How to Enable Hibernate Function in Ubuntu 24.04 & 22.04 LTS

Last updated: May 27, 2024

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

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 and Ubuntu 24.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 gnome-text-editor or gedit in following commands with your favorite text editor, or use the universal nano command line editor that works in most desktops (use Ctrl+S to save, Ctrl+X to exit).

Step 1: Check if hibernate works:

Hibernate does not work in my laptop by default 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. In some case, you may need to run sudo systemctl hibernate instead.

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

Step 2: Check the ID of Swap Area & Create if NOT exist.

So, if it does NOT restore your desktop to previous status after reboot in step 1, then you may try following this tutorial to enable this feature.

Hibernate saves data into swap area. You need to first check if you have a swap and what’s the UUID.

a.) Check Swap Area:

First, press Ctrl+Alt+T on keyboard to open terminal. When it opens, run command:

swapon --show

The command will output ‘/dev/sdaX’ or ‘/dev/nvme0n1px’ or similar device if you have a Swap volume/partition mounted. Or, it outputs a file /swap.img in my case in Ubuntu 24.04. If you don’t have any swap area, then it says no swap or a file.

b.) Create Swap File, if you don’t have Swap area:

ONLY do this step when you have neither a swap partition nor 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

c.) Find swap Name and offset

For Swap Partition. You just need to get the partition name by running command:

swapon --show

In the terminal output, just copy the partition name. It’s usually /dev/sdaX for sata, or /dev/nvme0n1px for NVME.

For Swap File. Just use the Ubuntu system partition name, plus, offset number instead.

To get the system partition name, run the command below, and check the one mounted on “/”:

df -h

Then, you need to run one more command to get the offset of the Swap file (replace ‘/swapfile’ in command according to the filename. It’s ‘/swap.img’ in my case in 24.04):

sudo filefrag -v /swapfile

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

Step 3: Enable Hibernate by adding Kernel Parameter

After step 2, you should got either UUID of Swap partition, or UUID + offset of Swap file. And, here you can use them by adding a kernel parameter in Grub boot config file.

To do so, press Ctrl+Alt+T to open terminal, and run command to edit the config file:

sudo gnome-text-editor /etc/default/grub

For Ubuntu 22.04 and earlier, replace gnome-text-editor with gedit. For non-GNOME desktop, use other text editor or nano that works for all.

For Swap partition, add resume=/dev/xxx (do replace “/dev/xxx” to yours Swap partition name) as value of “GRUB_CMDLINE_LINUX_DEFAULT”.

For Swap file, add resume=/dev/xxx resume_offset=xxx (also replace xxxx with the partition name and offset number) instead for value of “GRUB_CMDLINE_LINUX_DEFAULT”.

Finally, 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!

UPDATE for Ubuntu 24.04 with /swap.img file:

For hibernation with default /swap.img file, you may got “Call to Hibernate failed: Invalid argument” error when running the hibernate command in Ubuntu 24.04, due to this bug.

For choice, you may create and use swap partition instead, then write into /etc/fstab file, and also disable (add # at the beginning) the “/swap.img …” line.

If you insist on using the default /swap.img file, set MAJ:MIN to /sys/power/resume works for me.

1. First, open terminal (Ctrl+Alt+T) and run command lsblk to get the “MAJ:MIN” for the root permission. In my case, it’s 259:6.

2. Next, run command to set the “MAJ:MIN” value (259:6 in my case) you got to /sys/power/resume:

sudo sh -c "echo 259:6 > /sys/power/resume"

3. Finally, systemctl hibernate works even without sudo update-initramfs -c -k all.

4. /sys/power/resume will automatically reset its content to 0:0 after reboot! Thanks to @Vladimir, you may fix the issue by running command below to create & edit a config file:

sudo nano /etc/tmpfiles.d/hibernation_resume.conf

Write the lines below (replace 259:6) into it. Finally, press Ctrl+S to save and Ctrl+X to exit.

#    Path                   Mode UID  GID  Age Argument
w    /sys/power/resume       -    -    -    -   259:6

For choice, you may add one more line below (replace the value number accordingly). According to the archlinux wiki, decrease the value of /sys/power/image_size can make the suspend image as small as possible (for swap smaller than RAM, run free command to tell), and smaller values may drastically increase the speed of resuming a hibernating system.

w /sys/power/image_size - - - - 8036093952

Regenerate initramfs if hibernate to Swap file (For Ubuntu 22.04 & earlier):

Hibernate now works in my case after reboot. If it’s 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=/dev/xxx resume_offset=xxx” (replace xxx with correct partition name and offset number) and save it.

After saving the file, regenerate initramfs via command:

sudo update-initramfs -c -k all

Finally reboot and test hibernate function again.

Step 4: 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.) First, open terminal (Ctrl+Alt+T) and run command to create the config directory, that’s not exist by default in Ubuntu 24.04:

sudo mkdir -p /etc/polkit-1/localauthority/50-local.d

2.) Thanks to @Joerg, Ubuntu 23.10 and Ubuntu 24.04 users need to install polkitd-plka package first:

