Assuming you have the EndeavourOS “default” btrfs layout with a subvolume named @swap
:
- Create a 8GB swap file:
sudo btrfs filesystem mkswapfile --size 8g --uuid clear /swap/swapfile
sudo swapon /swap/swapfile
- Edit
/etc/fstab
and add
/dev/mapper/luks-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx /swap btrfs subvol=/@swap,defaults,compress=no 0 0
/swap/swapfile swap swap defaults,noatime 0 0
Make sure to use your mapped luks-device! Check with sudo blkid
- Take note of the resume offset
sudo btrfs inspect-internal map-swapfile -r /swap/swapfile
- Add resume device and offset to
/etc/kernel/cmdline
resume=/dev/mapper/luks-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx resume_offset=xxx
You could alternatively use the UUID of your mapped luks device, e. g. resume=UUID=a3d83cc0-84e0-4673-af97-742921cda13f
sudo reinstall-kernels
- Add resume hook to dracut. Edit
/etc/dracut.conf.d/resume.conf
add_dracutmodules+=" resume "
Edit: @Cubicle7595 reported in post #5 that the following workaround wasn’t needed anymore
You may also need to additionally add the following as a workaround for a recent bug; I don’t know if this has been resolved.
install_items+=" /usr/lib/systemd/system/systemd-hibernate-resume.service "
sudo dracut-rebuild