-
-
Notifications
You must be signed in to change notification settings - Fork 205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
resumeDevice for swap on btrfs #651
Comments
Unfortunately, as far as I am aware, there is currently no way to enable this with disko. Instead, I use LVM and a dedicated swap volume instead of a btrfs subvolume, if that helps at all. |
Support for It doesn't make much sense, unfortunately – in order for suspend/hibernate to work with btrfs, kernel needs not only It doesn't look like You can read more here: https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Acquire_swap_file_offset |
@MithicSpirit some of the options you mentioned are a part of PR #752 |
Hey, just wanted to let you know that with |
Got a good guide on how I'd enable swap hibernate on my Nix config then? I'm using a swapfile on a LUKS encrypted BTRFS subvolume. I already have systemd enabled in the initrd. |
I just created my swapfile using disko like in this example: https://github.com/nix-community/disko/blob/master/example/luks-btrfs-subvolumes.nix I neither have Then when i do systemctl hibernate everything just works. On boot I select the latest generation in systemd boot (the autoselected one) and enter the luks passphrase. |
Okay, I checked that, and I have my swapfile set up in a similar manner, but when I attempt to run systemctl hibernate it gives me this (for reference in case I need it, I have 32GB of RAM):
I have the swap subvolume set up like this: |
It shows that your swapfile is only 20 Megabytes. Normally one should have as much swap space as RAM so you have to change that to 32G. |
Yep, I changed that in my disko config to 38G, and that change makes it work. So for my BTRFS subvolume, since I already partitioned my drive, I couldn't run that, so doing this made it work:
|
One additional note: I disagree that it would be in-scope for disko to handle swapfiles. Swap partitions, sure, but if you want a swapfile you can just add
To your regular config, and this has nothing to do with partitioning. Using this option will automatically set Unless another maintainer disagrees, I would close this issue. |
This doesn't work on btrfs. According to the wiki, it's necessary to run some commands beforehand due to btrfs nuances. If that's not in scope for disko, then I'm not sure what is. |
What wiki are we talking about here? According to https://wiki.nixos.org/wiki/Btrfs#Swap_file:
This is definitely in scope, but all of the commands that follow are basic creation of a subvolume, which is already supported:
Further:
So to me it seems there is a bug in nixpkgs and the activation script in NixOS should check what filesystem the swapfile is supposed to be on, and if it's btrfs, use that to create the file instead of dd. I'm not opposed to writing a PR for this in nixpkgs, but I need your support with testing as I don't use btrfs for my root filesystem. Also, if you have differing information, let me know. |
I do not quite understand the problem, disko already creates the swapfile on btrfs automatically which is shown in the example btrfs config. For going into hibernation, nothing has to be specified, because systemd detects it automatically. One can specify For resuming from hibernation, nothing has to be specified in the case of using systemd in the intitrd, as systemd persists the values used when it started hibernation to the efivars. As the resume offset can only be calculated after creating the swapfile, one would need to have to run a script for dynamically generating kernel parameters, which I do not know whether that is currently possible in NixOS. More infos are in these issues from systemd: systemd/systemd#23177 systemd/systemd#27247 The simplest way is probably to document the behavior:
The correct way is probably to dynamically add the resume offset to the kernel parameters on |
Yeah, this is what I meant
That's fair. If it's fixed in nixpkgs, then I think it's fine to remove from disko.
I'd probably end up having to test in a VM, but sure. |
I did not realize that, sorry. This seems to be a unique feature in disko's btrfs module, and indeed it creates the swapfile with
Just to make sure, if
The activation script also changes the boot configuration, so I'd say yes, though I haven't checked yet how well this fits in with the current structure. Would that be what's required for making btrfs swapfiles compatible with Grub as well?
I would like that, it seems kinda odd that disko would do this one thing that doesn't have anything to do with formatting or disk layout for this one filesystem only. Would need a bit of a transition period, though. |
I don't think enabling
I think documenting this behavior, maybe even just as a comment in the mentioned example file, should be enough. |
Hi, I have a btrfs partitioned disk without lvm (kind of like in this example https://github.com/nix-community/disko/blob/master/example/btrfs-subvolumes.nix), I've tried to enable hibernation via |
How does one enable
resumeDevice
for a swapfile that is in a btrfs subvolume? Looking through https://github.com/nix-community/disko/blob/master/lib/types/btrfs.nix, there seem to be no options for this. I think it would also be nice to support other options from https://github.com/nix-community/disko/blob/master/lib/types/swap.nix if possible, such aspriority
,randomEncryption
, anddiscardPolicy
(although I am not as interested in these).The text was updated successfully, but these errors were encountered: