This is a setup on how to enable Hibernate on an LUKS encrypted Volume using a swap file. Why? Because if you are using an encrypted Swap partition, you'll have to enter your decryption password twice... and that's lame.
Tested on Manjaro.
btrfs subvolume create /swap
check: btrfs subvolume list /
mount /dev/mapper/luks-79f8dd77-b3a6-4d9f-803c-0d5b3f2fe621 /swap -o subvol=/@/swap
Note: Manjaro uses /@
as BTRFS root, this may vary on your setup
check: mount | grep swap
/dev/mapper/luks-79f8dd77-b3a6-4d9f-803c-0d5b3f2fe621 /swap btrfs subvol=/@/swap,noatime,nodiratime,nodatacow,compress=no 0 0
and
/swap/swapfile swap swap defaults 0 0
fallocate -l 64G /swap/swapfile
chmod 600 /swap/swapfile
mkswap /swap/swapfile
swapon /swap/swapfile
check: cat /proc/swaps
in /etc/mkinitcpio.conf
append resume
on hooks. Note that it must be after dm-crypt and lvm (see: https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Configure_the_initramfs)
execute mkinitcpio -p linux614
afterwards to generate initframes. Note: 614 is the target kernel version and may differ.
resume offset: btrfs inspect-internal map-swapfile -r /swap/swapfile
swap uuid: blkid /swap/swapfile
Note the results.
Add GRUB_CMDLINE_LINUX="RESUME=UUID=99856d6e-4b5d-4d25-8404-aae68fd33108 RESUME_OFFSET=194570203"
to /etc/default/grub with your own values from step 7 obviously...
Finally execute update-grub