How do I add a swap partition after installing EOS?

I have already created a 16gb swap partition and I want to actually enable it.
Also please note that I need it for hibernation as well.

Please post the output of
lsblk -fs
and
cat /etc/fstab

`lsblk -fs`:
NAME FSTYPE FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
loop0
     squash 4.0                                                    0   100% /var/lib/snapd/snap/snapd/14295
loop1
     squash 4.0                                                    0   100% /var/lib/snapd/snap/bare/5
loop2
     squash 4.0                                                    0   100% /var/lib/snapd/snap/snapd/14549
loop3
     squash 4.0                                                    0   100% /var/lib/snapd/snap/core18/2284
loop4
     squash 4.0                                                    0   100% /var/lib/snapd/snap/gnome-3-28-1804/161
loop5
     squash 4.0                                                    0   100% /var/lib/snapd/snap/spotify/57
loop6
     squash 4.0                                                    0   100% /var/lib/snapd/snap/spotify/56
loop7
     squash 4.0                                                    0   100% /var/lib/snapd/snap/vlc/2344
loop8
     squash 4.0                                                    0   100% /var/lib/snapd/snap/gtk-common-themes/1519
loop9
     squash 4.0                                                    0   100% /var/lib/snapd/snap/teams/6
sda1 vfat   FAT32 NO_LABEL
│                       4A81-3497                             510.7M     0% /boot/efi
└─sda
                                                                            
sda2 ext4   1.0         7d39844e-d23b-432f-b32c-2be1eca5b9d3  393.8G     6% /
└─sda
                                                                            
sda3 swap   1           4edff8a1-0bc8-4974-80b6-3d990cdba082                [SWAP]
└─sda
                                                                            
nvme0n1p1
│    ntfs         Recovery
│                       56F0D3BBF0D39F93                                    
└─nvme0n1
                                                                            
nvme0n1p2
│    vfat   FAT32       BAD4-7990                                           
└─nvme0n1
                                                                            
nvme0n1p3
│                                                                           
└─nvme0n1
                                                                            
nvme0n1p4
│    ntfs         Sun Valley
│                       E8BCD85DBCD82838                                    
└─nvme0n1
                                                                            
nvme0n1p5
│    ntfs               22CAF23FCAF20EB3                                    
└─nvme0n1
`cat /etc/fstab`:
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=4A81-3497                            /boot/efi      vfat    umask=0077 0 2
UUID=7d39844e-d23b-432f-b32c-2be1eca5b9d3 /              ext4    defaults,noatime 0 1
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0

already there

but should be added in fstab

I have now added the swap partition to fstab but it still doesn’t work:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=4A81-3497                            /boot/efi      vfat    umask=0077 0 2
UUID=7d39844e-d23b-432f-b32c-2be1eca5b9d3 /              ext4    defaults,noatime 0 1
tmpfs                                     /tmp           tmpfs   defaults,noatime,mode=1777 0 0
UUID=4edff8a1-0bc8-4974-80b6-3d990cdba082 none   swap    sw      0       0

What should I do?

What doesn’t work?

what does sudo swapon -s show?

Please use code tags around what output you posted in all posts.

Edit: This makes it more readable.

  1. swap entry is malformatted should be like so:
    UUID=4edff8a1-0bc8-4974-80b6-3d990cdba082 swap swap defaults,noatime 0 0
  2. for resume/hibernation to work you need to setup resume:
    sudo nano /etc/default/grub
    and add resume=UUID=4edff8a1-0bc8-4974-80b6-3d990cdba082 to the GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=4edff8a1-0bc8-4974-80b6-3d990cdba082 loglevel=3 nowatchdog nvme_load=YES" line.
    After saved the filr rebuild grub.cfg: sudo grub-mkconfig -o /boot/grub/grub.cfg

Fstab

UUID=4A81-3497 /boot/efi vfat umask=0077 0 2
UUID=7d39844e-d23b-432f-b32c-2be1eca5b9d3 / ext4 defaults,noatime 0 1
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0
UUID=4edff8a1-0bc8-4974-80b6-3d990cdba082 swap swap defaults,noatime 0 0

GRUB boot loader configuration

GRUB_DEFAULT=0
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="EndeavourOS"
GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=4edff8a1-0bc8-4974-80b6-3d990cdba082 loglevel=3 nowatchdog nvme_load=YES
GRUB_CMDLINE_LINUX=""

I’ve configured both of them but when I hibernate, it still doesn’t work.
For the record, I’ve rebuilt grub.cfg.

Two things to check:

  1. /etc/default/grub

GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=4edff8a1-0bc8-4974-80b6-3d990cdba082 loglevel=3 nowatchdog nvme_load=YES

Can you check again if " exists after YES? From your post it seems you missed ".
It should look like ... nvme_load=YES"

If yes, the regenerate grub config again sudo grub-mkconfig -o /boot/grub/grub.cfg

  1. /etc/mkinitcpio.conf

Verify resume exists as in below ex:

HOOKS=(base udev autodetect keyboard modconf block filesystems resume fsck)

If resume already exists, then its all good.

If its not there, then regnerate initramfs sudo mkinitcpio -P

@joekamprad @ricklinux, hibernation page of Arch Wiki talk about this kernel parameter. Is it not required anymore?
resume_offset=swap_file_offset

1 Like

Ok so resume wasn’t there in /etc/mkinitcpio.conf so I regenerated initramfs with the command you mentioned but it still seems to say:HOOKS="base udev autodetect modconf block keyboard keymap filesystems fsck"
And yes, there was a " after nvme_load=YES.

You need to add resume in the HOOKS. Sorry for not being clear about it.

sudo nano /etc/mkinitcpio.conf and add it.

Then regenrate initramfs sudo mkinitcpio -P

Arch wiki link

Thank you very much.
That worked.

1 Like

I missed this one :wink:

But:

this is only needed if you are using swap file to define the exact location of the swapfile and notz needed for a swap partition because the exact location is defined with the UUID already :wink:

1 Like

Ahh, ok - It clearing says swap file :person_facepalming:. Thanks for clearing that up. I am a big dum dum.

same counts for me on forgetting the mkinitcpio one :wink:

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.