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 the ID of Swap Area & Create if NOT exist.
System hibernate feature saves data into swap area on disk. You need to first find out the ID or UUID of the swap device, so to know where to resume from hibernation.
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 all enabled swap devices in your system, along with its name, type, size, priority, etc., information.
- If the TYPE is a partition, then you need to write down its name, which is usually ‘/dev/sdaX‘ or ‘/dev/nvme0n1px‘. Next go directly to step 2
- If it’s a file, then you need to go next step (b.) to find out the root partition (Ubuntu file-system) name, as well as the physical offset to locate that swap file.
NOTE: A Linux system may have multiple swap devices, go check the one with highest priority! If the swap name is “/dev/zram0”, then it does NOT support hibernation!!
b. Find root partition name and physical offset
So, if your system uses a file for swap area, then you need to find out the root partition name + physical offset to locate it.
To get the system partition name, run the command below, and check the one mounted on “/”:
df -h
In the screenshot below, the root is /dev/nvme0n1p6
in my case.
To get the physical offset of the file, use command:
sudo filefrag -v /swapfile
Here, replace /swapfile with yours swap file name (see swapon --show
output). Then, copy the start number under physical_offset. It’s 3606528 in my case.
c. Create Swap File, if you don’t have Swap area:
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
If you already have a swap space, and want to use this one with higher priority, run sudo swapon -p 100 /swapfile instead. Replace 100 with any number bigger than the existing swap.
And, if you already ‘swapon’ the swap, then you need to disable it via sudo swapoff /swapfile
first, then swap-on with priority number with the command above.
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
When done, you may run step b. to find out the root partition name plus physical offset for this swap file.
Step 2: Enable Hibernate by adding Kernel Parameter
After step 1, you can now add kernel parameter in Grub boot-loader config file, to tell it to try resuming from the swap device on every boot.
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 the Swap partition name you got in step 1) as value of “GRUB_CMDLINE_LINUX_DEFAULT”.
For Swap file, add resume=/dev/xxx resume_offset=xxx (also replace xxx with the root partition name and physical offset number according to step 1) instead for value of “GRUB_CMDLINE_LINUX_DEFAULT”.
Finally, save the file and apply changes by updating the Grub configuration via command:
sudo update-grub
Step 3: Check if hibernate works:
NOTE: The hibernation won’t work with secure boot!! You have to disable it in BIOS/EFI first. With secure boot enabled, you’ll get error:
“Failed to hibernate system via logind: Sleep verb “hibernate” not supported”.
To verify if the hibernation function works now, open terminal (Ctrl+Alt+T) and run command:
sudo 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 you can boot the machine again, and see if it restores your system status after login.
If hibernation works, go to Step 4 to enable ‘Hibernate’ option in shutdown menu. If NOT, then your computer may NOT support this feature or something has gone wrong.
Troubleshooting:
For Ubuntu 24.04 with swap file, there was a bug, that may cause “Call to Hibernate failed: Invalid argument” error when running the hibernate command. In the case, the hibernation may only work on first action.
The bug has been fixed in Ubuntu 24.04.1. And, here is just the note about the workaround:
- First, open terminal and run command
lsblk
to get theMAJ:MIN
value of the root partition. If you don’t know root name, usedf -h
to find the one mounted on “/”. - Next, run command to create a tmpfiles.d config file:
sudo nano /etc/tmpfiles.d/hibernation_resume.conf
When file opens in terminal window, add the lines below:
# Path Mode UID GID Age Argument w /sys/power/resume - - - - 259:6
Here, replace 259:6 according to
MAJ:MIN
value you got in last command. Then, press Ctrl+S to save file and Ctrl+X to exit.
This config file tells to write MAJ:MIN
value to the /sys/power/resume
automatically on system boot, so to workaround the bug until it was fixed.
Regenerate initramfs if hibernate to Swap file
Hibernation works in my case without this step!! If it’s NOT 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.
Option 1: The legacy method for For Ubuntu 22.04 and earlier, though it still works in Ubuntu 24.04.
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] Identity=unix-user:* Action=org.freedesktop.upower.hibernate ResultActive=yes [Re-enable hibernate by default in logind] Identity=unix-user:* Action=org.freedesktop.login1.hibernate;org.freedesktop.login1.handle-hibernate-key;org.freedesktop.login1;org.freedesktop.login1.hibernate-multiple-sessions;org.freedesktop.login1.hibernate-ignore-inhibit ResultActive=yes
Option 2: Thanks to this thread, since Ubuntu 24.04, the new method to add hibernate menu option is to create config file under /etc/polkit-1/rules.d/
directory.
- First, run command to create a config file:
sudo nano /etc/polkit-1/rules.d/10-enable-hibernate.rules
- When file opens, paste the lines below and press Ctrl+S to save, finally press Ctrl+X to exit.
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; } });
After doing either option above, your desktop (including MATE, XFCE, KDE, but exclude GNOME) should NOW have the “Hibernate” option in shutdown menu!
For GNOME, the default desktop in Ubuntu, you need to do one more step for the menu option visible:
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).
Moreover:
If everything goes well after this tutorial, you can get more, including hibernate when lid is closed, and automatic hibernate on system idle.
Very nice!
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!
Fantastic and clear explanation. Worked perfectly on my Lenovo X230 running Ubuntu 21.10
Excellent, clear and accurate step-by-step instructions, thank you very much. I just enabled hibernation on my laptop and it works great.
Thanks, i appreciate
Excellent! Thanks for your detailed tutorial. It works perfectly.
Works like a charm !!! Thank you so much 🙏
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
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
NAME TYPE SIZE USED PRIO
/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.
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:
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:
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.
followed your steps and it worked 100%
Now i got a wroking Hibernate option in my power menu.
thanks a million.
Indeed the secure boot was enabled, hibernation works fine now.
many thanks, I appreciate your guidance.
Thanks for this tutorial because I managed to hibernate my Beelink GT-R Mini PC with Ubuntu 22.04 Desktop. Keep it up!
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](https://askubuntu.com/q/1404958/480954). 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.
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!
Thanks for the post.
Working on Kubuntu 22.04
Worked well after disabling the secure boot as it says.
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 partitionI am unable to set up hibernation w
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?
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.
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:
Then delete the file:
If you don’t want to re-create the swap file again, also remove “/swapfile none swap sw 0 0” from /etc/fstab file.
systemctl hibernate works now after I managed to increase my LVM SWAP partition. Thanks a lot.
Thanks a lot.
This tutorial worked for me.
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
6b2ce25b-bc09-41fa-894f-70f9655fab24
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
Thanks. Been meaning to look into this for a while.
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.
Oh Thank God! It hsa started working, thanks for helping.
It’s my first time with Ubuntu and that was really very helpful. Thank you so much.
Great! Worked fine on lenovo!
Thank you so much guys I’ve been searching for a while in you save me thank u very much
Excellent article, works like a dream. However it’s about time this option was included in Ubuntu as standard.
Is there a way to avoid having to ask for password every time I want to hibernate?
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)
Now it works!!
Fantastic!
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!
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
Great! Worked fine on Dell Inspiron 7460!
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.
Thank you very much!!!
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:
to:
Save file and apply via
systemctl restart upower
command. See more here.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?
After some cut and paste incl. gnome extension it worked!
TNX
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.
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?
I am on Ubuntu 23
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.
Thanks for confirming!
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.
It should be enahled by default, or by means of a simple click.
Hibernate works in all modern computers I’ve tried
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!!
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.
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.
physical_offset only shows two digits.help ???
➜ ~ 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
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.
Cheers,
Joerg
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
GRUB_CMDLINE_LINUX_DEFAULT=”splash”
GRUB_CMDLINE_LINUX=””
#GRUB_DISABLE_LINUX_UUID=true
$ cat /etc/initramfs-tools/conf.d/resume
resume=UUID=a01cbd0d-9dcc-405a-9a5e-a3d2687419fc
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
Good tutorial
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).
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?
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.
My system is kubuntu
cat /etc/os-release
PRETTY_NAME="Ubuntu 24.04 LTS"
~$ swapon --show
NAME TYPE SIZE USED PRIO
/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
Thank you @Vladimir for the tips. I’ll give it try and update here.
Please delete my second comment with name vpq. I did this copy by mistake