How to Enable Hibernate Function in Ubuntu 22.04 LTS

Last updated: November 22, 2023 — 66 Comments

Computer hibernate does not work in your Ubuntu? Here’s step by step complete guide shows how to enable this feature.

Similar to suspend, hibernate can be used to save your system work. It moves the content from RAM memory into swap area in hard disk, then shutdown your machine completely. Next time you boot the computer, it restores the system status exactly as it was.

NOTE:This tutorial now is tested and works on my Ubuntu 22.04 Laptop with default GNOME. It may NOT work if you’ve used Grub-Customizer to edit the boot-menu!! For other desktop environments, you need to replace gedit in following commands with your favorite text editor, or use the universal nano command line editor.

Check if hibernate works:

Hibernate does not work in my laptop since Ubuntu 20.04 (maybe, can’t remember it), though it works in Debian 11 bullseye.

NOTE: The command below won’t work for secure boot!! You have to disable it in BIOS/EFI for using hibernate. With secure boot, you’ll get error:

“Failed to hibernate system via logind: Sleep verb “hibernate” not supported”.

To verify if the functions works, open terminal (Ctrl+Alt+T) and run command:

systemctl hibernate

Save you work before running the command!! Then type user password when it asks.

The command will turn off your computer/laptop. Next boot the machine again, and see if it restore your system status after login.

Enable Hibernate on Swap Partition:

So it does not work and just log into blank desktop? Try enable this feature via following steps.

Check Swap Area:

The swap area is used when the memory is getting full. It can also be used to save your system status via hibernate.

Open terminal (Ctrl+Alt+T) and run command tell the swap area:

swapon --show

If it outputs “/dev/sdax partition …” (or /dev/nvmex) continue this step. Or if it says no swap or a file, go next step: ‘Enable Hibernate on Swap File

Find swap area UUID

In my case the swap is a partition: “/dev/sda4”. Now find the UUID (universally unique identifier) for the area by running command:

cat /etc/fstab |grep swap

Copy the UUID for /dev/sda4 in my case. It will be used in next step.

Resume from swap via Kernel parameter

By adding a Kernel parameter into boot menu entry enables the hibernate in my case in both HP and ASUS laptops.

To do so, run command in terminal to open the config file:

sudo gedit /etc/default/grub

When it opens, add resume=UUID=xxxx (replace xxxx with the id you copied in previous step) as value of “GRUB_CMDLINE_LINUX_DEFAULT”.

Save the file and update the Grub via command:

sudo update-grub

Finally reboot your computer, open a few app windows, and run systemctl hibernate command to test if it works now!

Enable Hibernate on Swap File:

This step is only for those who don’t have a swap partition, since a swap file can also be used for hibernation.

Create Swap File:

To create a file for swap if you don’t have it, run following commands one by one:

a.) Pre-allocate a disk place for a file via command:

sudo dd if=/dev/zero of=/swapfile count=8192 bs=1MiB

Replace 8192 MB (8G) to your desired size. As large as RAM is recommended for swap.

b.) Change the file permission to only read & write for root:

sudo chmod 600 /swapfile

c.) Set the file as swap area:

sudo mkswap /swapfile

d.) Finally enable it by running command:

sudo swapon /swapfile

e.) And write it into ‘/etc/fstab’, so Ubuntu will mount it automatically on startup.

echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

Find the UUID & Offset:

Since the file is created on Ubuntu file-system. It can be located via root UUID as well as physical offset.

To see your Ubuntu partition, run command and find the one mounted on ‘/‘:

df -h

Then find its UUID via command:


In my case, it’s ‘/dev/sda3’ and UUID is marked underline.

To find the physical offset for /swapfile, run command:

sudo filefrag -v /swapfile

Copy the start number under physical_offset. It’s 1134592 in my case.

Resume on Swap file via Kernel parameter:

Finally edit the Grub configuration file (or use Grub-Customizer) via command:

sudo gedit /etc/default/grub

Then add resume=UUID=xxx resume_offset=xxx as value of “GRUB_CMDLINE_LINUX_DEFAULT”. Also replace ‘xxx’ with the id and/or offset value.

And update grub to apply change via command:

sudo update-grub

Regenerate initramfs:

