Re-visiting hibernate on Ubuntu

Every so often we consider the state of hibernate (suspend to disk) on Linux and choose to either have it disabled or enabled by default in Ubuntu. Currently it’s disabled by default. There have been previous discussions around this area, and perhaps things have moved on since then.

Anecdotally every time I mention to someone that we have hibernate disabled in Ubuntu, they mention some other distro they’re on where they have it enabled and it “works fine”. Obviously anecdotal, small sample size.

Is this something we can re-visit for a non-LTS release such as 20.10? I hear it’s nice to be able to hibernate, saving battery power and keeping your desktop state.

(Please can we avoid discussion of ‘well it boots fast so you don’t need to suspend or hibernate’? can we take it as read that not everyone wants to fully shutdown, but likes to keep their system state and just shut the lid, open the lid and carry on.)

Bonus points if we can consider hybrid-suspend (the mechanism whereby the machine suspends to RAM, but goes into ‘deep sleep’ (hibernate to disk) to save battery in the long term) too! :smiley:

16 Likes

I have tried to use hibernate on every LTS version of Ubuntu since Precise and it has never worked. This was particularly aggravating as the same computers running Windows had no issues at all.

3 Likes

Has hibernate ever achieved first class status in the kernel? I’m always drawn back to the discussion and invective at https://yarchive.net/comp/linux/hibernation.html where it looked to be an unsolved problem. My experience of hibernate has been universally bad. If it doesn’t really work, and is known to be broken, I don’t think it is worth revisiting. If the kernel plumbing has improved since 2007 then maybe it is worth another look.

1 Like

if it’s so catastrophically broken, how is it I seem to stumble upon only the people running other distros (today, OpenSUSE) who claim it works fine for them, and are agog that we don’t enable it?

There are people who have never experienced issues when installing software from the AUR. Not a convincing argument to add it to Ubuntu :wink:

2 Likes

I got some custom code help from AskUbuntu in 18.04 which I used to " suspend ". I am not sure whether it is suspend to disk or suspend to RAM.

It is common for me to get away from the desk for short breaks. " Suspend " helps a lot.

I would love to use hibernation in Ubuntu again, without having to fiddle with the kernel.

3 Likes

on my DELL XPS 9300 hibernation works on Ubuntu 20.10 by just updating /etc/default/grub with:
GRUB_CMDLINE_LINUX_DEFAULT=“quiet splash resume=UUID=<uuid of my swap partition”

then “systemctl hibernate” works as expected

Still need to test suspend-then-hibernate when I close the lid (in logind.conf) which for me would be ultimate goal

Update: suspend-then-hibernate works as expected

2 Likes

Anyone know what would be needed if I had a swap file instead of a swap partition?

@popey I just stumbled on this topic, obviously a bit late. It doesn’t seem that this conversation got very far but I’m curious if there’s still a motivation to make this happen? I think it’s a great idea and I’ve often wondered about the state of hibernate myself.

First, I should mention this relatively recent Ask Ubuntu topic on the subject which seems to have rather extensive documentation on how to make it work.

Also, the Arch docs provides even more information and a LOT of gotchas. That seems to resonate with a comment on the Ask Ubuntu topic, suggesting that “hibernate does not work with all equipment.”

Just picking out one of those, it seems like the problem with the radeon kernel driver is big enough to make this issue rather extensively thorny.

That said, I’d like someone to tell me that there’s a way to make this work.

P.S. It’s a year old, but here’s an OpenSUSE user having problems with both suspend and hibernate.

2 Likes

I would love to have it on my laptop. As it goes days w/o use at my house since the desktop is main family computer. Whenever I get to the laptop it is either complete dead or on it’s last 10th percent of battery life so I have plug it in. To work around that situation I have come to just shut it off and turn it on when needed as with SSD installed that made is pretty fast. Just not as fast as suspend.

2 Likes

I’d also really love to have it as I never fully shut down my machines. My desktop is always running and my laptop only fully shuts down if the battery dies. I just close the lid and throw it in my bag. It would be very nice if this would help me in squeezing some more juice out of my laptop.

2 Likes

Manjaro gnome latest has hibernate option. I have seen it demonstrated and working but will it work on your specific hardware and software configuration is a different matter.
Personally I would like to have an option with a disclaimer or a utility that could test your systems capabilities of working with hibernation.

2 Likes

Re-visiting hibernate
I see what you did there

1 Like

