I did a quick check in VirtualBox. Actually /etc/default/grub has everything set up correctly out of the box. The only thing that needs to be added is the swapfile offset.
I propose changing the wiki swapfile part to the following …
Make a swapfile
If you want to use hibernation, then you must add swap because the content of the RAM will be written to the swap partition/file. This also means that the swap size should be at least the size of RAM .
The following commands will produce a swapfile the size of 8GB . copy and paste them one after the other inside terminal and give your root password .
If you want more or less swap change 8G to what you want to use as swap.
sudo fallocate -l 8G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
To check …
swapon --show
Edit /etc/fstab to enable the swapfile after reboot
sudo leafpad /etc/fstab
Add the following line …
/swapfile none swap defaults,pri=-2 0 0
Save and exit.
Activate hibernation
sudo filefrag -v /swapfile | awk '{if($1=="0:"){print $4}}'
returns the swapfile offset. For example 997376..
, which means 997376.
sudo leafpad /etc/default/grub
Change to the following; remember to use your offset .
It will first look like this: (*** are the long snake of UUID numbers)
GRUB_CMDLINE_LINUX_DEFAULT=“quiet cryptdevice=UUID=:luks- root=/dev/mapper/luks-*** resume=/dev/mapper/luks-*** loglevel=3”
Add resume_offset=
***** to the end of this line (after loglevel=3).
Insert offset number we got from the command before here.
Save and exit
Add resume
to /etc/mkinitcpio.conf, do this now …
sudo leafpad /etc/mkinitcpio.conf
Change the HOOKS=… line by adding resume
.
HOOKS=“base udev autodetect modconf block keyboard keymap encrypt lvm2 resume filesystems fsck”
Save and exit
rebuild kernel images and grub.cfg:
EFI and Bios systems:
sudo mkinitcpio -p linux
sudo grub-mkconfig -o /boot/grub/grub.cfg