Swapfile on Btrfs does not start at boot

  • Done
  • quality assurance status badge
Details
4 participants
  • Brice Waegeneire
  • Josselin Poiret
  • John Kehayias
  • Zacchaeus Scheffer
Owner
unassigned
Submitted by
John Kehayias
Severity
normal
J
J
John Kehayias wrote on 24 Sep 2021 23:14
(name . bug-guix@gnu.org)(address . bug-guix@gnu.org)
TbQsNMzraZIGit6atyA0OzZlPwfsAZD8xpzM2LjZMnWEvV_d7Zs5OPpmUPiTl19KiOQvmw6Y6-eg8QHdOsxLOf6siP-wVjZAB-h2KzyBWiQ=@protonmail.com
Hi all,

This has been discussed a few times on #guix, with some having success, but mostly it seems not. The issue is having a swapfile (maybe also for partition?) on Btrfs and swap not being activated on boot. In my case, I can manually start with `sudo herd start swap-/swap/swapfile` and it will work fine. There might be an issue with when different filesystems are loaded with Btrfs subvolumes? I have my swap as a file on a subvolume.

From syslog, just before and after the only "swap" related message:

Sep 23 13:09:31 localhost vmunix: [ 9.424364] shepherd[1]: Service udev has been started.
Sep 23 13:09:31 localhost vmunix: [ 9.424466] Unable to find swap-space signature
Sep 23 13:09:31 localhost vmunix: [ 9.424912] shepherd[1]: Service user-file-systems has been started.
Sep 23 13:09:31 localhost vmunix: [ 9.443245] shepherd[1]: Service file-system-/swap has been started.
Sep 23 13:09:31 localhost vmunix: [ 9.454002] shepherd[1]: Service file-system-/var/log has been started.
Sep 23 13:09:31 localhost vmunix: [ 9.464911] shepherd[1]: Service file-system-/home has been started.

Checking the status of the service shows:

It is stopped.
It is enabled.
Provides (swap-/swap/swapfile).
Requires (udev).
Conflicts with ().
Will not be respawned.

This is the file-systems and swap part of my system configuration:

(file-systems (append
(list (file-system
(device (file-system-label "system"))
(mount-point "/")
(type "btrfs")
(flags '(no-atime))
(options "subvol=root,compress=lzo,ssd"))
(file-system
(device (file-system-label "system"))
(mount-point "/swap")
(type "btrfs")
(flags '(no-atime))
(options "subvol=swap,ssd"))
(file-system
(device (file-system-label "system"))
(mount-point "/gnu/store")
(type "btrfs")
(flags '(no-atime))
(options "subvol=gnu-store,compress=lzo,ssd"))
(file-system
(device (file-system-label "system"))
(mount-point "/var/log")
(type "btrfs")
(flags '(no-atime))
(options "subvol=var-log,compress=lzo,ssd"))
(file-system
(device (file-system-label "system"))
(mount-point "/home")
(type "btrfs")
(flags '(no-atime))
(options "subvol=home,compress=lzo,ssd"))
(file-system
(device (uuid "5989-F926" 'fat))
(mount-point "/boot/efi")
(type "vfat")))
%base-file-systems))
(swap-devices (list "/swap/swapfile"))

Hope this is helpful in tracking down what is happening, I know I'm not alone in this issue.

John
Z
Z
Zacchaeus Scheffer wrote on 25 Sep 2021 01:13
(address . 50788@debbugs.gnu.org)
CAJejy7nU2eBWbe9iS86wug5+7jX6owno+-wnFJRE35aD6j9MrA@mail.gmail.com
I have the same problem. I can start the swapfile normally with herd start
swap-/swap/swapfile, but it fails to start at boot.

Here are the (possibly) relevant parts of my system configuration:
(mapped-devices
(list
(mapped-device
(source (uuid "59d615e4-8a35-469c-aa24-88f28f084847"))
(target "ex")
(type luks-device-mapping))))
(file-systems
(append
(list
(file-system
(type "btrfs")
(mount-point "/")
(device (file-system-label "ex"))
(options "subvol=guix")
(dependencies mapped-devices))
(file-system
(type "btrfs")
(mount-point "/swap")
(device (file-system-label "ex"))
(options "subvol=swap")
(dependencies mapped-devices))
(file-system
(type "vfat")
(mount-point "/boot/efi")
(device (file-system-label "EFI"))))
%base-file-systems))
(swap-devices
(list "/swap/swapfile"))

Let me know if I should include more info.

-Zacchae
Attachment: file
B
B
Brice Waegeneire wrote on 25 Sep 2021 14:54
Re: bug#50788: Swapfile on Btrfs does not start at boot
(name . John Kehayias)(address . john.kehayias@protonmail.com)
877df4hl2g.fsf@waegenei.re
Hello John and Zacchaeus,

A month ago I open a thread in guix-devel titled “Using a swapfile on btrfs for
hibernation”¹ describing in depth my setup about your specific issue but it had
no response so far. It should be detailled enought for you to reproduce a
similar setup and if not I would like your feedbakc on it.

John Kehayias <john.kehayias@protonmail.com> writes:

Toggle quote (6 lines)
> This has been discussed a few times on #guix, with some having success, but mostly it seems not. The issue is having a swapfile (maybe also for partition?) on Btrfs and swap not being activated on boot. In my case, I can manually start with `sudo herd start swap-/swap/swapfile` and it will work fine. There might be an issue with when different filesystems are loaded with Btrfs subvolumes? I have my swap as a file on a subvolume.
>


>>From syslog, just before and after the only "swap" related message:

[...]

Toggle quote (2 lines)
> Checking the status of the service shows:

[...]

Toggle quote (2 lines)
> This is the file-systems and swap part of my system configuration:

Following are the same output as yours but from a working setup.

Toggle snippet (11 lines)
# dmesg
[...]
[ 6.393304] shepherd[1]: Service udev has been started.
[ 6.431318] Adding 32488200k swap on /swap/swapfile. Priority:-2 extents:2 across:32706248k FS
[ 6.433275] shepherd[1]: Service swap-/swap/swapfile has been started.
[ 6.434347] shepherd[1]: Service user-file-systems has been started.
[ 6.469352] shepherd[1]: Service file-system-/boot/efi has been started.
[ 6.535679] shepherd[1]: Service file-system-/home has been started.
[...]

Toggle snippet (11 lines)
# herd status swap-/swap/swapfile
Status of swap-/swap/swapfile:
It is started.
Running value is #t.
It is enabled.
Provides (swap-/swap/swapfile).
Requires (udev).
Conflicts with ().
Will not be respawned.

Here are the file-systems and swap-devices fields of my operating-system:
Toggle snippet (27 lines)
(file-systems
(append (list (file-system
(mount-point "/boot/efi")
(device (uuid "588A-2266" 'fat32))
(type "vfat"))
(file-system
(mount-point "/swap")
(device (uuid "2ab8e658-5878-4acd-ba33-8a46707a3828" 'btrfs))
(type "btrfs")
(needed-for-boot? #t)
(options "compress=zstd,subvol=swap")))
(hash-map->list
(lambda (mount-point subvolume)
(file-system
(mount-point mount-point)
(device (uuid "2ab8e658-5878-4acd-ba33-8a46707a3828" 'btrfs))
(type "btrfs")
(options (string-append "compress=zstd" ",subvol=" subvolume))))
(alist->hash-table '(("/" . "guix-system")
("/home" . "home")
;; ("/swap" . "swap")
("/mnt/btrfs-root" . "/"))))
%base-file-systems))

(swap-devices (list "/swap/swapfile"))

Toggle quote (2 lines)
> Hope this is helpful in tracking down what is happening, I know I'm not alone in this issue.

I think you are just missing “(needed-for-boot? #t)” on your swap subvolume,
even tho you shouldn't need to have it mounted from the initramfs (except if you
want to hibernate on your swapfile). On the thread previsouly cited¹, I suggest
two new records “swap-file” and “swap-device” where it would make sense to add
an additional “dependecies” field, similar to the one in ”file-system” record,
which would list the “file-system” to be mounted before activating that swap
file (or device).

Hope it helps.


Cheers,
- Brice
Z
Z
Zacchaeus Scheffer wrote on 27 Sep 2021 17:37
(name . Brice Waegeneire)(address . brice@waegenei.re)
CAJejy7mBxVpn6-cYgvHNboR5bURm_0T1NtPgai8H3sAYEuyJEg@mail.gmail.com
Hi Brice,

Yes, setting "(needed-for-boot? #t)" did it for me. I agree that adding a
dependencies field for swap devices is the "correct" solution.

Thanks,
-Zacchae

On Sat, Sep 25, 2021 at 8:54 AM Brice Waegeneire <brice@waegenei.re> wrote:

Toggle quote (114 lines)
>
> Hello John and Zacchaeus,
>
> A month ago I open a thread in guix-devel titled “Using a swapfile on
> btrfs for
> hibernation”¹ describing in depth my setup about your specific issue but
> it had
> no response so far. It should be detailled enought for you to reproduce a
> similar setup and if not I would like your feedbakc on it.
>
> John Kehayias <john.kehayias@protonmail.com> writes:
>
> > This has been discussed a few times on #guix, with some having success,
> but mostly it seems not. The issue is having a swapfile (maybe also for
> partition?) on Btrfs and swap not being activated on boot. In my case, I
> can manually start with `sudo herd start swap-/swap/swapfile` and it will
> work fine. There might be an issue with when different filesystems are
> loaded with Btrfs subvolumes? I have my swap as a file on a subvolume.
> >
>
>
> >>From syslog, just before and after the only "swap" related message:
>
> [...]
>
> > Checking the status of the service shows:
>
> [...]
>
> > This is the file-systems and swap part of my system configuration:
>
> Following are the same output as yours but from a working setup.
>
> --8<---------------cut here---------------start------------->8---
> # dmesg
> [...]
> [ 6.393304] shepherd[1]: Service udev has been started.
> [ 6.431318] Adding 32488200k swap on /swap/swapfile. Priority:-2
> extents:2 across:32706248k FS
> [ 6.433275] shepherd[1]: Service swap-/swap/swapfile has been started.
> [ 6.434347] shepherd[1]: Service user-file-systems has been started.
> [ 6.469352] shepherd[1]: Service file-system-/boot/efi has been started.
> [ 6.535679] shepherd[1]: Service file-system-/home has been started.
> [...]
> --8<---------------cut here---------------end--------------->8---
>
> --8<---------------cut here---------------start------------->8---
> # herd status swap-/swap/swapfile
> Status of swap-/swap/swapfile:
> It is started.
> Running value is #t.
> It is enabled.
> Provides (swap-/swap/swapfile).
> Requires (udev).
> Conflicts with ().
> Will not be respawned.
> --8<---------------cut here---------------end--------------->8---
>
> Here are the file-systems and swap-devices fields of my operating-system:
> --8<---------------cut here---------------start------------->8---
> (file-systems
> (append (list (file-system
> (mount-point "/boot/efi")
> (device (uuid "588A-2266" 'fat32))
> (type "vfat"))
> (file-system
> (mount-point "/swap")
> (device (uuid "2ab8e658-5878-4acd-ba33-8a46707a3828"
> 'btrfs))
> (type "btrfs")
> (needed-for-boot? #t)
> (options "compress=zstd,subvol=swap")))
> (hash-map->list
> (lambda (mount-point subvolume)
> (file-system
> (mount-point mount-point)
> (device (uuid "2ab8e658-5878-4acd-ba33-8a46707a3828"
> 'btrfs))
> (type "btrfs")
> (options (string-append "compress=zstd" ",subvol="
> subvolume))))
> (alist->hash-table '(("/" . "guix-system")
> ("/home" . "home")
> ;; ("/swap" . "swap")
> ("/mnt/btrfs-root" . "/"))))
> %base-file-systems))
>
> (swap-devices (list "/swap/swapfile"))
> --8<---------------cut here---------------end--------------->8---
>
> > Hope this is helpful in tracking down what is happening, I know I'm not
> alone in this issue.
>
> I think you are just missing “(needed-for-boot? #t)” on your swap
> subvolume,
> even tho you shouldn't need to have it mounted from the initramfs (except
> if you
> want to hibernate on your swapfile). On the thread previsouly cited¹, I
> suggest
> two new records “swap-file” and “swap-device” where it would make sense to
> add
> an additional “dependecies” field, similar to the one in ”file-system”
> record,
> which would list the “file-system” to be mounted before activating that
> swap
> file (or device).
>
> Hope it helps.
>
> ¹ https://yhetil.org/guix/87zgt9nrmg.fsf@waegenei.re/
>
> Cheers,
> - Brice
>
Attachment: file
J
J
John Kehayias wrote on 27 Sep 2021 20:25
(name . Zacchaeus Scheffer)(address . zaccysc@gmail.com)
ONwHpLBH-3TrqkLna9gc3DncEc7452sOma8xcRj86IpkL8H1L_7DWeGWGX2d6jfcxjLyK-jXuz8SoN-QXq2TnA6LUd9PyM7FSzTB3tg2FVY=@protonmail.com
Hi Brice and Zacchaeus,

??????? Original Message ???????
On Monday, September 27th, 2021 at 11:37 AM, Zacchaeus Scheffer wrote:

Toggle quote (4 lines)
> Hi Brice,
>
> Yes, setting "(needed-for-boot? #t)" did it for me. I agree that adding a dependencies field for swap devices is the "correct" solution.

Worked for me too, thanks! I'm guessing this is only needed for btrfs not ext4 for example? In any event, I support any change that makes it more obvious, at the very least a note and example in the documentation for swap.

John
Attachment: file
J
J
Josselin Poiret wrote on 6 Feb 2022 21:20
Re: Swapfile on Btrfs does not start at boot
(address . 50788-done@debbugs.gnu.org)
87mtj34uic.fsf@jpoiret.xyz
Hello,

swap-devices now include a dependencies system since
133a61ae263520378ac44482810d7adecfb017d9, see "(guix) Swap Space".

Closing.

--
Josselin Poiret
Closed
?