Hibernation in GNU Linux: A complete and practical guide

Last update: January 14, 2026
  • Hibernation in GNU/Linux saves the entire state of RAM to swap and shuts down the computer, while suspend keeps memory in RAM with low power consumption.
  • For hibernation to work reliably, kernel support and sufficient swap space are required, either a swap partition or a well-configured swapfile.
  • Various tools (systemd, pm-utils, uswsusp and PolicyKit) allow you to enable, control or disable hibernation and suspension depending on the distribution and usage scenario.
  • Choosing between suspend, hibernate, or restart with session restore depends on the balance you seek between energy savings, speed of return to work, and system stability.

Hibernation in GNU/Linux

La hibernation in GNU/Linux It remains one of those features everyone has heard of, but that isn't always well understood or configured correctly. Many users come here after experiencing problems with Windows or laptops that shut down unexpectedly and want to know exactly what each power mode does and how to control it in their Linux distribution.

In the latest kernel versions and major distributions, things have improved considerably, but they still exist. Important nuances between hibernating, suspending, and shutting down with reopening documentsIn addition to technical details such as the use of swap space (in partitions or files), which are important to understand, we'll break all this down calmly, but in a clear and practical way.

Hibernation, suspension, and restart with session restoration: how they differ

Before touching anything in the settings, it's key to understand what each energy-saving mode actually doesBecause concepts are often mixed up, and then come the scares with lost data or empty batteries.

When we talk about hibernation in operating systems, we are referring to a process by which the entire state of the system is frozenOpen programs, documents, services, desktop settings, buffers, etc. All that content from RAM is saved to a persistent storage medium (usually disk swap) and the machine is completely shut down.

This implies that Hibernation is not the same as simply leaving files open. It's not the same as shutting down the computer, nor is it the same as suspending it. It's slower than suspending to RAM, but it saves much more energy because the computer is completely off, with no power consumption.

On the other hand, some systems offer something similar to a "reboot with document reopening," where the system shuts down normally, but upon restarting Applications that were open are automatically relaunched.In GNU/Linux many distributions mimic this desktop environment behavior, but this is not hibernation: it is still a cold boot with all services started from scratch.

The advantage of hibernation over that restart with app restoration is that The kernel and user space do not reboot from scratch.Instead, a complete image of the previous state is restored. Therefore, when everything is working correctly, you can resume your work exactly where you left off, without reopening documents or reconfiguring windows.

Power modes in GNU Linux

What is suspension in Linux and why is it worth using?

In sleep mode, the operating system generates a vivid picture of the current state (your programs, your documents, the desktop) but, instead of writing it to disk, it leaves it in RAM, which is volatile.

When the kernel suspends, it powers down virtually all hardware devices: disk, screen, most of the chipset… The only component that remains powered is the RAM and the minimum motherboard specifications so that it can "wake up" when you press a key, move the mouse, or open the laptop lid.

This mode is great when you want an almost instantaneous return to the desktop And you're not so worried about energy consumption while the computer is idle. A modern laptop can stay in sleep mode for one to three days on battery power, but during that time it's still consuming some energy to keep the RAM running.

Standard suspension is especially recommended if you have more than 2 GB of RAM and little disk space (for example, on small SSDs) or if you're going to use the computer again very soon. This is typical in the case of closing the lid for a few minutes between classes or stopping for lunch.

Hybrid suspension: a mix of RAM and disk

There is a third, less well-known way: the hybrid suspensionIn this case, the system goes through the entire hibernation process (it dumps the contents of memory to the disk, usually to swap) but, instead of shutting down completely, it enters a suspended state in RAM.

  Contpaq: Features and advantages

This creates a mixed scenario: if the battery holds up, You'll raise the system as quickly as a normal suspension.However, if the power runs out, the image saved on disk will allow the session to be restored as if it had been hibernated.

