I do the same and use ugrd. I think dracut would also work.
You just set the resume kernel parameter to the decrypted memory device with the swapfile offset.
As long as the initrd attempts a resume after it decrypted all volumes it’ll work, and the initrd doesn’t even need to understand why and what was resumed from
It’s doable with a swap file instead. But some filesystems are more supportive than others.
For example BTRFS doesn’t support swapfiles over multiple devices (so my raid1c3 spanning 3 differently sized disks for example) and also swapfiles must be completely pre-allocated.
And no matter the filesystem you need to manually tell the kernel device and physical offset for the file via kernel parameters. Which can again be easier on some than on others (also causing the no-multiple-device filesystem problem mentioned above.
btrfs’s handling makes sense. The kernel talks to the disk directly, the file is just a pointer for what range it uses, and a placeholder for the filesystem. Something like raid, balancing, cow, all won’t work because the kernel doesn’t even go through btrfs to change the swap"file".
If you want a proper file as swapfile, with the corresponding overhead, you can make a regular file and mount it via loopback then use it as a swap device.
Don’t you need swap partitions to be able to use hibernation?
Been using a swap file in a luks partition for years. I hibernate very regularly.
Nah, you can use
resume_offsetinstead.Here’s an example: https://forum.endeavouros.com/t/how-to-hibernate-with-btrfs-swapfile-luks2-systemd-boot-dracut/55620/2
Nope, I hibernate with a swap file and it’s in a LUKS partition. Although IIRC that whole setup requires me to use systemd boot.
I do the same and use ugrd. I think dracut would also work.
You just set the resume kernel parameter to the decrypted memory device with the swapfile offset.
As long as the initrd attempts a resume after it decrypted all volumes it’ll work, and the initrd doesn’t even need to understand why and what was resumed from
It’s doable with a swap file instead. But some filesystems are more supportive than others.
For example BTRFS doesn’t support swapfiles over multiple devices (so my raid1c3 spanning 3 differently sized disks for example) and also swapfiles must be completely pre-allocated.
And no matter the filesystem you need to manually tell the kernel device and physical offset for the file via kernel parameters. Which can again be easier on some than on others (also causing the no-multiple-device filesystem problem mentioned above.
btrfs’s handling makes sense. The kernel talks to the disk directly, the file is just a pointer for what range it uses, and a placeholder for the filesystem. Something like raid, balancing, cow, all won’t work because the kernel doesn’t even go through btrfs to change the swap"file".
If you want a proper file as swapfile, with the corresponding overhead, you can make a regular file and mount it via loopback then use it as a swap device.
I don’t use hibernation so I’m not sure.
So you shut your pc down like a caveman when you do hardware upgrades or repairs or move apartments?
Yeah I shut down every day. It boots up fast enough that it’s really not an issue.