322 points · by cyka178 · 5y ago · 332 comments
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.
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.
I think I would rather (it'd be easier) to wrangle cats.
Do you have any source? (Even if those are opinion based)
System76 manufactures computers exclusively for Linux. Dell XPS laptops are also pretty popular with Linux users. Thinkpads were historically, as well.
I would think you could get financial support for a few base models and enough widespread support for at least half a dozen hardware configurations.
Currently, as it stands, you'd need 10,000+ 'reference' devices to match what's in use and to wait several years for them to fall out of use if you want that to be a lower number.
Even Chromebooks, which are largely based on specific boards for several models, have a few hundred reference boards that would need to be specifically supported.
Good luck with that.
On most hardware I buy, I can read "compatible with Mac and Windows" on the package, but nobody seems to bother if it's compatible with Linux or not ...
The way to convince the mainstream vendors would be what's attracting them to release Linux support right now. The popularity of Linux devices for people who want to work on the same machines they run their servers on.
Like I said though, I'm not sure whether this idea is workable or even makes sense.
But if I want to differentiate, commanding a higher price, then I'll probably be different.
The question is, who is going to make this reference device? Intel? AMD? ARM?
Apple computers are some of the worst documented computers out there. Also, niche components, one-off chips, secret registers and unidentifiable chips on the logic board, the T2 chip alone is a nightmare for linux (and the T2 is on every Apple laptop since 2018). The M1 isn't even minimally documented yet, and reverse engineering it will probably take a decade.
Hardware device vendors don't always write or maintain Linux drivers there's no stable driver ABI for binary drivers to be built and distributed for Linux. Instead, vendors are encouraged to write drivers that follow the conventions of the Linux kernel with no hardware abstraction layers and submit them for inclusion in the upstream Linux kernel under the GPLv2. Not every vendor is willing to do that (NVIDIA for example), but some do (AMD, Intel).
The hal (hardware abstraction layer) is always a hard problem that takes years to get right. Write the code, write the tests, fix insane little bugs, get market momentum. Once it is solved it kinda runs itself and is a massive moat.
(Apple tried this... 95? StarTrek project, os 8?)
This collection of issues is why i run windows as a host os and above that run wsl (far better than mac's weird port of bsd + homebrew), local vms, and cloud servers.
Unless you want to talk about the difficulty that is high dpi monitors? That has taken 5 years for 'the windows community' to shake out and i don't think linux ever will. Windows is the best solution right now for this very important problem, unless you like fuzzy text fonts.
I am not a windows fanboi. Far from it. I have all the ecosystems in my house, and have professionally gone back and forth as the winds have shifted. It is amazing to me that windows has come back, credit vmware, docker, wsl, and microsoft's new openness to being a sensible first stop for developers.
Windows makes the hardware vendors implement it in the their device drivers, and the "system integrator" (laptop manufacturer) is responsible to verify that it works. The laptop manufactures (a) have a limited and known set of hardware to verify works and (b) have "leverage" (i.e. promises to purchase large quantities of peripherals) to ensure the hardware vendors fix any problems found.
Linux drivers don't get much hardware vendor love.
But damn the number of issues I have on linux in 2021 outweighs the amount I’ve had on Windows, ever.
Still prefer linux over windows tho.
Have a Dell XPS for work. Sleep used to work fine, and the machine would barely touch its battery if I put it to sleep over a weekend.
It doesn't work any more: the machine never sleeps properly and drains its battery very quickly, barely making it from Friday night to Monday morning (and not making it at all if I don't plug the power in before I plug anything else in).
Note that this isn't a fault with the battery that I can see: battery life is still fine when the machine is being used. I can only assume that at some point over the past couple of years an OS or firmware/driver update broke sleep... which is annoying.
(It's one of many reasons I prefer OSX to Windows: sleep always works.)
Both my 2015 and 2018 MBPs probably once every 2 days, sometimes multiple times in a single day will resume from sleep to a hard reboot and a kernel panic message or "Your computer restarted because of a problem" message.
My windows desktop workstation manages just fine, but maybe I won the hardware combination lottery.
The board vendor knows what they put on the board, they have support from the suppliers, etc... So it's a tractable problem for them even if the solutions are often ugly ad hoc hackery.
The community has none of that. They need to figure out all this stuff by reverse engineering in most cases.
But the point is it's not an "OS" problem. "Windows" doesn't do anything different from Linux. The difference is that if you ship hardware and people only pay for windows, then you only make windows work.
In my particular case, I have a HP Elitedesk 800 G4 mini (a small form-factor desktop) that sleeps, hibernates, etc perfectly on linux. Worked ever since it was brand new.
On windows, for some reason, it randomly turns on at night. I've tried deactivating pretty much all I could, including the option to wake up to install updates (and I usually install the updates fairly quickly anyway).
This also happens on an older custom-built PC. Random screen problems (AMD RX card) and / or previously unused USB ports don't work. Everything goes back to normal after a reboot. As this computer doesn't have a TPM, bonus points for the screen turning on bright blue in the middle of the night for bitlocker unlock.
Linux sleeps and hibernates perfectly on all my PCs (all some form of HP elitedesk or probook - I haven't tried those on the custom-built PC).
I've seen companies run shelves full of sleep-wake machines. sleeping and waking. sleeping and... yawn... waking.
Also if you don’t implement it or you implement it poorly and you’re not the size of Nvidia your drivers will not pass the checks and will not be signed, so your customers won’t be able to load them.
I'm pretty certain ACPI is supposed to be at least one part of such a "hardware state layer" already, but as far as I know broken implementations are more common than functional ones.
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.
- it does not work on encrypted partitions since there is no way to unwrap any key at all
- with an active state originating from an encrypted partition gives any attacker the opportunity to manipulate the hibnerated system image
- hardening tools often recommend to turn off hibernation in the kernel completely because of #2 (and the implication that this would load any crafted image into your working memory)
- recent distributions create /tmp as a tmpfs/ RAM disk which makes hibernation impossible due to power loss of RAM in this sleep state, and /tmp could be the default if nothing else is specified
- partition parameters on kernel command lines rise and fall with modules available at boot time/ through the bootloader, e.g. GRUB or Lilo. It might happen that using UUID in the case of hibernation does not work in combination with certain bootloader versions
- hardware does not support the power down sleep state, e.g. Raspberry PI or has no peripherals connected triggering a boot process (BIOS does this upon pressing for example the shutdown-key on a USB-keyboard with this enabled in the BIOS which in turn requires the USB-ports to be monitored/ enumerated and powered which isn't the case for any Raspberry)
I've been using hibernation for more than a decade on different hardware and distributions but only on that drag-around low-fi laptop ingesting ycombinator, running IRC client or Liferea. I always use the swap partition for this and it has always been /dev/sda2 with 4GByte (currently 5.4.* for Arch, Gentoo and Debian). I trust Grub, currently 2.x but also worked back in the days with 1.x since it is a kernel parameter (and the kernel self-compiled with CONFIG_HIBERNATION=y and copied with a steady hand and a magnetized needle).
Incidentally, I've just upgraded my RAM to 64GB and it's in the process of resizing the swap partition right now!
https://help.ubuntu.com/community/EnableHibernateWithEncrypt...
https://wiki.archlinux.org/index.php/Dm-crypt/Swap_encryptio...
> 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?
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.
> What ensures that the hibernation image was actually written out by the kernel? Absolutely nothing, which means a motivated attacker with root access could turn off swap, write a hibernation image to the swap partition themselves, and then reboot
Maybe I'm just really thick, but I can't think of a reason to care that root could bypass secure boot. The attacker already has access to the entire system and I would usually assume the valuable part of that access is the data and not the hardware or the kernel. This is an attack at a level beyond the typical "evil maid" with physical level access.
Besides that, I'm not sure what would stop anyone from just tampering with pacman, mkinitcpio, or other things and just wait until the next kernel is being built and redeployed to have their fun. You're going to have to upgrade your kernel at some point, and you'll need some kind of tools to do so.
There's probably a very thin line between the threat that secure boot protects against and someone beating me to death for my password.
Increasingly, root and kernel access aren't the same thing any more (if you enable lockdown mode). That stops root from doing a whole bunch of things. It's true that often, user-level access is enough (if you only care about the user's data). But if you want to modify syscalls or do some other thing that root may not do in lockdown mode, you'll need to get kernel access. And many other ways of getting there have been blocked in an attempt to strengthen the barrier between root and kernel (some dispute the utility of that separation, but I think it's because they fundamentally reject its goals). This is about closing another hole in the barrier.
How useful that barrier is against attacks of the https://xkcd.com/538/ kind is, of course, a different matter. In my view, the point is that it raises the cost.
Can you get gpu accelerated video playback in Firefox/Chrome? For me these days, "having your cake and eating it too" means running linux on a virtual machine.
My current papercut is that 4k@60hz does not work with an Lenovo Gen 2 USB-C dock, while it works fine in Windows:
https://gitlab.freedesktop.org/drm/amd/-/issues/1317
(I didn't report this, but am running into the same issue.)
Yes. (not with nvidia drivers.)
I have hardware accel running in Chromium. It's really glitchy and would not recommend it. I'd probably just use mpv or vnc if you need hardware accel video.
Really, my biggest gripe with Chromium is that it does not yet support kinetic scrolling with a touchpad. Firefox supports it, however it's still not as comfortable as my Macbook.
But at some point I noticed that laptops I'd left for a long time without power would wake up & resume. I'd expected they had run out of juice while asleep & I'd have to boot fresh.
Turns out systemd (in my Debian OSes at least) was set up to hibernate at a very low critical % of power remaining. The laptop would rouse from sleep & hibernate, at the last minute (and change). And it was working fine.
After seeing it happen a bunch of times I decided to try to embrace hibernation, & remapped my power button from sleep to hibernate. Everything worked great! Now my computers drain no battery when not active. I love it. Been this way for half a decade now. Works great.
Bonus, one of my laptops would, when it woke up from sleep, "lose" it's wifi card. With hibernate, that laptop's wifi card shows up again, even if it had lost the card to sleep before. Hibernate, contrary to my expectations, was even safer than sleep.
Just echo "disk" or "mem" or "freeze" to /sys/power/state with sudo to make it sleep / suspend / hibernate.
If you want to lock the screen as well, run `i3lock -d -c 000000` or `xlock` before updating the power state.
The advantage is that files are much easier to change (extend) than a disk partition.
Ref:
https://askubuntu.com/questions/904372/swap-partition-vs-swa...
https://askubuntu.com/questions/927854/how-do-i-increase-the...
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.
Regarding your troubles, I'm not really surprised that it's not working with a third-party SSD, and it definitely sounds like a hibernation glitch. Have you tried disabling hibernation altogether?
disable: `sudo pmset -a hibernatemode 0`
re-enable: `sudo pmset -a hibernatemode 3`
(in fact, if my admittedly poor memory serves, I think I busted hibernation mode on my old 2009 17" MBP doing the same thing, and this trick fixed sleep…)
A module working for everything except hibernate is ridiculous.
I have just accepted it, on a personal computer I am less likely to need to keep a ton of things open so it's okay if I lose all my windows on crash.
On a work computer I would not be able to accept this - thankfully my work 2018 MBP on Catalina handles this fine.
I previously had an Ubuntu Dell XPS at work with a similar problem and it was horrible losing my tabs and terminal windows 4-5x per work day
I had similar issues with my Surface Book 2, though it wasn't as pronounced as my mac.
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).
Discussed in HN: https://news.ycombinator.com/item?id=26285683 (113 points, 39 days ago, 64 comments)
I followed kernel development closely 10-15 years ago, paying particular attention to hibernation because, well, it was rather more useful back then! And one thing that gradually became clear over the years was that there was one person in the kernel community, with a lot of responsibility, who was completely and utterly incompetent to handle that position. That one person, in my opinion, set Linux hibernation back by more than a decade.
(And to sibling: I'm not going to name any names, since I prefer not to shame in public. Especially when most all of what I did was read LKML, so who knows what background stuff I'd missed. I'm afraid you'll have to come to your own conclusions.)
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...
Oddly, enabling Android got the touchpad working in Ubuntu.
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.
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.
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).
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.
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.
Also the charger that ships with the USB-C macs doesn't feel like it puts out enough energy to jump start them, feels like it has to build a little battery charge just to get over that initial hump. Older models used to be even from cold dead battery it would start instantly once the power cord was in.
I can't, however, easily find an explanation of how actual hibernation is different from this simplistic understanding.... would someone care to explain?
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.
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).
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.
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.
The technical linux communities, like Redhat, Suse or Arch figured it out. See eg https://www.ctrl.blog/entry/fedora-hibernate.html
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...
It works mostly well. Once every few years I come across some weird issue happening with software X which over time I figure out is linked to software X not handling dehibernation well, but the pros outweigh the cons.
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.
Instead, I think the kernel/OS should implement this feature instead (perhaps as a something like SIGINT that can be overridden). This would be great on hardware like the pinephone, where you have multiple programs vying for memory but only 1 app is really being used at any given moment (because of screen space). As far as I know this is already implemented in android somehow.
I think it would be simpler if the operating system suspended programs automatically, because it already knows how much memory the system has, the memory speeds, and all that, so it could probably figure the optimal way to shuffle programs around.
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.
Hibernation is not a very viable scenario for me. I have uses for a 64 GiB chunk of my solid state storage, thank you very much.
Besides, 32 GiB of disk space is nothing to sneeze at as well. I don’t quite trust using dynamically-created swap files as hibernation images, alas.
Back then the consensus was that it's a really hard problem for all sorts of reasons (including but not limited to proprietary hardware, crappy hardware, etc.), which of course it is, but that given a few years and the shallowness of all bugs under the collective eyeballs of the entire Linux community it was inevitable that it would eventually become rock solid. I just remember a lot of people being really really really insistent about it, and when sophomore CS undergrads on Slashdot are really insistent about things being true then you know it must be true. I'm seeing the same advice here today, so you're in luck! Give it a couple years, it'll be fine. Either that or "Windows doesn't do it that great either". Either that or "nobody actually needs to use power management features and if you do you are computering wrong". Either that or "I've never had a single problem with power management on Linux but I've had tons of problems with it on macOS and Windows so there!" Aren't you glad you asked?!?
I think distros don't ship with it by default because it's still slightly tricky to get right in some cases. Hibernating on some hardware can crash or lock your machine. Remember that most Linux distros are still just a puddle of random tools and glue; it's never going to be as polished as a commercial OS.
And these days, I have to leave my desk pretty often so I have it set to hibernate after 30 minutes of inactivity. My pc idles at 80 watts, so it saves a decent amount of energy to hibernate often.
You should compare the power use on sleep, not idle.
Also every device driver needs to handle suspend/resume for the device, which is very hard to implement without documentation. And the only way is to reverse engineer some windows driver...
If a laptop that won’t hibernate is a defect, it’s a manufacturing defect.
It’s not the fault of volunteers working on a free operating system.
0. This is a highly unusual operation. There is no other code that exercises this scenario of switching form a hot state to another hot state, not even S3 sleep or runtime suspend (AKA s0ix, or PCI D3 Hot) although they are a little similar. You need to completely freeze the hardware (including invalidate every cache, stop all firmware, etc), then switch to the other Kernel and make sure this other Kernel can resume operation from the state the hardware is, which is probably different from the state left at boot or at S3.
1. AFAIK the hardware (BIOS, firmware, etc.) cannot detect this as well as it can detect, for example, S3, so it can not properly react. I know, sometimes hardware/firmware gets in the way, but sometimes it helps by setting state your driver may not otherwise be aware it needs to set.
2. Testing S4 is a pain. Basically if you want to guarantee S4 works you have to put the machine to S4, wake it up, run your whole test suite again, then put to S4 and wake up a few more times and then test again. Some bugs don't show up in the first S4 cycle.
3. Debugging S4 is even worse, since it involves two different Kernels and a lot of wasted time checking for everything. Do you think devs run S4 cycles before sending patches to the mailing list?
4. With machines booting so fast and both S3 and runtime suspend working so well (not necessarily on Linux), there is little reason to even want to hibernate. Seriously, why would I ever want to use S4?
4.5. Colorary: S4 bugs will always be very low priority for the devs I pay, unless I have a paying client explicitly yelling about it.
5. Every driver in your system needs to be properly working. Just a single broken driver may screw everything in your S4 cycles. So unless you're running on a machine where some dev team explicitly tested S4 to make sure it works, then there's a chance it won't work properly.
6. It's not impossible to get this right, it's not impossible to architect drivers so the S4 code benefits from the S3 code. It's not impossible to architect a driver so it's properly initialize and work on whatever state the registers are. But it's just almost never the priority to ensure S4 works.
Edit:
The driver I worked on was nicely designed and we tried to take advantage of S3 for S4 as much as we could. Still, sometimes an S4 bug would appear and would result in tons of debugging hours just for it. I remember one specific case where the hardware got a new cache and we forgot to invalidate it before switching, and that caused very weird memory corruption. We wasted probably 2 "man months" in debugging hours before the one line fix was committed. We had a client that was doing like 50 S4 cycles in their test procedures, and the bug for some reason would only appear after 2 S4 cycles.
If you shut down the computer when it's not in use, the problems stated never happen. That's not a solution everyone will use, I guess, but it completely eliminates the problems and is very simple to do. I wish more problems had "simple and complete" solutions :-).
when you hibernate a computer, it serializes all of its RAM and the state of all hardware to disk then powers off. Powers off. this is not "standby."
on Windows it generally works flawlessly, and when spinning disks were still the ruling storage mechanism, hibernation was always faster than shutting down and booting again later.
I will admit that I haven't tried using hibernate on any machine with an SSD as a main drive since bootup is so fast with an SSD.
https://austingwalters.com/increasing-battery-life-on-an-arc...
Effectively it will idle for 2 hrs and if I don’t reopen the lid it’ll shut down (saving state to disk). Works really well, boot up is slower than I’d like, but battery life is great. Pretty happy, tbh.
Through there is some hardware for which you will have a hard time to make hibernation work and the only reason why it works on windows is because the vendor explicitly provided a proprietary/closed source driver for their hardware.
And besides this there is the simple reason that Linux is server first. Servers generally don't do hibernation.
[0] https://www.asus.com/au/Displays-Desktops/Mini-PCs/All-serie...
Honestly, it would probably be easier to just run everything off a VM if having persistent states matters to you.
If you boot into an initramfs and make additional swap partitions visible, eg via losetup, you can then write the device major:minor into /sys/power/resume and kaboom the kernel will freeze userspace, read the hibernation image out of there, then jump to it.
References: https://wiki.archlinux.org/index.php/Power_management/Suspen...
https://blog.ivansmirnov.name/how-to-set-up-hibernate-on-ubu...
If you stick to “common” hardware and a high quality distribution you should be fine.
With suspend, I hate that nagging feeling that the battery is still running down, even if only slightly, while it's in my bag.
TL,dr: Set up large enough Swap and configure Grub correctly
Intel doesn't need it to sell chips.
The Linux kernel is huge, complex and particularly messy in terms of internal structure. This makes even otherwise trivial modifications hard, and complex modifications extremely hard. The development overhead is brutal.
And hibernation just happens to be a scenario that's a nightmare to implement with such a design.
I wonder how such a messy base offers such stability ...
By not solving problems like hibernation.
I have been running primarily Linux for longer (over two decades) and I am to some extent fond of it. But it is what it is.