Is hybrid-sleep effective in case of battery drain (restoring session and open programs)

hibernatehybrid-sleeplaptopsuspend

enter image description here

I think that Sleep/Suspend to RAM is just saving session to RAM, therefore entering sleep and restoring very quickly, but in case of total battery drain the session is lost as the machine shuts down by power failure.

In Hibernation, the session data active in RAM is saved on the HDD (I think swap partition is needed for this) and then the machine shuts down completely. When the Linux system is started up again the session is restored from disk with all the open programs. (In case of multi boot, one may chose to use other systems like Windows before going back to the Linux, with no impact on the effectiveness of the hibernation procedure.)

I know that Hybrid-Sleep is an intermediary operation; it doesn't shut down the machine (you cannot for example go to Windows in multi-boot) and the RAM is refreshed (like in "Sleep/Suspend to RAM") while data is also saved to the swap space of the HDD.

In case of total battery drain when the machine shuts down completely: what happens with the hybrid-sleep state? I think the RAM data is lost, but is the HDD backup restored when the Linux system is started again?

Best Answer

As I was expecting a quick answer which didn't came, I have subjected an older laptop to a rough test intended to provide the answer:

I have opened a text document, written something and, without saving the document, entered hybrid sleep with the command systemctl hybrid-sleep. At this point the LED beside the power button was blinking, like in Sleep mode. As the laptop cable was disconnected, I have also removed the battery. At this point the machine was fully shut down, the LED was dead. Putting the battery back and starting the machine from the power button, my multi-boot list became available (Windows etc.), and when booting Linux it all went just like in the case of hibernation (message with booting from dev/disk/...), my open unsaved document was available.

So, the answer is YES.

Hybrid Sleep is not an intermediary state between Suspension/backup to RAM ("Sleep") and that to disk ("Hibernation"), but a double operation; it simply does both.

It ensures all that is needed for the Hibernation procedure to work, but it doesn't shut down the machine; instead, it suspends it to RAM (Sleep mode). As long as power is not completely drained, only the 'Sleep/Suspend to RAM' capability is visible. In case of total power drain, the Hibernation capability is used: the machine is shut down but is able to restore all programs from swap upon startup.


It is important to know that in the case of Hibernation/Hybrid-Sleep, the boot/startup procedure should not be interrupted (by the power button or power failure) or the programs' session&data saved on swap-partition (by the 'hibernation' action) will be lost.

Related Question