Jump to content

Power Management: Difference between revisions

Add notes on hibernation
imported>Lelgenio
(Add workaround for systems that immediatly wakeup after beign suspended)
(Add notes on hibernation)
 
(One intermediate revision by one other user not shown)
Line 13: Line 13:
</syntaxhighlight>
</syntaxhighlight>


It is also possible, to use the <code>post-resume</code> target directly to make a service.
It is also possible to use the <code>post-resume</code> target directly to make a service.
Refer to the [[Systemd Services]] article for details about writing systemd services for NixOS.


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 28: Line 27:
</syntaxhighlight>
</syntaxhighlight>


=== Troubleshooting ===
== 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. An example configuration could look like this:<syntaxhighlight lang="nix">
swapDevices = [
  {
    device = "/dev/hda7";
  }
];
boot.resumeDevice = "/dev/hda7";
</syntaxhighlight>Please note that encrypted swap devices or swap files are not yet supported for hibernation.


==== System Immediately wakes up from suspend ====
Test and use hibernation with following command:<syntaxhighlight lang="nix">
systemctl hibernate
</syntaxhighlight>
 
== Tips and tricks ==
 
=== Go into hibernate after specific suspend time ===
Using following configuration, your system will go from suspend into hibernate after 1 hour:<syntaxhighlight lang="nix">
systemd.sleep.extraConfig = ''
  HibernateDelaySec=1h
'';
</syntaxhighlight>
 
== Troubleshooting ==
 
==== System immediately wakes up from suspend ====


Particularly in some gigabyte motherboards with NVMe drives, the system may immediately wake up from being suspended.
Particularly in some Gigabyte motherboards with NVMe drives, the system may immediately wake up from being suspended.
This can be worked around by disabling the wakeup triggers for the offending components:
This can be worked around by disabling the wakeup triggers for the offending components:


===== Solution 1: Disabling wakeup triggers for all PCIe devices =====
===== Solution 1: Disabling wakeup triggers for all PCIe devices =====


If you don't need your system to wakeup via PCIe components you can simply disable it for all without needing to search for what component is causing problems.
If you don't need your system to wakeup via PCIe components you can simply disable it for all without needing to determine which component is causing problems.


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 45: Line 67:
</syntaxhighlight>
</syntaxhighlight>


===== Solution 2: Disabling a common NVMe interface =====
===== Solution 2: Disable a common NVMe interface =====


Specifically on Gigabyte motherboards you can try targetting only the NVMe ports.
Specifically on Gigabyte motherboards you can try targetting only the NVMe ports.
Line 55: Line 77:
</syntaxhighlight>
</syntaxhighlight>


===== Solution 3: Disabling a single device's wakeup triggers =====
===== Solution 3: Disable a single device's wakeup triggers =====
If you wish to be more granular in what components should no longer be able to wakeup your system you can manually search what component is causing the wakeup events.
If you wish to be more granular in what components should no longer be able to wakeup your system, you can find out which component is causing the wakeup events.


First, list all components and their current wakeup status:
First, list all components and their current wakeup status:
Line 72: Line 94:
</syntaxhighlight>
</syntaxhighlight>


You can temporarily toggle a device by sending it's "Device" collumn back into `/proc/acpi/wakeup`
You can temporarily toggle a device by writing its "Device" name back into <code>/proc/acpi/wakeup</code>


<syntaxhighlight lang="sh">
<syntaxhighlight lang="sh">
Line 87: Line 109:
</syntaxhighlight>
</syntaxhighlight>


And finally use those values in a udev rule:
And finally use those values in a <code>udev</code> rule:
   
   
<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 94: Line 116:
'';
'';
</syntaxhighlight>
</syntaxhighlight>
== See also ==
* [[Laptop]]


== External resources ==
== External resources ==


* {{manual:nixos|sec=#sec-rebooting|chapter=Chapter 23. Rebooting and Shutting Down}}
* {{manual:nixos|sec=#sec-rebooting|chapter=Chapter 23. Rebooting and Shutting Down}}
62

edits