Discussed in the Fedora KDE SIG Matrix channel. Setting up hibernation with the myriad of file systems and methods out there isn't a simple task for a user. Plasma's Power KCM could offer the user options to set up hibernation including working with file systems to ensure it is set up correctly e.g. BTRFS subvolumes.
Let me go a step further here: we could just dynamically create a swap file whenever hibernation is enabled. On Btrfs, all that's required to do is the following: $ truncate -s 0 swapfile $ chattr +C swapfile $ fallocate -l 32G swapfile # set this to just slightly larger than how much RAM is on the system $ chmod 0600 swapfile $ mkswap swapfile $ swapon swapfile Ideally, this swap file exists in a Btrfs subvolume that has "chattr +C" set on it, because we can use that subvolume to create more swap files as needed for performance.
But setting up a swap file is just half of the work, right? You still need to tell the kernel about it: https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation Not sure if it works differently between different distributions also. So yes, sounds like something nice, but also non-trivial to implement.
With some things like disk changes, you can update the kernel about it with certain commands. I wonder if you can do that with Hibernation as well.
You can use "grubby" in Fedora to do that easily and persistently. $ grubby --update-kernel=ALL --args=”<new cmdline args>” Other distributions may either have a commandline tool or just rely on updating /etc/default/grub. Probably the correct way to deal with this is provide a hook that a distribution can fill in with a script/command/etc. to handle it.
That's a good idea, it could be a file on the system or something added at compile time. The file if detected would then show the Hibernation settings in the KCM. The file would contain the commands necessary to enable and disable hibernation on that particular OS.
In case it's helpful, we have an implementation of the swap setup and management dance in https://github.com/facebook/chef-cookbooks/tree/main/cookbooks/fb_swap . While this won't be directly usable for this purpose, the systemd logic in there can likely be cribbed, or at least used as inspiration.