The flip side of this is that It takes longer to enter and exit. It's more than a pure suspend because it writes to disk and also keeps the RAM powered. That's why it's often used on servers or workstations that need an extra level of security against state loss.

How hibernation works internally in GNU/Linux

When you hibernate a GNU/Linux system, the kernel executes a series of fairly well-defined steps to capture and restore the complete state of the machineIt's not simply a matter of "saving the RAM to a file" and that's it.

The typical process of suspension to disc (suspend-to-disk) This general sequence follows:

  • User processes are stopped to freeze its state and prevent it from continuing to modify memory while the capture is being made.
  • Hardware devices are frozen or stopped to prevent memory changes associated with controllers and DMA.
  • The image of hibernation is created: The entire contents of RAM are copied with interruptions disabled.
  • The hardware devices are reactivated in a controlled manner.
  • The image is written in the swap space, which is then considered a suspension area (swsusp or linux-suspend).
  • Finally, all devices are suspended and the computer is completely powered off.

Upon restarting, the starting system Check if there is a valid hibernation image:

  • If there is one, It doesn't start normally.but reads the image from the swap.
  • The devices are frozen again to prevent interference.
  • The image is copied from swap to RAM and reactivate processes and devices as they were before hibernating.

One curious detail observed in real-world tests: after hibernation, the old "linux-swap partition" appears labeled as linux-suspend or swsusp in tools like GParted or parted. This change of type is one of the clues the system uses to know whether to restore from hibernation or start from scratch.

The importance of swapping during hibernation

This entire mechanism involves one key requirement: to hibernate in Linux You need a suitable swap spaceboth in size and configuration. Without swap, the system will have nowhere to store the RAM image.

The swap can be:

  • An dedicated partition with system type linux-swap.
  • Un swap file located in a normal file system (for example, in /swapfile).

For practical purposes, the kernel treats both as swap space transparently. However, to use a swapfile as hibernation destination You need to tell the kernel, through the boot manager, parameters such as resume= (device) and resume_offset= (displacement within the file). If this is not done, the system will boot from scratch and will not restore the image, even if it is written to disk.

Regarding size, the classic recommendation for reliable hibernation is that the swap should have at least the size of the physical RAMIt's true that if the system is heavily underutilized, you can sometimes hibernate with a slightly smaller swap space, but it's not a sure thing and shouldn't be generalized. On systems with 32 GB or 64 GB of RAM or more, many administrators advise against hibernation altogether due to time and storage limitations.

It is also worth remembering that there are mechanisms such as zram or zswapwhich create a compressed swap area within RAM itself. They are fantastic for improving performance on systems with limited memory, but they are not suitable as a hibernation destination: being volatile, The image would disappear when the power was cut off..

Hibernation on swap partition vs. swapfile

For years it was considered almost mandatory to have a dedicated swap partition If you wanted to hibernate without complications, the behavior of the kernel and tools like initramfs was very much based on that classic model.

However, many modern distributions, such as Ubuntu in recent versions, have switched to using it by default. a swapfile instead of a partitionThis does not mean that the ability to hibernate is lost, it simply changes where the state is saved.

  Linux Distributions: A Complete Guide

In both cases, the underlying process is the same: The image from RAM goes to a persistent swap spaceThe difference is that, with a swapfile, the system needs to know the exact block on the disk where the file starts (hence the parameter). resume_offset) to be able to read the image early during startup.

Practical experiments on Debian and derivative machines have shown that, if The swap partition is formatted or deleted Where the hibernation image was stored, the next boot will be clean, as if hibernation had never occurred. This confirms that the image is indeed saved in swap space and not elsewhere on the disk.

Kernel requirements and support in distributions

In addition to the exchange space, it is necessary that the Linux kernel has hibernation support enabledIf you compile your own kernel and disable this option, no matter how much you tweak the distro's configuration, you won't be able to hibernate.

In practice, most distributions use the kernel packaged by the project itself, and in those cases Hibernation is usually enabled by default. along with the rest of the usual power management functions and drivers.

