Today I have found out that hibernation is by default disabled in my Ubuntu 18.04 distribution. After this, I found this 11 month old post https://discourse.ubuntu.com/t/re-visiting-hibernate-on-ubun... where I realized that the Linux community does not seem to be able to implement a working implementation of hibernate. Is there any reason why this is a difficult problem? I would like to have an option in my OS like VM's have where everything that is currently running is saved on disk and can be resumed later without issues.
[+] [-] gvb|5 years ago|reply
Add to that difficulty the fact that many hardware (peripheral) vendors provide incomplete documentation making it difficult or impossible to implement "off-nominal" situations like hardware state reading/writing-restoring.
VMs have an advantage that the peripherals are limited in types and numbers and the state is "virtual" so the state is directly accessible (r/w) in the virtualizing driver software, not buried in physical hardware. When you "hibernate" a VM, no physical device actually powers down and no (buried in hardware) state is lost.
[+] [-] addicted|5 years ago|reply
Basically, you develop against that device, and it's upto hardware manufacturers to try and match the reference device to make their laptops/desktops compatible.
If you could get a couple of distro owners such as Red Hat, Ubuntu, Arch, etc. to agree upon such a device it would go a long way to resolving a lot of the issues that the desktop community faces.
Disclaimer: I have no expertise in this on either the hardware or software end so this idea might be completely nonsensical for all I know.
[+] [-] rcxdude|5 years ago|reply
[+] [-] cesarb|5 years ago|reply
[+] [-] liquidify|5 years ago|reply
[+] [-] ironmagma|5 years ago|reply
[+] [-] test6554|5 years ago|reply
[+] [-] m463|5 years ago|reply
It's like savegames - I think it's hard and bug-ridden so some folks just add checkpoints and don't bother with complex restores in the middle of the bossfight with rockets in the air.
[+] [-] whatever1|5 years ago|reply
[+] [-] saltedonion|5 years ago|reply
[+] [-] Kliment|5 years ago|reply
[+] [-] bbulkow|5 years ago|reply
[+] [-] bouncycastle|5 years ago|reply
Incidentally, I've just upgraded my RAM to 64GB and it's in the process of resizing the swap partition right now!
[+] [-] DyslexicAtheist|5 years ago|reply
https://help.ubuntu.com/community/EnableHibernateWithEncrypt...
https://wiki.archlinux.org/index.php/Dm-crypt/Swap_encryptio...
[+] [-] herodoturtle|5 years ago|reply
> You need a swap configuration that's large enough to fit your entire RAM and also your current swap.
I'm struggling to wrap my head around this one - please help me understand?
How can a swap be made large enough to fit your entire RAM as well as your current swap?
In other words, what if your current swap is already being used near capacity?
Or is that not really likely with a really large swap?
[+] [-] deckard1|5 years ago|reply
I have a ThinkPad running Archlinux. I have suspend-then-hibernate mode enabled, which means when I close my laptop lid it suspends for 2 hours (configurable) and then puts itself into hibernate. If I decide to open the laptop within 2 hours, it's available instantly. Otherwise, it takes maybe 20 seconds to reanimate from hibernation. People often say, why not just shutdown and reboot? The obvious answer is that I don't want to close out a dozen Chrome tabs, close all my terminals, all my files, and open everything up every time I need to walk away from the computer.
I have secure boot turned on. Hibernation is done to a swap file (I can simply delete the file if I need the space). I have LUKS encryption enabled. I'm dual booting with Windows. And yes, it all does work perfectly fine.
You can have your cake and eat it too. It just takes a bit of research and a bit of time to setup.
[+] [-] k__|5 years ago|reply
I switched the SSD of my MBP 2 years ago and since then everything is out of control. Sometimes the thing keeps running when I close the lit and when I open it again the battery is empty. Sometimes it simply shuts down entirely and has to boot from scratch when I open it again.
I tried reinstalling the OS and whatnot, nothing worked.
[+] [-] hospadar|5 years ago|reply
With SSDs, booting is fast. Most apps that I care about which have complex state (browser, IDE) do a much better job of saving their state than the OS can do (browsers & IDEs can and do easily restore sessions, etc).
[+] [-] jules|5 years ago|reply
[+] [-] pkulak|5 years ago|reply
[+] [-] severine|5 years ago|reply
Discussed in HN: https://news.ycombinator.com/item?id=26285683 (113 points, 39 days ago, 64 comments)
[+] [-] gruez|5 years ago|reply
[+] [-] pixelmonkey|5 years ago|reply
https://en.wikipedia.org/wiki/TuxOnIce
[+] [-] dorfsmay|5 years ago|reply
This makes a huge difference on Linux, and I hear the windows mode is somewhat experimental and not working so well yet even with Windows.
https://mobile.twitter.com/dorfsmay/status/13629639921094778...
[+] [-] techrat|5 years ago|reply
Oddly, enabling Android got the touchpad working in Ubuntu.
[+] [-] terinjokes|5 years ago|reply
[+] [-] rickspencer3|5 years ago|reply
You can see some discussion here: https://bugs.launchpad.net/ubuntu/+source/policykit-desktop-...
and even more here: https://bugs.launchpad.net/ubuntu/+source/policykit-desktop-...
net/net even back then, no matter how much effort we put into it, we could never make it work on even most machines because there was just too much variability. The OEM team could make it work for specific machines that Ubuntu was pre-installed on, but otherwise, hibernate was just a bug farm.
[+] [-] _joel|5 years ago|reply
[+] [-] dathinab|5 years ago|reply
[+] [-] yaantc|5 years ago|reply
Still, with the current implementation one must disable secure boot to enable hibernation (which I do). Having hibernation and secure boot is the (complex) missing part, see [1] for why.
[1] https://mjg59.dreamwidth.org/55845.html
[+] [-] wing-_-nuts|5 years ago|reply
[+] [-] jcheng|5 years ago|reply
[+] [-] alerighi|5 years ago|reply
A thing that I do often is that I forget my desktop PC in sleep mode but still powered, and since I know that hibernation works I can simply cut power to the whole power strip to save energy without having to wake up the PC just to shut it down correctly and then remove power safely.
By the way, you can also have a swap file, but it's not as simple to configure (and still the file size is kind of fixed and that removes the point).
[+] [-] throwaway823882|5 years ago|reply
I have about a thousand browser tabs and 20 terminals open at any given time. Re-setting all that up would be a pain. I haven't shut down my laptop in 6 months, but I hibernate and resume it regularly.
[+] [-] detaro|5 years ago|reply
[+] [-] ashneo76|5 years ago|reply
Regularly my MBP dies with the lid closed with no option to hibernate. After which, it refuses to start for 15 minutes after being plugged in, before it agrees to turn on. To me, that is user hostile.
Windows hides the hibernate option until you do some magic incantation. Often upon restart, wifi driver is disabled or cannot be enabled and I have to restart.
On Linux, At least with a decent swap size, all I have to do is `systemctl hibernate` and it works like magic. LUKS and sd-boot are what I use as well.
[+] [-] ineedasername|5 years ago|reply
I can't, however, easily find an explanation of how actual hibernation is different from this simplistic understanding.... would someone care to explain?
[+] [-] Syonyk|5 years ago|reply
But the devil is very much in the details, and you may not have access to any of the details because the datasheets are NDA'd or just flat out not available to anyone outside the OEMs.
The problem is mostly around hardware state. I've written some sleep patches for Linux on a PineBook Pro (I should finish those and try to upstream them...), and the problem is that on restore, you have to put the hardware exactly as it was when you put it to sleep, or things just don't work. The details of both querying the hardware state, and putting it back, range from "fairly straightforward if inefficient" (copying out device register state on sleep, restoring state on resume - but which of them actually matter?) to "really, really nasty, involving going through the init sequences again, then updating state in the proper order."
Resuming from hibernate is almost the same as a cold boot, except that it's a different shutdown state, so the boot firmware may or may not do things the same as on a cold boot. If you've moved PCI devices around to where you want them instead of where the boot firmware put them, you have to shuffle them back to where you want them - and do this in the correct order, which may or may not be the same as the ordering you did it when the kernel first came up.
If any of this isn't done properly, the system will be in a weird state and things might not work on resume. The patches I wrote for my PBP work fine, unless there's audio playing when the system goes to sleep. Then it still doesn't restore audio state properly and I've not taken the time to dive into the Linux sound system enough to understand why... and this is sleep (suspend to RAM), not hibernate (suspend to disk). Coming up from hibernate, the device state might be entirely different.
Like just about anything with modern computers, a simple idea turns into an absolute minefield of implementation details, and the Linux side of things is hindered because you often simply don't have the datasheets. So now you have to reverse engineer Windows drivers if you want support, or guess that, well, this device is in the same family as that similar device we have a leaked datasheet for from some OEM's FTP site, so maaaaybe it uses the same weird register layout, and... etc.
[+] [-] pedro2|5 years ago|reply
Sleep works fine for ages. Works better on Linux on my 2015 laptop than on Windows (hint: if you have a KIRA laptop, suspend stops borking after you update the drivers for the touchpad to a ~2019 version).
[+] [-] dathinab|5 years ago|reply
E.g. for a relative secure setup you can:
- use a custom platform key
- use EFIStub boot and bundle you kernel initramfs, flash screen image, kernel options, etc. into a single efi bootable blob
- sign that blob with your custom platform key (or enroll it's hash if you don't use a custom platform key).
- copy your secure boot signed early boot environment into the efi partition.
- have everything else in encrypted partitions including /boot (which your are not using)
- easiest way to have this is make a EFI partition and a single large encrypted partition and then use LVM (logic volume manager 2) on it to split it into swap, root, /home etc. Added benefit is you can easily resize them.
- now you just need to setup a way to decrypt on boot, e.g. by having a boot password, secure key or similar. You will need to provide it even if you boot from hibernation. (or you use the platforms TPM!)
Naturally you can also just ignore how hibernation breaks secure boot and set it up anyway. Your computer doesn't know you are braking the secure boot spec. But a company (like Ubuntu) might have committed to not brake the spec.
[+] [-] dfox|5 years ago|reply
[+] [-] hobonate|5 years ago|reply
I have a LUKS (but not LVM) encrypted root and swap partition on /dev/sda3 and /dev/sda4 respectively.
I use the command "su && mount /boot && genkernel --luks initramfs" to generate the initramfs.
I give the initramfs the following parameters: "crypt_root=/dev/sda3 root=/dev/mapper/root crypt_swap=/dev/sda4 resume=/dev/mapper/swap". This makes my initramfs ask for my password for the partitions, then decrypt the partition, then mount them and resume from hibernation if possible.
I add this parameter by setting GRUB_CMDLINE_LINUX in /etc/default/grub, and then running "grub-mkconfig -o /boot/grub".
When I want to hibernate I use the following command: "exec loginctl hibernate". My window managers let me bind this to a keyboard combination.
I am using openrc as my init system (with elogind), and sway/GNOME as my window manager. The computer uses legacy BIOS (SeaBIOS) and the storage uses GUID partition table with the grub bootloader. Hope this helps.
[+] [-] ka0lin|5 years ago|reply
[+] [-] rurban|5 years ago|reply
The technical linux communities, like Redhat, Suse or Arch figured it out. See eg https://www.ctrl.blog/entry/fedora-hibernate.html
[+] [-] fsflover|5 years ago|reply
[+] [-] smhenderson|5 years ago|reply
OpenBSD hibernate, and power management in general, works great on Thinkpads but the developers specifically like and use them regulary, at least so I've heard.
So I don't think it's any one OS that works well or badly or better than another; it comes down to the combination of the OS and the hardware and the compatibility between the two...
[+] [-] rurban|5 years ago|reply
[+] [-] phendrenad2|5 years ago|reply
[+] [-] twobitshifter|5 years ago|reply
Of course app developers can make a restart less painful too. Web browsers have already implemented restoring tabs from the last use, and Outlook will automatically save any of your drafts. For any work in the cloud, you really just need a pick up where you left off cue.
[+] [-] chme|5 years ago|reply
Every time my desktop PC running Windows 10 tries to wake up from a suspend-to-disk or even suspend-to-RAM state, it resets its BIOS and RTC.