How to enable hibernation in Ubuntu

Last update: 03/12/2026
Author Isaac
  • Hibernation saves the session to the disk and does not depend on the battery, unlike sleep.
  • Ubuntu disables it by default due to potential hardware failures, so it's best to test it before relying on it.
  • The swap area must have sufficient space and the GRUB and initramfs configuration must point to the correct UUID.
  • Depending on the desktop environment, an extension or a Polkit tweak may be needed for the option to appear.

Modern laptop in a bright workspace displaying lines of code on the screen, ideal for representing the technical configuration of Ubuntu.

Hibernation in Ubuntu means saving your entire session to the hard drive, so that when you turn your computer back on, the programs, documents, and folders you had open are exactly as you left them. It's not the same as suspend , because suspend keeps the session in RAM and requires a power source to maintain it; hibernation, on the other hand, doesn't depend on the battery or a power cord, making it very practical for laptops and when traveling. The bad news is that Ubuntu usually disables this option by default, as it doesn't work well on some computers and can result in data loss, so it's best to test it thoroughly before relying on it.

The good news is that enabling it isn't rocket science if your hardware is up to the task. Before messing with configuration files, it's worth checking if your computer supports hibernation, reviewing the swap space, and running a manual test; if something goes wrong, it's best to fix it before proceeding. I also recommend saving any open documents during your initial tests, because it's better to be safe than sorry.

Check if the device supports hibernation

Close-up of hands typing on a laptop keyboard, symbolizing the execution of commands in the Linux terminal.

Open a terminal and run cat /sys/power/stateThe answer should include words like freeze, mem y diskFor hibernation, we are primarily interested in it being diskSome older guides were content to see memBut that value is more related to the suspension, so Don't just rely on memories If you want to hibernate. If the command doesn't show diskIt is most likely that the system does not have hibernation available as is.

Then you can do a manual test with sudo systemctl hibernateIn older systems it was also used pm-hibernate And for that, you could install sudo apt install pm-utils hibernateIf the process does not complete successfully, it could be due to a missing UEFI partition, the need for BIOS or UEFI adjustments, insufficient swap space, or simply incompatibility of the computer. It is not advisable to continue until that error is resolved.because there's no point in adding the button if the device doesn't wake up correctly.

Review the swap: size, type, and available space

The next key point is the swap area. swapon --show And look at the name and location, the type, the total and used size, and the priority, which applies when there are multiple active swap zones. The size should be equal to or greater than the RAMSome recommend doubling or even tripling it, although this is a controversial topic and depends on usage and the computer. For a computer with 4 GB of RAM and typical tasks, matching the memory is usually sufficient.

  Full tmux integration in Arch-based Omarchy

You should also check if the swap space is a file or a partition. If it appears as a file, for example a swap.img In the root directory, many modern guides accept this, but the configuration may require the UUID of the root filesystem and a resume offset. If it's a partition, the process changes slightly, and the UUID of the swap partition itself is typically used. Classical guides assumed a partition They warned that hibernation wasn't always possible with a swap file; it is possible in current systems, but don't copy a configuration designed for partitioning without checking your case.

  • Check that the swap is active and has enough space.
  • Note whether it is a file or a partition, because the UUID and steps may vary.
  • Remember the name and location of the swap so you don't get confused later.

Locate the UUID and prepare GRUB

Open the montage file with sudo nano /etc/fstab and locate the interchange area line. You can also use grep swap /etc/fstab o blkid | grep swap To copy the UUID. If your swap is a partition, the normal thing to do is use the UUID of that partition; if it's a file, many current methods use the UUID of the main file system and add an offset. Note the value carefully.because you'll need it in more than one place and a single miscopied character can ruin the resumption.

Now edit the GRUB configuration with sudo nano /etc/default/grubYou'll see a line similar to GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"You must add the resume parameter with your UUID, leaving something like GRUB_CMDLINE_LINUX_DEFAULT="quiet splash resume=UUID=31c69035-7988-42b5-a6cb-7645528c092f". Don't lose the UUID= part and the quotation marks when editing. When you're finished, save and apply the changes with sudo update-grub.

Configure initramfs and try again

Laptop screen with green code text on a black background, representing the terminal interface and configuration file editing.

It is also necessary to indicate the resumption in /etc/initramfs-tools/conf.d/resumeOpen it with sudo nano /etc/initramfs-tools/conf.d/resume and write a line like RESUME=UUID=31c69035-7988-42b5-a6cb-7645528c092f, replacing the value with the one that corresponds to your computer. Then run sudo update-initramfs -u to apply the changes. GRUB and initramfs must point to the same UUIDIf one of the two retains an old value, hibernation may fail or wake up incorrectly.

Now you can try again with sudo systemctl hibernateIf the computer shuts down, restarts, and you regain your session, you're on the right track. If not, double-check the swap space, UUID, and firmware settings before proceeding. Perform the manual test first It saves you from surprises and helps you know if the menu button will actually work.

  Creating and signing .deb packages for Linux distributions

Add Hibernate to the menu with Polkit

In modern versions, a Polkit rule is usually created in /etc/polkit-1/rules.d/10-enable-hibernate.rules with sudo nano /etc/polkit-1/rules.d/10-enable-hibernate.rulesInside, you can add a JavaScript rule that allows the hibernation actions of login1 and upower, including org.freedesktop.login1.hibernate, org.freedesktop.login1.hibernate-multiple-sessions, org.freedesktop.upower.hibernate, org.freedesktop.login1.handle-hibernate-key y org.freedesktop.login1.hibernate-ignore-inhibit. The goal is to prevent Polkit from blocking the order and that the desktop can display the option.