However, not all distributions always display the "Hibernate" button in their graphical menus. Some, like Ubuntu in certain versions, They hide the option on the desktop by default. even though the kernel and hibernation infrastructure are fully operational.

How to enable hibernation in Ubuntu using PolicyKit

On Ubuntu systems where the hibernation option does not appear in the shutdown menu, you can to rehabilitate in a relatively simple way By modifying some PolicyKit rules, the idea is to authorize regular users to invoke the hibernation actions of upower and logind.

The typical procedure involves creating a configuration file, for example com.ubuntu.enable-hibernate.pklawith content similar to this (adapted to the syntax used by your tools):


Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes


Identity=unix-user:*
Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions
ResultActive=yes

Once the file has been created, it must be placed in /etc/polkit-1/localauthority/50-local.d/To do this, you can open your file manager as administrator (for example with gksudo nautilus in environments that still support it) and paste it into that directory.

After restarting the system, the Ubuntu desktop will show the hibernation option Along with the shutdown, restart, or suspend functions. Obviously, a sufficiently large swap space and a kernel with hibernation support are still required.

GNU Linux hibernation configuration

Hibernation and suspend commands from the terminal

If you prefer the terminal or use lightweight environments (Fluxbox, IceWM, Openbox, JWM, etc.) where there are no pre-configured power buttons, you can control hibernation and suspension directly with commands.

Using pm-utils

In many classic Debian/Ubuntu distributions, the package pm-utils It provides several simple commands:

  • pm-suspendThis suspends the machine to RAM. Most devices are powered off, and the state is maintained in memory. Power consumption is significantly reduced, but energy is still being used.
  • pm-hibernate: hibernates the system by saving RAM to disk (swap) and completely shutting down the computer.
  • pm-suspend-hybridIt performs hibernation on the disk and, instead of shutting down, puts RAM into sleep mode, thus achieving a "hybrid sleep".

The basic usage would be:

sudo pm-suspend
sudo pm-hibernate
sudo pm-suspend-hybrid

On Arch Linux-derived systems and others that maintain it in their repositories, you can also use these commands, although pm-utils has been abandoned in favor of systemd in many modern distributions.

Using systemd (systemctl)

In distributions with systemd (OpenSUSE, many versions of Arch and derivatives, modern Debian, etc.), the recommended way is to use systemctl:

  • systemctl suspend: suspends RAM.
  • systemctl hibernate: hibernates to disk.
  • systemctl hybrid-sleep: activates hybrid suspension.

For example, in OpenSUSE or any typical systemd system, you can directly call:

sudo systemctl hibernate

In many distributions, if you prefer to maintain compatibility with older tools, pm-hibernate It remains available and simply delegates or coexists with systemd depending on the configuration.

Using uswsusp: s2ram, s2disk and s2both

Another family of tools, less common nowadays, is uswsuspwhich provides the commands s2ram, s2disk, and s2both. It was available in Debian and Ubuntu up to certain versions (Debian 10; Ubuntu 20.04 and later have deprecated it).

  • s2ram: suspends the system to RAM (S3 mode). It is equivalent to pm-suspend or systemctl suspend.
  • s2disk: saves the complete state to disk and shuts down the machine (classic hibernation).
  • s2both: combines both things: writes the image to disk and then suspends to RAM, achieving hybrid behavior.
  How to partition a 1TB disk in Windows step by step

The commands would be:

sudo s2ram
sudo s2disk
sudo s2both

These utilities require proper initramfs configuration so that, upon startup, the resumption mechanism is called (resume) and restore the image if it exists.

How to disable sleep and hibernation on GNU/Linux systems

In some environments, such as classrooms, shared computers, or public workstations, suspend and hibernate can cause unexpected shutdowns, network problems, or blockages that are difficult to explain to usersIn those cases, sometimes the most practical thing to do is to disable these functions completely.

