On Linux, it’s possible to control which RAM-based sleep state computer prefers by setting mem_sleep_default
kernel parameter. These parameters are often referred to as S-states.
A full list of all S-states is as follows:
- S0 - Fully On (Normal operation)
- S0ix - Modern Standby / Connected Standby (low-power idle state)
- S1 - Power on Suspend
- S2 - CPU powered off
- S3 - Suspend to RAM (also known as Sleep or Standby)
- S4 - Suspend to Disk (Hibernate)
- S5 - Soft Off (Shutdown, but still drawing some power)
- G3 - Mechanical Off (No power draw at all)
S1 and S2 are largely obsolete and not commonly used in modern systems.
The deeper the sleep state, the more power is saved, but it may take longer to resume.
The mem_sleep_default
parameter is primarily designed to control the choice between different RAM-based sleep states.
s2idle
This corresponds to S0ix (Modern Standby)shallow
This is an intermediate state between s2idle and deepdeep
This corresponds to S3 (Suspend to RAM)
Using deep sleep can potentially lead to more power savings, and most likely a preferred option on laptops or other battery-powered devices. s2idle is another popular choice, but doesn’t have great hardware support. Support for s2idle could be checked with a following python script.
While S3 and S0ix keep the system in a low-power state with some components still powered, S4 saves the entire system state to disk and then powers off the system completely. S4 often results in maximum power savings at the cost of longer resume times compared to other sleep states, but could not be configured as option for mem_sleep_default
.
My laptop supports S0ix (s2idle), but in practice,laptop battery lasts significantly longer with a closed lid in s3 (deep) state. In case of power button is pushed, it’s better to go into S5 (hibernate) state. It’s great that that there is ability to tweak that in Linux!