How does Linux move from an awake machine to a hibernating one? How does it then manage to restore all state? These questions led me to read way too much C in trying to figure out how this particular hardware/software boundary is navigated.
↫ Jacob Adams
So this is a lot deeper of a dive than I expected, and it blows my mind just how complex sleep, hibernating, and waking a computer really is. Instinctively you know this, but seeing it spelled out like this really drives that point home – and this only covers going into hibernation. It also highlights how hard it must be for the developers involved to keep this working at all, especially on the wide variety of machines and hardware combinations Linux runs on.
It wasn’t too log ago that pretty much the only platform where sleeping and waking worked reliably was Mac OS X with its controlled, small hardware selection, so it’s kind of remarkable this works at all on Linux now. I haven’t had to worry about sleeping and waking with Linux for quite a while now, and it’s one of those things that “just works” so I never have to think about it. This definitely wasn’t always the case, though, and on both Linux and Windows I would just turn the whole feature off since it rarely worked reliably, especially on desktops.
I’m sure it still breaks for people, but for me, it’s been rock solid, and reading through the linked article, I’m even more amazed about this than I already was.
I remember when this used to not work for me, then over time it mostly worked, you still had to manually fiddle with some individual piece of hardware and scripts and to now, past couple of year, on where it just works.
There was a time when I compiled every single RC by hand in the hope for better Laptop support and read every single changelog.
Today, I can not even say anymore what minor kernel version is running on my laptop. Things have changed so much for good and I am grateful for having gotten so many mighty power tools for free.
I always had very serious issues with sleep and hibernation on Linux, namely that the system was frozen after waking up and required a hard reset. Hopefully it won’t be case when I move back to Linux in a week or two.
Also, please do something about the login issues – “Remember Me” does literally nothing and still logs me out after a couple of weeks. Please set longer login cookie time to live, like several years, if you check “remember me”.
I also remember a time when it only worked reliably on Macs. I found PC laptops to be especially bad. You could always rely on PowerBooks and later MacBooks to start right back up where you left them after closing them, but that wasn’t generally the case with PC laptops.
I’m glad those days are over though. I haven’t had an issue with sleeping/hibernation on any PC in both Windows and Linux for years even through different hardware, Windows versions, Linux distros and kernel versions, etc.
Alex Seifert,
I do find my laptops wake up ok. There is a reproducible issue on a windows 10 & 11 HP laptop though: I do a full poweroff then close the lid only to find that when I power the laptop back on it wakes up and proceeds to complete the shutdown. The shutdown process goes to sleep and it doesn’t shut down properly. Doh. I have to wait for windows to shut down completely before closing the lid.
I always go for a full shutdown on desktops and it’s slower than I’d like. I have VMs that need to shutdown, but I find it’s really the network shares that cause the most delays and on debian the shutdown gets delayed by their timeouts. I don’t know why linux network shares are programmed to timeout when there are no pending writes. I also use automount, so I suspect the problem lies between it and the cifs driver. I should probably try and fix the timeouts, because it adds a couple minutes. At least bootup is fast.
I haven’t had any problems with modern PC laptops waking up, but that was certainly not the case ten years ago or so. I’ve heard about that issue with HP laptops. A friend of mine has had that same problem with his HP laptop (don’t know what model it is). When it comes to PC laptops, I’ve always been a big fan of ThinkPads. They tend to work well. last forever and Linux compatibility has always been great.
I also use sleep mode for my desktop PCs since it’s so much faster than shutting it down and start it up again. I haven’t had an issue with it for years, but I also have a fairly simple setup and only really use VMs to play around with different OSes rather than for anything serious.
@Thom you use Fedora right? I’ve been using Fedora 40 with KDE Plasma 6 + Wayland for about 2 weeks now and am pretty happy so far. Of course there were various tweaks I had to make, but they were for the most part pretty straightforward. The only thing I haven’t been able to get working is hibernate – apparently Fedora just doesn’t support it at all out of the box? and the only way to get it working is to follow a labyrinthine set of instructions here: https://fedoramagazine.org/hibernation-in-fedora-36-workstation/ which are either outdated or I’m just not talented enough to get working on my ext4 setup. Pretty disappointing considering in every other respect, this distro has supported my laptop better than any other I have tried thus far.