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.
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.
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.
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.
Re-visiting hibernate
I see what you did there
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.
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.
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
Hello , I’ve worked on enabling suspend-then-hibernate as a default on Ubuntu 20.04 :
-
suspend-then-hibernate is the default on Windows & MacOS AFAIK and the best of both world. it will suspend for X hours and then hibernate , it works perfectly on all my laptops.
-
Intel does not support “real suspend S3” on new Tigerlake laptops so suspend S0ix can drain your battery in a night
-
I have made this small script that automates everything
But beware of the very last part , it symlink the suspend systemd service because the DE does not propose the suspend-then-hibernate option.
ok you well… That’s a common issue. You might have to reload keyboard and mouse ‘‘drivers’’’ so just google for that. It doesn’t happen often (by me just like 3 of 30)
I see there is an endless catch up in the Linux world to get either hibernate or deep sleep correctly working on different hardware.
My preference: give options to users to properly test it -hibneration, deep sleep- on there machines and to have it easily activated.
shouldn’t be too difficult ;-).
This article just appeared in Linux Uprising. I’m going to give it a shot tonight and see what happens.
https://www.linuxuprising.com/2021/08/how-to-enable-hibernation-on-ubuntu.html
I finally had a chance to follow the directions in that article and HALLELUJAH it works!! I can’t believe nine years ago I switched from Windows to Ubuntu (Precise) and it took nine years to get my old laptop hibernation capability again! PLEASE make this default in upcoming builds!
Just put a Lubuntu 20.04 on my old HP G7000 Laptop. Had a Q4OS based on Debian 11.1 running on it before, hibernated without any problems. Did not like some other things, so I decided to get back to an Ubuntu flavor, but the installer did not put any swap file or partition on it (maybe it got confused by Q4OS’s swap partition). Could not work with 2GiB of RAM, and while pointing the system to the 4GiB swap partition (helpful article here), I enabled hibernation as well; works without problems!
Thanks for the hibernate enabler script! Is it going to an official Xubuntu release some day?