Power Management: Difference between revisions
Hustlerone (talk | contribs) m remove some whitespace and fix typo |
|||
(2 intermediate revisions by 2 users not shown) | |||
Line 43: | Line 43: | ||
=== Hibernation === | === Hibernation === | ||
Hibernation requires a configured swap device. See [https://nixos.org/manual/nixos/stable/#ch-installation installation instructions] on how to create a swap partition. | Hibernation requires a configured swap device. See [https://nixos.org/manual/nixos/stable/#ch-installation installation instructions] on how to create a swap partition. | ||
Please note that <code>resumeDevice</code> must match the output of <code>swapon -s</code> especially if you're dealing with mapped volumes (LUKS, logical volumes, logical volumes under LUKS, etc.). If you're using a swapfile, you must also [https://search.nixos.org/options?channel=unstable&show=boot.resumeDevice&from=0&size=50&sort=relevance&type=packages&query=resume+offset specify the offset to it.] | |||
Therefore, an example configuration could look like this:<syntaxhighlight lang="nix"> | |||
/* | |||
I'm hibernating into a logical volume that's also under LUKS. Pretty cool, right? | |||
*/ | |||
swapDevices = [ | swapDevices = [ | ||
{ | { | ||
device = "/dev/ | device = "/dev/VG/SWAP"; | ||
} | } | ||
]; | ]; | ||
Test and use hibernation with following command:<syntaxhighlight lang="nix"> | boot.resumeDevice = "/dev/dm-7"; | ||
</syntaxhighlight>Derived from a system with the following output from <code>swapon -s</code> :<syntaxhighlight> | |||
Filename Type Size Used Priority | |||
/dev/dm-7 partition 67108860 00 | |||
/dev/zram0 partition 32881148 032767 | |||
</syntaxhighlight> | |||
Test and use hibernation with the following command:<syntaxhighlight lang="nix"> | |||
systemctl hibernate | systemctl hibernate | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 62: | Line 76: | ||
systemd.sleep.extraConfig = '' | systemd.sleep.extraConfig = '' | ||
HibernateDelaySec=1h | HibernateDelaySec=1h | ||
''; | |||
</syntaxhighlight> | |||
Or, to disable suspend entirely, consider a configuration like this: | |||
<syntaxhighlight lang="nix"> | |||
systemd.sleep.extraConfig = '' | |||
AllowSuspend=no | |||
AllowHibernation=no | |||
AllowHybridSleep=no | |||
AllowSuspendThenHibernate=no | |||
''; | ''; | ||
</syntaxhighlight> | </syntaxhighlight> |