The Register Home Page

back to article New Linux kernel patch lets you cancel hibernation mid-process

A new Linux kernel patch lets you cancel the process of your machine going into hibernation, but the bigger context of the work may be more important. The new request for comments is from Collabora's Muhammad Anjum. Collabora does a lot of FOSS development, although its work on LibreOffice may be the most visible. (That may …

  1. frankvw Silver badge
    Holmes

    "... hibernation support is a somewhat neglected area of Linux support"

    That's putting it mildly. As I see it, solving the many problems with hibernation (that tends to break things like network support, power management or just everything, at least on most of my systems) should have priority over adding weird and wonderful options such as the possibility of interrupting it halfway through. As it currently stands, in most (all?) distro's hibernation is disabled by default, simply because it's too much of a minefield. So fixing that before adding new features might not be such a bad ides. But maybe that's just me...

    1. Tom Chiverton 1

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      That's because "things" breaking on resume-from-disk is down to the various subsystem and driver maintainers, and most drivers in the kernel don't have active developers (there are a lot of drivers !)

    2. Czrly

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      Indeed. Hibernation, today, is pretty much completely useless because the issues it causes are invariably going to take a LOT longer to resolve, over time, compared to just waiting all of six seconds for a cold-boot on modern hardware.

      What *I* truly miss is *proper* suspend-to-RAM: S3. That's basically dead, too: what we have, now, is a sort of polished version of S2: suspend-to-idle. It is a lot better than S2 was, historically, but it is still nowhere near as nice as true S3 was when one got that actually working – which, admittedly, was basically never.

      1. alkasetzer

        Re: "... hibernation support is a somewhat neglected area of Linux support"

        True, suspend to ram is broken. Depending on the kernel version I may be able to enter it (step one) and then I may eventually be able to exit suspend (step two) and use the computer with input/output devices (step three).

        Linux is usually broken, freebsd is usually broken, osx is almost never broken, windows is occasionally broken (you are always one update away of this state these days).

    3. m4r35n357 Silver badge

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      Hibernate to swap partition requires a decision at installation - not good. Swap files are better, but why does hibernate need to share swap space at all? Why not just allow a swap file for, er, swapping and a separate one for hibernation? They can then _each_ be sized appropriately.

      1. frankvw Silver badge

        Re: "... hibernation support is a somewhat neglected area of Linux support"

        "Hibernate to swap partition requires a decision at installation - not good."

        That is partly correct, but only up to a point.

        The "decision at installation" I assume you refer to is to create a swap partition, while today's default is to just plonk everything into one disk-wide partition and use a file within that file system for swap. However, while that approach is in part driven by the need to make installations decision-free (which is good), the choice not to differentiate between the basic OS, user-installed/supplied files and swap on a partition level also reflects the assumption that with a swap file a swap partition is superfluous because those who don't know about partitions and file systems won't be able to enable hibernation anyway.

        It would be easy to change the default installation to create a sensibly-sized OS file system and swap partition and leave the rest to user storage space for applications, settings and documents. But currently there's no point, because hibernation is so broken it's not worth the effort of tinkering with it.

        Alternatively, as Liam already pointed out in his article, hibernation to file rather than hibernation to swap partition is no biggie; Windoze has done it for ages. That would also do away with any decisions at installation. But again, currently there's no reason to do that until hibernation becomes useful.

        1. Rich Harding

          Re: "... hibernation support is a somewhat neglected area of Linux support"

          Agreed. I think your para about the default installation is particularly spot on. I did a / /home Swap installation just yesterday on a spare Win10 machine that I should have reconfigured ages ago, to be honest. For work machines, I tend to partition /var separately too, because it avoids me accidentally maxing out / but..

    4. stiine Silver badge

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      I expect that making it interruptable will fix the existing after-wake-up problems.

    5. Irongut Silver badge

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      True but being able to cancel it would be useful when testing those improvements, which would require it first.

      Tbh a new system that doesn't use the swap space and considers cancellation from the start would be best but then we get into the dreaded Linux fragmentation.

    6. deive

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      "if you enable it, you will probably want to try it out repeatedly, so being able to cancel the process sounds good to us" - this also applies to devs, so this functionality could help improve things.

    7. Anonymous Coward
      Anonymous Coward

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      It's an industry-wide problem. Sleep modes are a serious issue on Windows and MacOS too. Maybe there needs to be a better standard of how these states are supposed to work. As an example, Windows and MacOS suffer from power drain in S0 because they have network wake, which Linux doesn't.

    8. ChoHag Silver badge

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      Give it enough time and it'll be supported as well as audio is. Eight different variants, each broken in subtly different and incompatible ways. Three of them abandoned by their developers including the most commonly used one that mostly works but is has never been accepted in the main kernel branch. Documentation dotted around stackoverflow.

    9. This post has been deleted by its author

    10. DoctorPaul Bronze badge

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      Totally agree, I run 6 monitors on two graphics cards and hibernation is my go-to option. Otherwise it's a total PITA to set up my working environment each time I start the computer.

      And that's where Linux has completely let me down when Windows "just works" (one of the few times it actually does). In the first instance of trying Mint, running two nVidia cards meant open-source drivers that could see all 6 monitors but it took a couple of seconds for a drop-down menu to drop down, or closed-source drivers that could only see 3 of the monitors on one of the graphics cards.

      So I built an identical rig using AMD graphics cards and had another go. Installation with one card fitted worked, as did then adding the second card. Hooray! All 6 monitors working.

      Then I made the massive mistake of following an online guide to enabling hibernation on Mint. On restart, the machine barfed completely and dumped me into some sort of GRUB menu with only "emergency graphics".

      Even nuking every partition on the disk and doing a complete reinstall hasn't fixed it, can't get Mint to work, just get the GRUB menu now. $deity only knows how it could stuff up a system so completely.

      PS I've used Mint as the OS for my media server for years so I'm not a complete newbie.

      1. harrys

        Re: "... hibernation support is a somewhat neglected area of Linux support"

        my guess..... sounds like a firmware and or driver update was pushed out in the period in between after it was working

    11. Anonymous Coward
      Anonymous Coward

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      Ah yes, hibernation problems.

      All of my hibernation problems on Arch linux came down to three things:-

      1. turning on hibernation doesn't automatically update the initial ramdisk image used during boot to point to the right swap partition where the hibernation image was stored (config file change needed and regeneration of initrd - this functionality isn't tied to the KDE plasma settings menu for sleep/hibernation, and I don't think it should be.)

      2. My bootloader (Refind) has to be manually updated to point at the same disk partition with a "resume=#####" added to the call to the linux kernel.

      3. My dell XPS laptop has two hard disks, and for some reason /dev/nvme0 and /dev/nvme1 very occasionally have their IDs swapped early in the boot process, so you *have* to supply a partition UUID to your bootloader as well as your fstab or you get occasional failed boots.

      I wouldn't expect the average user to deal with problems like that, nor would I expect the Arch community to be able to configure hibernation for everyone's esoteric computer configurations. (For one thing, they'd probably have to only support one bootloader, and not give users a choice.)

    12. DS999 Silver badge

      I've never seen the point of it

      Closing the lid i.e. "suspend to RAM" lasts about three days for me on a fully charged laptop, so unless I've let it run down pretty far that's good enough even for a "time to board my international flight" timeframe.

    13. Rattus
      Alert

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      it is my experience that most firmware and driver devs, turn on and configure hardware devices (and pin swapping matrix) at start and then forget about it. Often with single hard coded magic register vales instead of individual bit toggling.

      There is no attempt to clean up and save configuration state, or even turn off hardware during suspend (or shutdown) and this can be a real problem when resuming, the hardware block needs to be re-powerd and restored into a state that wasn't previously saved; requiring state machines to be restarted, effectively screwing up anything higher up the stack. Although it would help if software further up the stack could cope with stateless device communication (or at least handle closing and re-opening pipes)

      Why does this happen?

      I lay the blame mostly on the HW vendors not providing any open access documentation for the hardware devices that would enable FLOSS developers to work well in this area (even the better players in this area usually only provide redacted information under an NDA limiting useful development in the open to a few named individuals)

      And why is that?

      Often because the HW is a combination of IP / devices from a combination of vendors that are poorly documented themselves. Likewise the HW team usually end up hacking a few registers to get the device to start before handing over to the SW team, who never envisaged the need for their device to handle suspend or hibernate events (at a HW level this usually means power off) the reference design and demonstration code normally leaves such things as an exercise for the integrator :-) Such hacky code often ends up underpinning much of our low level hardware control...

      This isn't just a FLOSS issue. This is true for almost every 'embedded system' I have ever worked on.

      ----

      What about 3rd party peripherals (after market devices)?

      Just how many of the vendors provide FLOSS support as source code as opposed to a binary that assumes a particular kernal version, or distribution? (true also for Windows)

      Now support the cheaper end of the market

      A lot of OEM hardware uses 'generic' drivers - however often these drivers don't support all the device features' or the device doesn't quite work with the drivers...

      /Rattus

    14. Graham Cobb

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      I don't know if its a coincidence, but this week a bunch of patches have hit the BTRFS developer list regarding suspend/hibernate. Mostly about cancelling long running stuff (like disk scrubs) so suspend can go ahead, but also discussing the things that can go wrong! Horrible!!

      I'm glad my last (and only) kernel contribution was in 2002!

    15. Sandtitz Silver badge

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      "So fixing that before adding new features might not be such a bad ides. But maybe that's just me..."

      Not just you. I'm also curious why Linux hasn't managed this yet.

      Windows has had a working hibernation implementation since W2K.

    16. Jou (Mxyzptlk) Silver badge

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      You are doing the same complaint we all do about MS. And it is not just you. MS has suspend and hibernate in a surprisingly stable manner (BIOS can still sabotage of course, but then it boots up and assumed someone pulled the power cable). For many years I used it, and for the last three years I use suspend-wakeonlan for video encoding (and other loaded jobs) depending on how much solar power is there. 16 (32 SMT) cores, running full throttle, many parallel tasks, "suspend" or "hibernate" (usually I choose suspend) without taking care whatever it running... Wake it up again and it all just works on, no data corruption etc... If only they would not messed up the UI so bad and concentrated more on actual new bugs since 2021 instead of featuritis. Or fix some of those half-assed implemented features like network QoS missing incoming packet control etc... See, same shit as Linux, just a different shade.

    17. 42656e4d203239

      Re: "... hibernation support is a somewhat neglected area of Linux support"

      I Hate to be the one to grab all the down votes but, Hibernation, for me, on an oldish ACER Inspire laptop running Manjaro with 12Gb of RAM, suitably sized swapfile and a 250Gb SSD has been mostly painless!

      It used to crash the lockscreen on resume if I had a second monitor plugged in when suspending and not when resuming, but that just meant swapping to a text console and killing the lockscreen (or rebooting).

      These days I don't have a problem, other than it takes a while and at abouot half way through looks like it has finished - sadly the laptop doesn't have a drive activity light so learning about how long it took was interesting - opening the lid only to have it switch off almost instantly when it should have been resuming was puzzling to begin with (never said I was a quick learner).

  2. JimmyPage Silver badge
    Linux

    Has hibernation ever reliably* worked ever ?

    *That is repeatedly for varied models with varied spec and varied setups ?

    I've never trusted it on Windows so quite happily accept it not working in Linux.

    Hate to sound niggardly, but I'm sure there are other more pressing areas that could do with attention ?

    I write as someone who has used Linux for 20 years everywhere I can.

  3. Boothy

    Who actually uses Hibernation?

    Not trolling, just curious.

    For myself I used to use Hibernation (in Windows) years ago when it meant a faster boot from cold than a regular true cold start (I'd full shut down on Friday night, but Hibernation Mon to Thus).

    But with faster SSDs and CPUs I gave up using it, as Hibernation caused occasional issues (hardware sometimes not initialising correctly, memory fragmentation etc), that a reboot would fix. The then newer and faster systems would boot up in less than say 10 seconds anyway, so my use of Hibernation to me just wasn't of much use any more.

    If I want to save state (such as having lots of application/programs open that I want to continue with the next day), I'll just sleep/suspend, which sips very little power these days and gives you an instant resume. I could see the hybrid approach being useful for people working on the move, so might have a lack of available power, but I mostly WFH, and sometimes on client sites, so I've always (baring a power cut!) got power.

    For non $work related use, I am on Linux (Mint) as my daily driver, but I always just full shut down each day, using Hibernation has never actually crossed my mind, hence being curious about why other people might find this useful?

    1. Ken Y-N

      Re: Who actually uses Hibernation?

      Me! The office PC has so much stuff to load at startup that it can take two or three minutes after log in for Teams to appear, for instance.

    2. Kevin McMurtrie Silver badge

      Re: Who actually uses Hibernation?

      Hibernation is a good response to your UPS saying power reserves are getting low. Sleep can still consume 20+ watts and it won't survive a power outage.

    3. AndrueC Silver badge
      Meh

      Re: Who actually uses Hibernation?

      It's always worked fine for me on Windows. I used hybrid sleep on my office PCs for years. I vaguely recall that many years ago (Win XP perhaps) I had a work machine that wouldn't stay in hibernate and woke back up immediately but that was a long time ago solved problem.

    4. Sandtitz Silver badge

      Re: Who actually uses Hibernation?

      "But with faster SSDs and CPUs I gave up using it"

      With SSD's the hibernation is much faster than with HDD's back then, getting close to suspend speeds. Restoring e.g. 16GB of memory content is just a couple of seconds with an NVMe SSD, and not very laborious for a SATA SSD either. The downsize of course is the required disk space to house the (compressed) memory contents.

      "being curious about why other people might find this useful?"

      Leaving programs open and continuing work later? Browser tabs waiting in the same state you left them?

      People leave apps open on phones and tablets all the time, and usually reboot them only when OS updates are installed. Why should it be any different with computers?

  4. This post has been deleted by its author

  5. Dan 55 Silver badge

    Not the power button

    Just any key on the keyboard will do oherwise you'll could miss the time to cancel the hibernation and turn the computer on again.

  6. powershift

    It works in debian 12

    Getting hibernate to run requires advanced installation in the disk partitioning during install. I'm sure there is a way to do it without installing but for me that I how I did it. Tthe automated debian OS install doesn't partition enough swp space.

    After that the debian NVIDIA drivers needed installing. Couldn't get suspend to work reliably S3 (resume failed) on an i7 Acer laptop. But with hibernate I have that working and to hibernate I run a script to disable bluetooth and then systemctl -h. After resume the script runs to enable bluetooth. BTH would cause a hang on resume every 4-5 suspend/resume iterations. So far my record is 28 days uptime with S4/resume multiple times a day.

    The gotcha is sometimes I think there are leaks and memory corruption issues when its up a long time so a reboot is needed when unexpected things start happening.

  7. O'Reg Inalsin Silver badge

    Dilemma

    If checked baggage with battery inside gets used for shotput practice, then put in the hold, how long does it take to detect the fire compared to abused baggage in an overhead bin?

    1. collinsl Silver badge

      Re: Dilemma

      It's more that taking action on a fire in the hold is a lot harder/more damaging/more expensive than in a cabin.

      At least in a cabin a flight attendant can stick the battery in a bucket of water to try and suppress/pause the fire until the plane can land, in the hold it'll be fire extinguishers only which may not help if the battery is generating it's own combustible materials so doesn't rely on external oxygen etc. Plus releasing the fire extinguishers damages everything else in the hold to varying degrees.

  8. heyrick Silver badge
    Happy

    I used hibernate all the time with Windows, as it takes ages to get going and when it is going it is still doing stuff in the background for a while.

    Linux starts up a lot faster (Mint Cinnamon), and my usual come home routine is to press the power button then go flip the kettle on. Kettle hasn't even boiled when I heard the "burr bip" of a BBC Micro, which is my startup sound.

    Windows, on the other hand, tea's made and being drunk. And if it insists upon installing updates, well, time to fly to China to harvest my own tea leaves, ferment them, grind them up, stick them in bags, then raise a cow from a baby for the milk...okay, slight exaggeration but there's a reason I ditched Windows for good...

  9. Apocalypso - a cheery end to the world Bronze badge

    I must be a bear of little brain...

    > Hibernation can take a while. As the RFC says, on Anjum's machine it takes about 20 seconds. The proposed change is simple: it adds a mechanism to cancel the process by pressing the power button.

    Who is this change for?

    1) People who know that hibernation doesn't work on their machines but absent-mindedly hit the hibernate button anyway? Why not just disable it in the first place?

    2) People who don't know that their machine won't hibernate and restart properly? They won't be using the cancel option and when the restart fails they'll join group 1.

    3) People who do know that their machine hibernates properly, decide to hibernate but then have an "oh no" moment? Handy feature to have in reserve but not something that is going to be used daily.

    Am I missing something?

  10. This post has been deleted by its author

  11. This post has been deleted by its author

  12. SomeRandom1

    Optane

    Was this the sort of issue that the optane storage system would have solved? Admittedly my knowledge of orange is what I have briefly read as I never encountered it in person.

  13. A Non e-mouse Silver badge
    Holmes

    With the prevalence of laptop/mobile devices, I think non-working hibernation might just be one (of many!) reasons why Linux on the desktop hasn't quite taken off yet.

  14. This post has been deleted by its author

  15. This post has been deleted by its author

  16. ovation1357

    If only suspend to RAM actually worked :-(

    Regular comment readers will know that I have a bitter hatred of Microsoft and all its products - this extends to the latest generation of CPUs where MS appears to have used its monopolistic powers to bully lobby manufacturers to completely ditch hardware support for the 'S3' sleep state we knew as 'suspend to RAM' in favour of Microsoft's catchily named 'S0ix' a.k.a. 'Modern Standby'... This has the objective of making standby near-instant because, shocker, S0ix isn't really standby but instead pushes full responsibility onto the OS to pretend to sleep by suspending services and/or switching them in to power-saving modes.

    This means that the relatively stable and quick alternative to hibernating to disk is no longer available on modern hardware. All my previous Lenovo laptops have happily suspended to RAM multiple times per day for months on end (sometimes after a few initial teething issues), however now my Laptop (a P14s Gen4 with an AMD Ryzen 7 PRO 7840U) comes out of my bag ranging from feeling warm to the touch, to scalding hot and completely dead. I am lucky to see an uptime of more than 30 days before something causes the machine to overheat and drain the battery when I'm not using it.

    Rumour has it that this method of standby has caused a lot of pain and frustration for Windows users too, with many reporting similar issues of laptops cooking themselves whilst in standby. Certainly my latest corporate-issued Win 11 laptop seems to be begging for a charger every morning when I wake it up.

    After a lot of pain (and a fair bit of swearing) I managed to isolate Bluetooth as the main cause of my pain on Ubuntu, although disabling it also means I then can't use it, but lately I found out that if I suspended after using my built-in cellular modem then this will wake the machine up and cook it in my bag. Basically, anything could wake the laptop up at any time because it's really still awake.

    So the suggested alternative is hibernating to disk - great; except that I've since upgraded my RAM and have nowhere near enough swap space, plus hibernation is known to be problematic (not to mention fairly slow, and possibly still not ideal to be dumped onto NVMe/SSD storage) - At some point I'll get around to migrating to a bigger drive so I've at least got the option to try it.

    Yet again this seems to me like Microsoft abusing its dominant position to force everyone to do things its way - In the same way they tried to force a tablet/touch-centric UI onto all users, they now want to force a tablet/phone style 'standby' onto everybody, even though laptops/desktops are arguably running far more complex tasks without the constraint of everything being an app in a sandbox. Why did they have to push for the removal of legacy S3 standby!?

    Seriously, I don't mind nor care if they want to dabble with their own 'modern standby' implementation - good luck to them! But they should not be allowed to remove or break core hardware (and firmware) the ones relied upon by other users.

    Where will this end? We've already got dedicated Microsoft buttons on our keyboards (thankfully just Windows keys on mine and no 'co-pilot' button), enforced 'upgrades' to TPM v2.0 because of Windows 11 requirements, Secure Boot (which last time I read about it was controlled entirely by Microsoft - e.g. non-MS OSes need to obtain a certificate from MS if they want to use it).

    Back on topic - I can see the ability to cancel hibernation as being useful on those occasions when I put the machine to sleep and then remember something else I meant to do - this happens often. I'm just hoping that when I finally sort it out (which may also involve making a jump to Devuan Linux to rid myself of systemd) that hibernating to disk will work 100% of the time and won't take too long to sleep/resume.

  17. Jou (Mxyzptlk) Silver badge

    One of the things which work surprisingly good on Windows

    You hardware can still torped it my not following the rules or with wrong entries.. But apart from that: I have machine doing video compression and other lengthy jobs, many threads in parallel. They are set to hibernate or standby when there is not enough sun to do that for free. In the middle of encoding, 100% load on 16 (32 SMT) cores, while doing other things too. Nothing is stopped, just a "Suspend" or "Hibernate" signal, and it will do so. Machines get woken up via Wake-On-Lan. And this is not a laptop.

    Even more surprising: It still works with Windows 11 24h2 / Server 2025. Will it will work with 25h2? Might be a classical MS thing to break that next...

  18. DoctorPaul Bronze badge

    Recommendations?

    Hibernation is a must-have for me, can anyone recommend a distro that supports it? I found out to my cost that Mint doesn't.

    1. DoctorPaul Bronze badge

      Re: Recommendations?

      Genuine query, thanks for the downvote, care to explain?

  19. Rich 2 Silver badge

    Options

    I can’t believe I’m saying this but this looks like an area that MS actually got right. Yes. I know - I shall beat myself later with a knobbly stick

    So why not go down the same route in implement it in a singular way? Hibernation has worked on windows machines for the last goodness-knows many years - a long time

  20. Taliesinawen Bronze badge

    Linux Hibernation and Windows Fast Startup

    There can be a problem on dual boot systems. As there can be a conflict between Linux Hibernation and Windows Fast Startup. As Windows locks the partition and Linux writes to it could lead to file corruption. Sleep mode on a fast SSD works.

    A true hibernation should run from specially designed chips with variable clock rate. On no activity it switches to a low clock rate. On keyboard activity it switches to a full clock rate. Now that would be instant on.

    1. druck Silver badge

      Re: Linux Hibernation and Windows Fast Startup

      That's sleep not hibernate which powers down the RAM and other hardware.

  21. This post has been deleted by its author

  22. Dwarf Silver badge

    Insomnia

    Insomnia reaches Operating Systems.

    No sleep for the wicked.

POST COMMENT House rules

Not a member of The Register? Create a new account here.

  • Enter your comment

  • Add an icon

Anonymous cowards cannot choose their icon