polkit.addRule(function(action, subject) { if (action.id == "org.freedesktop.login1.hibernate" || action.id == "org.freedesktop.login1.hibernate-multiple-sessions" || action.id == "org.freedesktop.upower.hibernate" || action.id == "org.freedesktop.login1.handle-hibernate-key" || action.id == "org.freedesktop.login1.hibernate-ignore-inhibit") { return polkit.Result.YES; }});

Older versions of Ubuntu used a different rules system with a file .pkla within /etc/polkit-1/localauthority/50-local.d/You could create com.ubuntu.enable-hibernate.pkla with sudo nano /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla and paste inside the upower and logind sections with Identity=unix-user:*, the corresponding actions and ResultActive=yes. There were also variants , the com.ubuntu.desktop.pkla, and in Kubuntu 22.04 the route has been documented /var/lib/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla with login1, handle-hibernate-key and upower actions.

[Re-enable hibernate by default in upower]\nIdentity=unix-user:*\nAction=org.freedesktop.upower.hibernate\nResultActive=yes\n[Re-enable hibernate by default in logind]\nIdentity=unix-user:*\nAction=org.freedesktop.login1.hibernate;org.freedesktop.login1.hibernate-multiple-sessions\nResultActive=yes

In older environments it was common to open the graphics editor with gksudo gedit after installing the package gksuor open Nautilus with administrator privileges using gksudo nautilus and paste the created file into the corresponding folder. Today, it's normal to use sudo and nano.Because gksu is outdated, but those steps explain why many older guides mention graphical windows and manually pasting files. After restarting, the Hibernate option should appear in the shutdown menu.

GNOME, other desktops, and the visible button

In XFCE, KDE, or MATE, after configuring Polkit, a Hibernate option usually appears in the shutdown menu. In GNOME Shell, however, you may need to install the Hibernate Status Button extension. The easiest way is to use Extension Manager : go to the Browse tab, search for the extension's name, and click Install when it appears in the results. Afterward, you can access it from the system menu, and you'll see a window similar to other shutdown options.

In Ubuntu 12.04, the Hibernate function disappeared from the regular menu and was only available in the power settings, under the option related to critical battery level. The decision to disable it by default was made because it didn't work well on many newer computers and, in the worst cases, could corrupt data by failing to wake up correctly. The Ubuntu Certified whitelist It included tested equipment; if you didn't see the button, your computer most likely wasn't on that list. If after testing pm-hibernate The computer hibernated and woke up without problems, so it made sense to restore the option.

Failures, risks and final checks

Stylish laptop on a wooden table, highlighting the portability of the device where hibernation is most useful.

Si sudo systemctl hibernate If it's not working, check that the swap space is active and large enough, that the UUID is correctly copied to GRUB and initramfs, and that there are no interfering BIOS or UEFI settings. On uncertified systems, hibernation may not be reliable, so... Do not force its use if the device does not recover the session properly.Save the documents before the first tests and, if something seems off, go back and check each step.

  Kagi announces the development of its Orion browser for Linux

Hibernation in Ubuntu can save a significant amount of time on startup and is very useful when you don't want to rely on battery power, but it requires checking support, reviewing the swap space, tweaking GRUB and initramfs, enabling the action in Polkit, and, in GNOME, installing the corresponding extension. The key is to test it first , not blindly copy UUIDs, and ensure the computer wakes up without losing any data; if everything works correctly, the option will be available in the menu and you can use it with confidence.

FAQ

How do I know if my computer can hibernate in Ubuntu?

Run cat /sys/power/state and check that disk appears; you can also try sudo systemctl hibernate and verify that it recovers the session when you turn it on.

How much swap space do I need to hibernate?

The swap space should be equal to or greater than the RAM. Some recommend doubling or tripling it depending on usage, although for common tasks, matching the RAM is usually sufficient.

Why doesn't the Hibernate option appear in Ubuntu?

It is usually disabled by Polkit and, in GNOME, requires the Hibernate Status Button extension. On other desktop environments, simply create the corresponding rule and restart.

Can I hibernate if I use a swap file instead of a partition?

It's possible on modern systems, but the configuration changes and sometimes requires specifying the root system UUID and an offset. Older guides often assume a swap partition.

What do I do if `sudo systemctl hibernate` doesn't work?

Check that the swap space is active and has sufficient size, update GRUB and initramfs with the correct UUID, and check BIOS or UEFI settings and system compatibility.

Is data lost when hibernating in Ubuntu?

Hibernation can fail on uncertified hardware and cause data loss. Save your documents before initial testing and do not use hibernation if your computer does not recover properly.

Do I need to install anything to have the Hibernate button?

In GNOME, the Hibernate Status Button extension is installed. In XFCE, KDE, or MATE, it usually appears after configuring Polkit, and in older versions, pm-utils, hibernate, or gksu might be required.

How do I configure the resume UUID?

You must copy the UUID of the swap area, or the root system UUID if you use a swap file, and add it to GRUB and /etc/initramfs-tools/conf.d/resume before updating both.

Isaac

Isaac

Passionate writer about the world of bytes and technology in general. I love sharing my knowledge through writing, and that's what I'll do on this blog, show you all the most interesting things about gadgets, software, hardware, tech trends, and more. My goal is to help you navigate the digital world in a simple and entertaining way.