Hybrid sleep not working, suspend & hibernation works

Hi!

I have a System76 laptop with NixOS unstable on it

 - system: `"x86_64-linux"`
 - host os: `Linux 5.16.4, NixOS, 22.05 (Quokka)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.6.0`
 - channels(root): `"unstable-22.05pre343944.ff377a78794, nixos-hardware, nixos-21.11.335037.e67c94a1adb, master"`
 - channels(lillecarl): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Using the unstable channel to build my system

nixos on ξ‚  master [$!]
❯ neofetch
          β–—β–„β–„β–„       β–—β–„β–„β–„β–„    β–„β–„β–„β––            lillecarl@lemur
          β–œβ–ˆβ–ˆβ–ˆβ–™       β–œβ–ˆβ–ˆβ–ˆβ–™  β–Ÿβ–ˆβ–ˆβ–ˆβ–›            ---------------
           β–œβ–ˆβ–ˆβ–ˆβ–™       β–œβ–ˆβ–ˆβ–ˆβ–™β–Ÿβ–ˆβ–ˆβ–ˆβ–›             OS: NixOS 22.05 (Quokka) x86_64
            β–œβ–ˆβ–ˆβ–ˆβ–™       β–œβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–›              Host: Lemur Pro lemp10
     β–Ÿβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–™ β–œβ–ˆβ–ˆβ–ˆβ–ˆβ–›     β–Ÿβ–™        Kernel: 5.16.4
    β–Ÿβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–™ β–œβ–ˆβ–ˆβ–ˆβ–™    β–Ÿβ–ˆβ–ˆβ–™       Uptime: 10 hours, 23 mins
           β–„β–„β–„β–„β––           β–œβ–ˆβ–ˆβ–ˆβ–™  β–Ÿβ–ˆβ–ˆβ–ˆβ–›       Packages: 2648 (nix-system), 716 (nix-user), 55 (nix-default), 12 (flatpak)
          β–Ÿβ–ˆβ–ˆβ–ˆβ–›             β–œβ–ˆβ–ˆβ–› β–Ÿβ–ˆβ–ˆβ–ˆβ–›        Shell: zsh 5.8
         β–Ÿβ–ˆβ–ˆβ–ˆβ–›               β–œβ–› β–Ÿβ–ˆβ–ˆβ–ˆβ–›         Resolution: 1920x1080
β–Ÿβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–›                  β–Ÿβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–™   DE: Plasma 5.23.5
β–œβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–›                  β–Ÿβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–›   WM: KWin
      β–Ÿβ–ˆβ–ˆβ–ˆβ–› β–Ÿβ–™               β–Ÿβ–ˆβ–ˆβ–ˆβ–›            Theme: Breeze [GTK2/3]
     β–Ÿβ–ˆβ–ˆβ–ˆβ–› β–Ÿβ–ˆβ–ˆβ–™             β–Ÿβ–ˆβ–ˆβ–ˆβ–›             Icons: breeze-dark [GTK2/3]
    β–Ÿβ–ˆβ–ˆβ–ˆβ–›  β–œβ–ˆβ–ˆβ–ˆβ–™           ▝▀▀▀▀              Terminal: WezTerm
    β–œβ–ˆβ–ˆβ–›    β–œβ–ˆβ–ˆβ–ˆβ–™ β–œβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–›        CPU: 11th Gen Intel i7-1165G7 (8) @ 4.700GHz
     β–œβ–›     β–Ÿβ–ˆβ–ˆβ–ˆβ–ˆβ–™ β–œβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–›         GPU: Intel TigerLake-LP GT2 [Iris Xe Graphics]
           β–Ÿβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–™       β–œβ–ˆβ–ˆβ–ˆβ–™               Memory: 6647MiB / 39976MiB
          β–Ÿβ–ˆβ–ˆβ–ˆβ–›β–œβ–ˆβ–ˆβ–ˆβ–™       β–œβ–ˆβ–ˆβ–ˆβ–™
         β–Ÿβ–ˆβ–ˆβ–ˆβ–›  β–œβ–ˆβ–ˆβ–ˆβ–™       β–œβ–ˆβ–ˆβ–ˆβ–™
         ▝▀▀▀    β–€β–€β–€β–€β–˜       β–€β–€β–€β–˜


~
❯ pm-is-supported --suspend && echo yes
yes

~
❯ pm-is-supported --hibernate && echo yes
yes

~
❯ pm-is-supported --suspend-hybrid && echo yes

~
❯

pm-is-supported suggests my system doesn’t support hybrid sleeping, but what I don’t quite understand is how hybrid sleep is any different than a normal sleep (hardware support wise). Is this a hardware problem or something I could configure myself around?

❯ lsblk
NAME           MAJ:MIN  RM   SIZE RO TYPE  MOUNTPOINTS
nvme1n1        259:0     0 465.8G  0 disk
β”œβ”€nvme1n1p1    259:4     0     1G  0 part  /boot-fallback
└─nvme1n1p2    259:5     0 464.8G  0 part
  └─md1337       9:1337  0 464.6G  0 raid1
    β”œβ”€md1337p1 259:6     0    40G  0 part  [SWAP]
    └─md1337p2 259:7     0 424.6G  0 part
      └─crypt0 254:0     0 424.6G  0 crypt /var/lib/lxd/storage-pools/default
nvme0n1        259:1     0 465.8G  0 disk
β”œβ”€nvme0n1p1    259:2     0     1G  0 part  /boot
└─nvme0n1p2    259:3     0 464.8G  0 part
  └─md1337       9:1337  0 464.6G  0 raid1
    β”œβ”€md1337p1 259:6     0    40G  0 part  [SWAP]
    └─md1337p2 259:7     0 424.6G  0 part
      └─crypt0 254:0     0 424.6G  0 crypt /var/lib/lxd/storage-pools/default

I haven’t tried yet since I’m not sure if I’ll break something or not, but does the swap have to be bigger for hybrid sleep than hibernation somehow? The Linux kernel documentation in this area isn’t the clearest, or I’m looking at the wrong place.

My nix configuration is available here: https://github.com/lillecarl/nixos in case there’s anything you’d like to check out. The machine in question is β€œlemur”.

So what happens is that both suspend and hibernate works like they should, but hybrid sleep acts just like hibernation and shuts the machine off straight away after writing RAM to disk. I’ve messed with the sleep.conf file in may ways but what’s supposed to work according to the web doesn’t work for me. I’m not sure where I should start troubleshooting this either so I’m hoping someone knows something about these things here :slight_smile:

I tried reading the source for pm-is-supported, but i found the script implementation too complex/arcane for me to understand.

Thankful for anythings that might lead me in the right direction, don’t hesitate to ask if i left something you’d like to know out.

1 Like

https://www.freedesktop.org/software/systemd/man/systemd-sleep.conf.html#Description
A description of the 4 power saving modes supported by systemd, and by extension NixOS.

Just from reading the description it seems that hybrid-sleep will suspend the system AND in parallel write the system status to swap, while suspend-then-hibernate will first enter suspend status and after HibernateDelaySec (by default 2h) it will go into hibernation.

From my experience if the power saving mechanism works it is safe to use.

Which is what the systemd manual implies: its description only implies that it may be β€œslower” than hibernate to enter.

I understood it as that it would freeze the system and write to disk while staying in suspend mode until the power runs out, which in that case then has the system state on disk to boot into when power is returned.

Yeah I meant me talking about if I had to change my raided partition layout, which I’ve never done before. :slightly_smiling_face:

Thanks for the clarification.