sudo apt install polkitd-pkla

3.) Then, run command to create & edit a config file (replace gedit with gnome-text-editor for 24.04):

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. For KDE user, try this one to create /etc/polkit-1/rules.d/10-enable-hibernate.rules file and add following lines:

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

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:

After installed the extension, go back “Installed” tab in Extension Manager window, and click configure the extension for showing/hiding power-off menu options (May need log out and back in).


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:

76 responses to How to Enable Hibernate Function in Ubuntu 24.04 & 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?

    • It turns out that pm-hibernate work fine as suggested [here]( There is nothing to change, instead of systemctl just use pm-hibernate.

      • With the kernel update to linux-image-5.15.0-47-generic the systemctl hibernate work as in 20.04.

        I would like to note that pm-hibernate was not a good alterantive to systemctl hibernate according to my experiences.

  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.


  50. The “Call to Hibernate failed: Invalid argument” problem, i try to resolve it by using a separate swap partition, changing the /etc/default/grub by removing the resume=xxx and resume_offset=xxx kernel parameter, changing the /etc/initramfs-tools/conf.d/resume by adding resume=xxx, then sudo update-grub2, sudo update-initramfs -c -k all.

    My config file and swap partition looks like:
    $ blkid
    /dev/mapper/vgubuntu-swap: UUID=”a01cbd0d-9dcc-405a-9a5e-a3d2687419fc” TYPE=”swap”

    $ cat /proc/cmdline
    BOOT_IMAGE=/boot/vmlinuz-6.8.0-31-generic root=/dev/mapper/vgubuntu-root ro splash vt.handoff=7

    $ cat /etc/default/grub|grep LINUX

    $ cat /etc/initramfs-tools/conf.d/resume

    Test and check the log.
    $ sudo systemctl hibernate
    $ journalctl -x –no-pager –since=’2024-04-29 13:45:00′
    Some logs look like these:
    The system has now entered the hibernate sleep state.

    kernel: ACPI: PM: Preparing to enter system sleep state S4

    kernel: ACPI: PM: Waking up from system sleep state S4

  51. Good tutorial

  52. 24.04 broke hibernation completely on my X1 Carbon 3rd. Was working fine (thx to this article) on 22.04 and 23.10. with a swapfile. Decided to install 24.04 from scratch, funny thing is: system goes to hibernate out of the box with absolutely no changes made but can’t resume from it (goes to cold boot instead).

    Tried several variations of the instructions given here but every time I add the resume/resume_offset to grub it throws the “invalid argument” error. Trying to get hibernation back to life w/o editing grub, just configuring initram didn’t work either. System goes to hibernate but can’t resume (just like vanilla installation).

    Will now boot up from USB stick, create a swap partition and give it another try.

    • Follow-up: after creating and activating a swap partition and deactivating and deleting swapfile and, for sure, editing grub and initram, hibernation works again.

      While changing system configuration to use swap partition instead of swapfile I did some research and maybe found out why swapfile wasn’t working: fragmentation. So when using swapfile for hibernation be absolutely sure to have a “file w/o holes”. So defrag may be the way to solve this error (didn’t test it as I now have a swap partition).

  53. Hi,
    Dell Latitude 5420 with swap partition, update from 22 to 24 LTS
    The hibernation worked fine on the 22. On 24, the system seem to hibernate (screen go black), but appr. 15 sec. the login screen appears. This happened at the first check: sudo systemctl hibernate. systemctl hibernate threw an error.
    After following the instructions, the only difference now is that the systemctl hibernate starts the hibernation without error, but again 10-15 sec. later I’m on the login screen.
    Any ideas?

  54. wahyupriadi95 May 8, 2024 at 7:37 am

    Works on Ubuntu 24.04 with swap partition, after struggle with swap file.
    After edit grub with config as step above, do update grub.
    Clean /etc/initramfs-tools/conf.d/resume, no need to define on there, then regenerate initramfs.
    Reboot and try hibernate.
    Tell me if it works in reply section.

    • Hi,
      no change: screen goes black for 10-15sec. and the login screen appears to log into the session.

  55. If you insist on using the default /swap.img file, set MAJ:MIN to /sys/power/resume works for me. However it always resets to 0:0 once reboot! Please, leave comment below if you know how to make it persistent.

    My system is kubuntu

    cat /etc/os-release
    PRETTY_NAME="Ubuntu 24.04 LTS"

    ~$ swapon --show
    /swapfile file 11G 899,2M -2

    for work around this bug I create file /etc/tmpfiles.d/hibernalization.conf
    and add it:

    # Path Mode UID GID Age Argument
    w /sys/power/resume - - - - 259:4
    w /sys/power/image_size - - - - 8036093952

    Note. Second line in this file I add because I have this amount of RAM (in “free” command answer) and for some reason decide to allow save entire RAM contents to swapfile. Actually I don’t know if it is correct decision.
    But as for “/sys/power/resume” contents of “/sys/power/image_size” also not percistant and changed to default value after each reload

  56. Please delete my second comment with name vpq. I did this copy by mistake