You are not logged in.

#1 2022-07-19 13:11:25

0xfMel
Member
Registered: 2022-07-19
Posts: 4

Hibernation to swapfile in encrypted btrfs root not resuming

I'm testing this in a virtual machine.

When I hibernate the system the screen changes to display the following

:: running early hook [udev]
Starting version 251.3-1-arch
:: running hook [udev]
:: Triggering uevents...

then turns off.

When the resume hook is reached, the screen changes to display the same.  This time the system freezes permanently, with a non-flashing cursor on the line below it.  Resetting from this point boots normally with some warnings about fixing a dirty bit in the filesystem.

The partitions are as follows:
128M /boot/efi (fat32)
512M /boot (btrfs)
remaining encrypted with LUKS / (btrfs)

I've created a swapfile at /swap/swapfile.img as follows:

btrfs subvolume create /swap
chattr +C /swap
truncate -s 0 /swap/swapfile.img
chattr +C /swap/swapfile.img #to be safe
btrfs property set /swap/swapfile.img compression "" #to be safe
dd if=/dev/zero of=/swap/swapfile.img bs=4M count=6144 status=progress #24G swapfile
chmod 0600 /swap/swapfile.img
mkswap /swap/swapfile.img

/etc/fstab is as follows:

UUID=</dev/mapper/root UUID>    /    btrfs    rw,relatime,space_cache=v2,subvolid=5,subvol=/    0 0
UUID=</dev/vda2 UUID>    /boot    btrfs    rw,relatime,space_cache=v2,subvolid=5,subvol=/    0 0
UUID=</dev/vda1 UUID>    /boot/efi    vfat    rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro 0 2
/swap/swapfile.img    none    swap    defaults    0 0

my mkinitcpio hooks are:

base udev autodetect keyboard keymap modconf block encrypt filesystems resume fsck

my grub kernel params are:

cryptdevice=UUID=</dev/vda3 UUID>:root resume=UUID=</dev/mapper/root UUID> resume_offset=872973 loglevel=3

resume_offset value was generated with this c program, compiled locally: https://github.com/osandov/osandov-linu … physical.c
I took the physical offset of the first line and divided it by 4096 as per the wiki, which I checked is indeed the pagesize using getconf PAGESIZE

I don't see any errors relating to swap or hibernation in journalctl

Configuration originally setup on the zen kernel, but tested on vanilla and LTS as well, no difference.

Searched for a long time to see if I could find someone with a similar problem, couldn't find anyone.  Read through the wiki and other guides for setting this up and I don't see anything that I've done differently.
Thanks for any help.

Last edited by 0xfMel (2022-07-19 13:23:28)

Offline

#2 2022-07-19 18:50:49

obap74
Member
Registered: 2021-03-18
Posts: 69

Re: Hibernation to swapfile in encrypted btrfs root not resuming

I had a similar issue but only on my real hardware, it was working fine on a virtual machine. As mentioned in the thread, it wasn't working either on my Gentoo install with an identical setup.
I never found the culprit and gave up on using Btrfs. I stuck with LVM on LUKS and ext4, no issue.

Maybe the other thread will help you somehow. Does suspend work fine though? asking because you only mentioned hibernation.

Offline

#3 2022-07-19 20:10:14

0xfMel
Member
Registered: 2022-07-19
Posts: 4

Re: Hibernation to swapfile in encrypted btrfs root not resuming

Just tried suspending, it behaves the same way as booting from hibernation does.
Shows

:: running early hook [udev]
Starting version 251.3-1-arch
:: running hook [udev]
:: Triggering uevents...

with a non-flashing cursor, and completely freezes.  Doesn't even turn off, which unless that's just because I'm in a virtual machine, is the opposite of what you were experiencing.

Disappointing, unless someone can suggest anything to try I guess I will have to use LVM.

Offline

#4 2022-07-21 18:59:24

0xfMel
Member
Registered: 2022-07-19
Posts: 4

Re: Hibernation to swapfile in encrypted btrfs root not resuming

OK so now I'm even more confused, I noticed my host installation had suddenly stopped being able to hibernate too, is now acting the same way as the virtual machine.  My host is setup with an encrypted swap on LVM on LUKS, with an EXT4 root, and had been working before.  I'd changed a few things since I was last able to hibernate so I'm guessing it was something to do with that but I can't remember exactly what.  I tried the setup I outlined in my first post on an external drive to test on real hardware and it works fine.  Not sure what's going on now, was already planning on replacing my host installation (thats why I was testing this setup on a VM in the first place), so while the problem is still not solved, I don't really have a problem anymore.

Last edited by 0xfMel (2022-07-21 19:03:09)

Offline

Board footer

Powered by FluxBB