Hibernation on Linux Explained
November 13 2024 9:13pmWhat Is Hibernate on Linux?
Hibernate is a power-saving state where the contents of the system's memory (RAM) are written to a designated (NVMe for example) storage space and the system powers down.
When the system is turned back on, the memory contents are read back into RAM, restoring the system to its previous state.
Hibernate is particularly useful for laptops as it saves battery while preserving your session, including open applications, unsaved work, and system state.
Note: While suspend (s2idle to ram) is officially supported on most Linux systems, hibernate is provided "as is" and may require manual configuration.
How Does Hibernate Work?
State Saving:
- The kernel writes the entire content of RAM to a swap partition or file.
- This includes application states, memory allocations, and other runtime data.
Power Down:
- Once the memory is stored, the system shuts down completely, using no power.
State Restoration:
- On the next boot, the bootloader and kernel detect the hibernation image in the swap space.
- The kernel restores the memory contents from the swap space back into RAM, resuming the system exactly as it was before hibernation.
Security considerations:
- Secure boot will need to be turned off with some distributions that lack the needed kernel signing.
- When using a swap partition, we recommend using LUKS encryption as explained in guides.
- Fedora (unofficial guide) is available here for the application approach and the manual method.