Hibernate now works in my case after reboot. If not working for you, try regenerating initramfs via a new rule.

Firstly, open terminal (Ctrl+Alt+T) and run command to create a config file:

sudo gedit /etc/initramfs-tools/conf.d/resume

Then paste the line “RESUME=UUID=xxx resume_offset=xxx” (replace xxx with correct id) and save it.

After saving the file, regenerate initramfs via command:

sudo update-initramfs -c -k all

Finally reboot and test hibernate function again.

Enable Hibernate option in Power-Off Menu:

After enabled the function, you can now add a menu option into the system tray shutdown menu.

1.) Firstly, open terminal (Ctrl+Alt+T) and run command to create & edit a config file:

sudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla

When the file opens, paste following lines and save it.

[Re-enable hibernate by default in upower]

[Re-enable hibernate by default in logind]

For non-Gnome desktop, e.g., XUbuntu and Ubuntu MATE, there should be a hibernate option after log-out and back in.

2.) Enable Hibernate option in system menu for the default GNOME Desktop.

For default GNOME desktop, go to the link button below and install the extension for the menu option:

For those first time installing Gnome extension, you need to run command to install “chrome-gnome-shell” package first:

sudo apt install chrome-gnome-shell

And click the “click here to install browser extension” link in the extension page and refresh the page if you don’t see the toggle icon.

Or, search for and install “Extension Manager” from Ubuntu Software, and use the tool to search and install that extension:


If everything goes well after this tutorial, you can get more, including hibernate when lid is closed, and automatic hibernate on system idle.


I'm a freelance blogger who started using Ubuntu in 2007 and wishes to share my experiences and some useful tips with Ubuntu beginners and lovers. Please comment to let me know if the tutorial is outdated! And, notify me if you find any typo/grammar/language mistakes. English is not my native language. Contact me via [email protected] Buy me a coffee:

66 responses to How to Enable Hibernate Function in Ubuntu 22.04 LTS

  1. Marcos Oliveira August 27, 2021 at 3:14 pm

    Very nice!

  2. Thank you SO MUCH for this tutorial. I have been trying to get my laptop to hibernate for years but was never able to do so. I finally made it thanks to you. You are awesome!

  3. Fantastic and clear explanation. Worked perfectly on my Lenovo X230 running Ubuntu 21.10

  4. Excellent, clear and accurate step-by-step instructions, thank you very much. I just enabled hibernation on my laptop and it works great.

  5. Thanks, i appreciate

  6. Juan Julio Corica March 24, 2022 at 11:05 pm

    Excellent! Thanks for your detailed tutorial. It works perfectly.

  7. Works like a charm !!! Thank you so much 🙏

  8. Olubodun Agbalaya May 21, 2022 at 1:37 pm

    Bravo very brilliantly explained thank you.
    I guess its normal to expect slower resumption from a swapfile than a swap partition,but really glad to be able to hibernate

  9. Sadly, it doesn’t work for me (fresh Ubuntu 22.04 budgie on thinkpad t14s).

    I had a swap partition (per default, I did not configure anything during installation), but this is only about 1 GB in size. Thus I created a dedicated swapfile
    cat /etc/fstab |grep swap
    # /dev/mapper/vgubuntu–budgie-swap_1 none swap sw 0 0
    /swapfile none swap sw 0 0

    which is also registered

    swapon –show
    /swapfile file 32G 0B -2

    I tried adding it directly to grub and initramfs with its own UUID
    sudo swaplabel /swapfile
    UUID: e8034255-1bf5-4101-8430-30decbb92b19

    and with the method described here via UUID of the partition it is saved on and the offset found via filefrag -v. Both does not work. It only slows down my boot now with the message “Gave up waiting for suspend/resume device”.

    I’m a bit at a loss here now. Secure boot is disabled. Any directions appreciated.

    • The UUID you got via “sudo swaplabel /swapfile” command won’t work (at least it does not work in my case).

      But the UUID of the Ubuntu system partition, plus physical offset works. So, the Kernel parameter should be:

      resume=UUID=the-system-partition’s-uuid resume_offset=physical-offset-id

      It works in my HP laptop with 22.04 LTS right now, though it didn’t when Ubuntu 22.04 was in Beta.

      • Hey, thanks for the quick reply. I tried both. Now back on the UUID of the system partition plus physical offset. But it’s still not working. I’ve found one spot where a problem might be:
        W: initramfs-tools configuration sets RESUME=UUID=2fe750fa-2d0e-414c-8249-39c09d3a336d
        W: but no matching swap device is available.

        initramfs can’t find the swapfile. I have no idea at the moment how to fix that but it’s my best guess that this is the problem.

  10. The hybernation does not work for me as well. I get the following erorr when running “sudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla” despite the lines have been added to the file.

    (gedit:3498): dconf-WARNING **: 16:29:11.144: failed to commit changes to dconf: Failed to execute child process “dbus-launch” (No such file or directory)

    I can confirm the swap is created and no other erorrs

    • Try installing the “dbus-x11” package via command:

      sudo apt install dbus-x11
      • thanks for your swift replay, the “dbus-x11” package didn’t sort out the hybernation.
        Failed to hibernate system via logind: Sleep verb “hibernate” not supported

        • I’ve mentioned that you have to disable “Secure Boot” to be able to use the feature. That could be one of the reasons that Ubuntu does not enable this function out-of-box.

          To verify if Secure Boot enabled in your machine, run command in terminal:

          mokutil --sb-state
          • Gabriel Rossato August 15, 2022 at 11:27 pm

            Hello my friend, “systemctl hibernate” command is hibernating perfectly. But I can’t enable the sleep button at all.

            I already installed “sudo apt install dbus-x11” and the command “mokutil –sb-state” returns: SecureBoot disabled

            What the master thinks my Ubuntu 22.04LTS can be in Portuguese/BR

          • Do not recommend anyone disabling secure boot on their laptops. Even on desktop it is questionable.

          • That’s one of the reasons why Ubuntu Linux does not have hibernate function out-of-the-box.

  11. followed your steps and it worked 100%
    Now i got a wroking Hibernate option in my power menu.
    thanks a million.

  12. Indeed the secure boot was enabled, hibernation works fine now.
    many thanks, I appreciate your guidance.

  13. Thanks for this tutorial because I managed to hibernate my Beelink GT-R Mini PC with Ubuntu 22.04 Desktop. Keep it up!

  14. I’ve upgraded from 20.04 to 22.04 and the hibernation gone. I’ve done all the steps including extras like dbus and hibernation only locks the screen nothing more. Yes, the secureBoot is disabled. Any ideas to solve the issue?

  15. I’ve been a linux user for decades and this may be the first time I’ve had “hibernate” actually work after following theses instructions with only slight modifications based on my personal system. Thank you!

  16. Thanks for the post.
    Working on Kubuntu 22.04

  17. Worked well after disabling the secure boot as it says.

  18. I was wondering if you’ve tried this on an encrypted drive? I encrypted my system following this tutorial, but with the following differences:

    1) I did not create a swap partition. Instead I created a swap file after installation according to your tutorial.
    2) I created two partitions inside the encrypted partition, one for my root directory / and one for my home directory /home.

    I am uncertain how to go about getting hibernation to work in this particular case. I can confirm your tutorial for hibernation using swap file does not work as is. Do you have a suggestion how the procedure needs to be modified to get it to work properly?

    created two partitions for my root (/) and home (/home) directories within a LUKS encrypted partition
    I am unable to set up hibernation w

  19. Using Ubuntu 22.04.1 on Thinkpad X1 Carbon Gen 9 with LUKS encrypted LVM and 40 GiB swapfile for 32 GiB RAM. Followed this guide, but cannot get hibernate working.

    userx@x1:~$ sudo filefrag -v /swapfile | head -5
    Filesystem type is: ef53
    File size of /swapfile is 42949672960 (10485760 blocks of 4096 bytes)
    ext: logical_offset: physical_offset: length: expected: flags:
    0: 0.. 2047: 12746752.. 12748799: 2048:
    1: 2048.. 4095: 213837824.. 213839871: 2048: 12748800:

    userx@x1:~$ sudo blkid
    /dev/mapper/nvme0n1p3_crypt: UUID=”…” TYPE=”LVM2_member”
    /dev/mapper/vgubuntu-root: UUID=”87d2097a-7613-42c3-85c1-d18952e4c1a1″ BLOCK_SIZE=”4096″ TYPE=”ext4″

    Line from /etc/default/grub:
    GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash resume=UUID=87d2097a-7613-42c3-85c1-d18952e4c1a1 resume_offset=12746752″

    userx@x1:~$ cat /etc/initramfs-tools/conf.d/resume
    RESUME=UUID=87d2097a-7613-42c3-85c1-d18952e4c1a1 resume_offset=12746752

    Also getting the initramfs warnings mentioned above:
    W: initramfs-tools configuration sets RESUME=UUID=87d2097a-7613-42c3-85c1-d18952e4c1a1
    W: but no matching swap device is available.

    Any idea what may be the problem here?

  20. Worked well.
    Thought in step Enable Hibernate option in Power-Off Menu / 2
    I needed another extension manager for Firefox. But it was suggested by the software center automatically.

  21. Gerhard Lehnhoff October 14, 2022 at 11:12 am

    Does not work. Disk is full, is the message. My Swap file is 2GB, but my RAM 32GB. I probably have to increase Swap file, but how?

    • Try disable the swap file via:

      sudo swapon /swapfile

      Then delete the file:

      sudo rm /swapfile

      If you don’t want to re-create the swap file again, also remove “/swapfile none swap sw 0 0” from /etc/fstab file.

    • Gerhard Lehnhoff October 17, 2022 at 3:48 pm

      systemctl hibernate works now after I managed to increase my LVM SWAP partition. Thanks a lot.

  22. Thanks a lot.
    This tutorial worked for me.

  23. I have a machine with 8G and according to swapon -s:
    /swapfile file 8388604 0 -2

    Yet, when I run update-initramfs -c -k all I get
    W: initramfs-tools configuration sets RESUME=UUID=resume=UUID=6b2ce25b-bc09-41fa-894f-70f9655fab24
    W: but no matching swap device is available.

    I should add that findmnt -no UUID -T /swapfile generates

    So, it seems that the device should be found.

    My swap is NOT encrypted, per the swapon, see above.

    So, why is initramfs not finding it? What am I missing/doing wrong

  24. iconoclast hero November 4, 2022 at 3:05 pm

    Thanks. Been meaning to look into this for a while.

  25. I have followed all the steps and its not showing hibernate option in Power Menu even after Restart. Please reply.

    • Please try out if the hibernate function works by running systemctl hibernate command in terminal. And tell your Ubuntu edition, desktop environment, and if possible what’s error you got.

      You can search for and install “Extension Manager” from Ubuntu software, and use it to see if the extension is probably installed and enabled.

  26. It’s my first time with Ubuntu and that was really very helpful. Thank you so much.

  27. Marcos Scalabrin December 22, 2022 at 7:30 am

    Great! Worked fine on lenovo!

  28. Thank you so much guys I’ve been searching for a while in you save me thank u very much

  29. Excellent article, works like a dream. However it’s about time this option was included in Ubuntu as standard.

  30. Is there a way to avoid having to ask for password every time I want to hibernate?

  31. Well part of it has worked!
    It hibernates from the command line.
    It also hibernates from the menu.
    But in both cases when it is restarted, it shows the message “Resuming from hibernation”
    then sadly it just carries on the normal boot, to system screen with no application running.
    So I have question re Modify Grub:
    The UUID= does this go in quotes ie UUID=”168xxyt4684846″ and also the offset address? ie resume_offset=”12345679987″
    In your example you have quote symbol only at the end of the offset address!

    Otherwise thanks for a step by step which has half worked.
    I need to know where to find the log which shows what error then maybe we can find the problem. I have looked in var/log/ but can not find the correct log!

    I am running 22.04.1 LTS with Gnome 42.5 on with X11 on an ancient Clevo laptop CLEVO CO. W240EU/W250EUQ/W270EUQ. (The bios is now being awkward and taking many attempts to boot, but I do no think it is the problem. (Many hundreds of years before secureBoot was invented)

  32. Now it works!!
    Many thanks to Ji m !!
    I had a problem with quote marks in the addition to the /etc/default/grub file.
    But it needs to be exactly as per the photo on the page, with a closing quote ONLY at the end of the resume_offset=address”

    Now I have to fix my dodgy bios!

  33. Hi, I’m able to observer that ubuntu often getting crash and throwing bulk_update_rename, I/o error. error while writing superblocks in complete black screen. kinds of error. And this is happenning once i resumed from hibernate and spend few minutes to few hours in ubuntu. Also i can notice that some memories were occupies on swap memory once resumed after hibernate. and ubuntu using completely ram memory before i’m putting ubuntu into hibernate. Also mentioning that i’m running with sufficient ram memory in my system using swap to make the system into hibernate. Could anyone help on this

  34. Thiago Marques Silva February 18, 2023 at 2:02 pm

    Great! Worked fine on Dell Inspiron 7460!

  35. It works! great! Thank you very much!
    Just one little addition, I think you need to reboot in order to get the Hibernate option in Power-Off Menu visible.

  36. Thank you very much!!!

  37. Hello! Thanks for your awesome tutorial. Can you please tell me how may I configure Ubuntu to hibernate in case of critical battery percentage?

    • Edit the “/etc/UPower/UPower.conf” file, and change the last line from:




      Save file and apply via systemctl restart upower command. See more here.

  38. Ji m, hello and thz.
    Ubuntu 23.04
    If i run “sudo systemctl hibernate” all work,
    but if i press button “Hibernate” in menu after start black screen.
    Helps only reboot.
    You could help?

  39. After some cut and paste incl. gnome extension it worked!

  40. Hi, Thanks for the explanation. From the responses I understand it should work like a charm, however, I keep running into the error: `Failed to hibernate system via logind: Not enough swap space for hibernation`; even if I make the swapfile 4GB larger than my actual RAM, which is 16GB.
    Do you have any suggestions?
    BTW I found this thread which suggests to bypass the memory size check but I don’t know how to set this, or if this is even save.

  41. Hi there, I have followed these directions in detail and I am having an issue where Hibernate works MOST of the time, but sometimes it does not. About 10-20% of the time, it boots up as if it was shut down completely. The rest of the time, my state is saved properly. Any ideas on this?

  42. Thank you so much. I’ve tried this on two laptops, one of them with Ubuntu 22.04 and the other one with Ubuntu 24.03. Both working perfectly fine.

  43. thank’s for this post, that is actually very help full for me because i before the come at this blog i seartch the how to enable hibernate on ubuntu, in the youtube but there i dont get the proper solution, but here i got the proper solution again thanks for this help.

  44. It should be enahled by default, or by means of a simple click.
    Hibernate works in all modern computers I’ve tried

  45. Hundreds… thousands of answers on the internet and this one was the ONLY that worked for me, beautifully exaplined. Thank you so much kind sir!!

  46. Thanks for well written write up.

    A couple of items which I noticed would have helped.

    1. A test for SecureBoot

    $ sudo mokutil –sb-state​
    SecureBoot disabled

    Also probably should mention the risk about this, there is a reason for enabling SecureBoot!

    2. If /swapfile is in use, which is the LTS default install iirc (but too small)

    $ sudo swapoff -a

    is needed before resizing, and the fstab probably will not need editing.

    3. I think I prefer the dconf editor approach.

  47. I followed the steps here however my problem is after going into hibernate, when i restart the computer the Ubuntu boot screen appears and then as it tries to boot into the system the display goes blank but the numlock key is working, indicating that the system is not frozen just that nothing is loading.

  48. physical_offset only shows two ???

    ~ sudo filefrag -v /swapfile [24/04/3| 8:25PM]
    Filesystem type is: 58465342
    File size of /swapfile is 8589934592 (2097152 blocks of 4096 bytes)
    ext: logical_offset: physical_offset: length: expected: flags:
    0: 0.. 0: 24.. 24: 1:
    1: 1.. 522127: 25.. 522151: 522127: unwritten
    2: 522128.. 926739: 46085179.. 46489790: 404612: 522152: unwritten

  49. Thx for the brilliant guide – on small addition:
    On Ubuntu 23.10 you need to sudo apt install polkitd-pkla to be able to create the .pkla file.


Leave a Reply

Text formatting is available via select HTML.

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>