How do I hibernate my Fedora 40 laptop with a swapfile on an encrypted btrfs filesystem?
1
vote
1
answer
93
views
When I attempt to hibernate, my laptop hangs. It shows the screen wallpaper, then a black screen (as if it's going to hibernate), then the screen wallpaper again. Then it seems to freeze; I cannot get any more response out of it at that point. What am I missing? Thanks.
I am running Fedora 40 Linux with kernel 6.11.10-200.fc40.x86_64.
Here is what I attempted so far:
- Created a swapfile larger than zram0 swap + 64 Gig system ram.
btrfs filesystem mkswapfile --size 80G /swapfile
- Edited /etc/fstab and put in: /swapfile none swap sw 0 0
- Rebooted, run:
swapon -s
Filename Type Size Used Priority
/swapfile file 83886076 0 -2
/dev/zram0 partition 8388604 0 100
- See the luks UUID, and the btrfs filesystem UUID:
blkid | grep luks
/dev/mapper/luks-319127be-114d-4dd2-884b-0a04642c538a: LABEL="fedora" UUID="7a4b5350-4d8a-44ee-83b7-f612701eca51" UUID_SUB="f98c2850-16e0-4144-a4df-da5f1302e0a9" BLOCK_SIZE="4096" TYPE="btrfs"
- See the btrfs offset:
btrfs inspect-internal map-swapfile -r /swapfile
134685952
- vim /etc/default/grub
and modified GRUB_CMDLINE_LINUX
(shown here line wrapped):
GRUB_CMDLINE_LINUX="rd.luks.uuid=luks-319127be-114d-4dd2-884b-0a04642c538a rhgb quiet
mem_sleep_default=deep resume=UUID=7a4b5350-4d8a-44ee-83b7-f612701eca51
resume_offset=134685952"
- Edit resume.conf: vim /etc/dracut.conf.d/resume.conf
- Insert the following. Note the spaces in the first two entries:
add_device+=" /dev/mapper/luks-319127be-114d-4dd2-884b-0a04642c538a "
add_dracutmodules+=" resume "
resume="UUID=7a4b5350-4d8a-44ee-83b7-f612701eca51"
resume_offset="134685952"
- Remake grub config. Remake initramfs image:
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
dracut -f
- vim /etc/systemd/sleep.conf
and put in it:
[Sleep]
AllowHibernation=yes
HibernateMode=platform shutdown
HibernateState=disk
- Now run: systemctl daemon-reload
- Reboot
- On command line: systemctl hibernate
- Machine freezes.
Edit:
Note that I've disabled Secure Boot, and I've disabled selinux. It looks like it takes 30 or so seconds to shut down. The system does not hibernate, it goes to power off now. After this poweroff, when I power the machine back on my existing desktop is gone so it's not recovering from hibernate.
Asked by Mike S
(2732 rep)
Dec 7, 2024, 12:25 AM
Last activity: Dec 7, 2024, 11:12 PM
Last activity: Dec 7, 2024, 11:12 PM