Disable using systemd (target mask)

If your system uses systemd, just mask the targets related to sleep and hibernation so that they cannot be activated from either graphical menus or the terminal:

sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target

This redirects those targets to / Dev / nullIn other words, it symbolically sends them "to the trash." After a reboot, any attempt to suspend or hibernate will fail cleanly.

If you later want to restore normal behavior, you will only need to use:

sudo systemctl unmask sleep.target suspend.target hibernate.target hybrid-sleep.target

Disable hibernation and suspend buttons with PolicyKit

Another, finer option is to use PolicyKit to remove suspend/hibernation permissions to all users. For example, you can create files in /etc/polkit-1/localauthority/90-mandatory.d/ on the table:

/etc/polkit-1/localauthority/90-mandatory.d/disable-suspend.pkla


Identity=unix-user:*
Action=org.freedesktop.upower.suspend
ResultActive = no
ResultInactive=no
ResultAny=no


Identity=unix-user:*
Action=org.freedesktop.login1.suspend
ResultActive = no


Identity=unix-user:*
Action=org.freedesktop.login1.suspend-multiple-sessions
ResultActive = no

And for the hibernation:

/etc/polkit-1/localauthority/90-mandatory.d/disable-hibernate.pkla


Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive = no
ResultInactive=no
ResultAny=no


Identity=unix-user:*
Action=org.freedesktop.login1.hibernate
ResultActive = no


Identity=unix-user:*
Action=org.freedesktop.login1.hibernate-multiple-sessions
ResultActive = no

After restarting, the suspend and hibernate buttons will disappear from the graphical menus. preventing the user from activating them unintentionally.

Block keyboard shortcuts and direct commands

Even if you hide the buttons, some desktops and keyboards still have them. special sleep/hibernation keys which can continue to function. In older environments with classic GNOME, this could be adjusted with commands like:

gconftool -s /apps/gnome-power-manager/buttons/hibernate -t ​​string interactive

Additionally, you can create scripts in /etc/pm/sleep.d/as the /etc/pm/sleep.d/000cancel-hibernate-suspendwhich simply Cancel any attempt at suspension or hibernation returning control to the system. A typical skeleton would be:

#! / Bin / sh
# prevents hibernation and suspend
. «$PM_FUNCTIONS»
case «${1}» in
suspend|hibernate)
inhibits
;;
resume|thaw)
exit 0
;;
esac

Don't forget to give it execute permissions:

chmod 0755 /etc/pm/sleep.d/000cancel-hibernate-suspend

When is it appropriate to hibernate and when is it not?

With all this theory on the table, the practical part remains: When is it really worthwhile to hibernate in GNU/Linux? There is no single answer, but there are some reasonable guidelines.

If your top priority is save energy (For example, on a laptop that you leave unused for many hours) and you have plenty of disk space for the memory image, hibernation is a very attractive option; you can read how to choose between Turn off, suspend, or hibernate your PCEnergy consumption in hibernation state is zero, and when you return you start up much faster than from a cold start.

If what you want is pure speed when returning to the desktop and you're going to leave the computer idle. just a short whileSuspending to RAM might be more convenient. The machine will still use some battery power, but resuming will be almost instantaneous.

On systems with a lot of RAM, or where stability upon resuming is not guaranteed (certain unusual hardware, exotic drivers, etc.), it's often worth foregoing hibernation and opting for a good suspend function and a clean reboot with document restore when needed.

Ultimately, a thorough understanding of how they rely on swap, what the kernel does under the hood, and how to control them with tools like systemd, pm-utils, uswsusp, or PolicyKit allows you to treat hibernation and suspension as tools in your favorand not as mysterious functions that sometimes work and sometimes leave the laptop "stuck" without any apparent explanation.

turn off suspend or hibernate PC lifespan
Related article:
Turning off, suspending, or hibernating your PC: what's best to extend its lifespan