I use hibernate occasionally for instance when temporarily rebooting into Windows or when I’m out and my battery is almost empty. It is not so difficult to enable it when following a howto like https://ubuntuhandbook.org/index.php/2017/10/enable-hibernate-ubuntu-17-10/ but the main problem is that default swap partition is only 1GB and cannot easily be extended, especially not when using full disk encryption. Unless Ubuntu switches to LVM layout, or there is a way to get this work with a swap file.

4 Likes

It would be great to have at least a possibility to activate hibernation easily but it would come with a warning like “do it on your own risk. Your machine might explode if you do this”.

Maybe even with a warning in case the Swap is too small and a test button for hibernation.
If the result is Sleep verb xyz not supported the hint “You might have to disable Secure boot / Fast boot”.

This way users would have a helpful solution.

1 Like

I don’t know much but i lastly tried to hibernate. And it doesn’t work.

This seems to be a regularly recurring topic. I remember it being an issue on the last LTS Ubuntu I used, I think two laptops ago.
It’s currently not working for me on my dual-boot laptop, which is a middle-age HP Elitebook which I have a second hard drive in the expansion bay. That shows up to the BIOS as a “USB drive”, but I think it’s a lot faster than that (I have to check the speed - for tonight’s “todo, l8r” list. I can’t get the supplied hard drive to boot windows from the expansion bay and I’ve stopped fighting that fight - it works well enough for me. Changing that has been removed from the “todo” list and will not go back on it until this laptop physically dies.) The expansion bay HDD includes all the Ubunt installation including a primary partition for swap.
Suspend seems to do it’s “thang”. Resume gives me interminable “systemd … cannot read inode” and such like errors that make me think … “hard drive isn’t powering up in time for the restore”, but I’m a little short on ideas of where to go from here.

Is there a setting to tell “restore” to give the HDD 30sec (whatever, think of a number then add your cat’s age) to get sorted out?
There’s no mention of “restore” when I grep /etc/fstab ; shouldn’t there be a mention in the entry for the swap partition? That looks a bit stinky to me.
There’s a new option when I
cat /sys/power/state
freeze mem disk
So, I should be able to do S2RAM, S2D and … what’s a Freeze? Ubuntu’s answer to an NHS payrise? That sounds like a point for the documentation people.
I’d better go look for that in the documentation. Should’ve done that before trying to remember my old Ubuntu login.

Hmm, well that was moderately informative and interesting.
Following instructions from https://itectec.com/ubuntu/ubuntu-how-to-enable-hibernate-option-in-ubuntu-20-04/ I “told” Grub about where my swap partition was, updated Grub, then did a commandline
sudo systemctl hibernate
which shut off my mouse pointer, keyboard interface (CapsLock flashes no lights) and started the power and HDD access lights flashing away. Then after a couple of minutes, the system closed down.
So far, so good.
Re-apply power though and Grub comes back up, defaults to Ubuntu, restores from the swap partition (well, I assume from there ; that’s what I changed) to my desktop, the programs that were running …
… and stops. No keyboard handler, no CapsLock response, no mouse response.

It’s progress, of a sort. Not really useful to me - doing a shutdown and re-boot is quicker. But a sort of progress.
Any ideas where to go further?
Oh, HDD speed? dd-ing, I get about 44MB/s, which is faster than any of the USB buses on this box, so must be on one of the HP’s internal buses. Meh - good enough. I get faster performance off the Ubuntu on that bus than I do on Windows using the internal hard drive on the laptop.

Hello…
I think you all do it wrong
I’m using an Apple macbook… I installed the packet hibernate (sudo apt install hibernate)
I also had to edit grub to set resume=/dev/sda… It perfectly worked by: sudo hibernate (if there was enough free swap)
Tested with 20.04, 21.10 and with a desktop computer asus mainboard: 21.04:
Did not work since packet hibernate isn’t availlable anymore (!I mean 21.04!).
On the Apple Laptop the only problem was that sometimes the swap-UUID changed wich forced the system to forgive resuming.
I’m glad if you add the ‘resume’ packet to 21.04 and let me not just use UUID for ‘resume’.
I think it works better with a swapfile: resume=/swapfile because I don’t think that the UUID changes there
Please also make the hibernate packet as ‘default’ because it works perfeclty. Kali Linux also doesn’t have troubles with the newest version
The Apple behavior is quite special with the ubuntu hibernation: sometimes the system starts without any key pressed. Just kill the system (power button 12s) and done you are

2 Likes