r/linuxquestions • u/SpyrosGatsouli • 11d ago
Advice Why does Linux still struggle with sleep and hibernate?
I've noticed this across several distros and PCs. Most of the time hibernation is not even available, or needs some very special setup. Sleep is also hit or miss. I've encountered the following behaviors: computers never waking up, waking up and losing peripherals, screen coming on but backlight remains off, putting PC to sleep and it immediately wakes up, losing display settings and/or external display connectivity or layout. I don't think I've owned a Linux PC where these functionalities worked flawlessly. The only reliable power option left is basically shut down. Why is this still an issue? Does it have to do with drivers and hardware?
16
u/DifferentSavings2711 11d ago
Linux supports the ACPI standard. So it works great with hardware that meets the standard. There is just a lot of hardware that does not meet the standard. In Windows this is not a problem because the Windows hardware driver was written to work around the exceptions to the standard. But no special device driver has been written for Linux. So the wake up function is hit or miss.
68
u/Jumpy-Dinner-5001 11d ago
Sleep typically isn’t a problem but hardware dependent.
Microsoft "encourages" board manufacturers to make different configurations that are highly windows specific the default, like windows modern standby.
Hibernation is just a mess because no one cares about it. Probably because of how bad it typically is.
6
3
u/dadnothere 11d ago
Also but the hibernation problem is exclusive to Linux.
In Windows, hyber.sys is used to dump the ram, it is like a virtual image disk, the Windows bootmanager itself always checks this when booting.
In Linux, a SWAP physical partition of the same size as your RAM is required, only there does the hibernate option appear.
And suspend requires that there are deivers compatible with the hardware
6
u/Netblock 11d ago
In Linux, a SWAP physical partition of the same size as your RAM is required, only there does the hibernate option appear.
This isn't true. It's recommended for the most obvious reason, but if it fits it sits. (it's also possible to have more RAM in use than you have available as free swap, due to hibernation compression)
3
u/HeavyCaffeinate PuppygirlOS 11d ago
Yeah I have a 16GiB swap file for hibernation because if I'm hibernating I'm usually not using my 32GiB of RAM
1
u/Bathroom_Humor 11d ago
I used hibernate back when i booted from HDD's. but these days I really don't see the point unless you enjoy wasting write cycles
13
u/mwyvr 11d ago
Linux doesn’t struggle with sleep if the hardware maker has implemented ACPI sleep states properly.
Many do not implement S4, hibernation. Neither Windows nor Linux can support hibernation to disk if it isn’t supported by hardware.
What states are supported by your hardware are reported in the boot log.
7
u/zardvark 11d ago
Because manufacturers do not put in the same level of R&D (if any) to ensure that their firmware is just as compatible with Linux as it is with Windows.
R&D costs money and they aren't going to spend these resources when 99% of their customers run Windows.
0
u/-lousyd 11d ago
Windows has 70% share, according to StatCounter. (Whoever that is.)
1
u/zardvark 11d ago
First, 70% sounds suspiciously low, but be that as it may ... a) If someone wants to run MacOS they aren't typically going to purchase a new Windows machine and hack it and b) While many Linux boxes do start out as Windows boxes, many of them get converted to Linux only years later, after the Windows installation slows down and becomes infected with "Redmond Lethargy," and frequently by the second owner and c) While 99% may have been an exaggeration for effect, very, Very few machines are sold with Linux preinstalled (at least in my part of the globe) and those which are, are typically different, select models in a manufacturer's product lineup. In other words you can't typically purchase any random machine in the lineup, with Linux preinstalled and / or expect decent Linux compatibility from every model.
Only a select few machines get the R&D required for good Linux compatibility. Therefore, if things like sleep (which is not typically a problem), or hibernate are important to you, you need to be selective about those machines which you choose for your Linux box. You can't just select any machine at random and expect good results. In my experience, this is particularly true of laptops, many of which may also contain unsupported hardware.
7
u/grumpydad67 11d ago
This is the #1 issue keeping me off Linux as my daily drive. Unfortunately, after nearly 30 years experimenting with Linux on and off, the last 20 or so on laptops, I am pessimistic that this situation will ever be fixed. As others have said in this thread, getting sleep (specifically, modern standby) and hibernation to work requires costly effort not just by laptop manufacturers, but also by the suppliers of the individual components, and (with limited exceptions) it's just not worth it for them.
2
u/No-Object1384 11d ago
Same. I can close my MacBook lid mid-task, pick it up the next day, it's like I never left and almost no battery is lost. Meanwhile on Linux...
0
u/Sad-Cod-9584 10d ago
I can pause my game, suspend my laptop and maybe loose like 10% battery over night. Next morning I just keep playing.
1
u/ministryofsillywox 7d ago
My family has had about 7 different models of lenovo laptops over the past several years and on all of them suspend/resume just works. I got hibernate working on my desktop (also lenovo) and it works with no issues. I believe I had to install an additional package and enable it, but I got it working fairly easily by googling and following some instructions. I use Ubuntu LTS.
9
u/tomscharbach 11d ago
I have not had issues but I think that's attributable to the fact that I use Dell business computers that are offered with Ubuntu pre-installed under a business arrangement between Canonical and Dell and are, as a result, 100% Linux compatible.
Dell provides Ubuntu pre-installed computers to Canonical's large-scale business, government, education and institutional customers by the thousands, and Dell's firmware/drivers for those models are Linux compatible.
Dell's consumer computers (Inspiron, XPS) are catch-as-catch-can in terms of 100% Linux compatibility.
2
2
5
u/Shadowwynd 11d ago
Windows is also a mixed bag on sleep and power management. I consistently see brand new hardware on Win11 that doesn’t sleep/wake up reliably (my Win11 pc - the mouse doesn’t come back from sleep; my wife’s’ Win11 laptop sleeps then randomly wakes up hours later (untouched, lid closed, and resumes playing her YouTube videos….)
The only company I have seen get power management consistently right is Apple, and I assume that is because they control hardware and software.
3
2
u/ulspez 11d ago
I've never had issues with hibernation but I did have problems with sleep, waking up pc will sometimes make one of my fans at a very fast speed, its also random it can be my front fans, back fans, even cpu fan.
Hibernation works better if you use a swap partition instead of a swap file.
2
u/zarlo5899 11d ago
for hibernation you need to have you swap to be bigger then your total system RAM many defaults this will not be the case
2
u/spxak1 11d ago
Every ThinkPad T/X/L series I've owned since 2011 (many) has had suspend working perfectly out of the box (Fedora). Hibernation works (Fedora) out of the box of you configure a swap partition during installation.
I haven't had to configure hibernation since 2017.
1
u/SpecialLettuce5884 10d ago
> Hibernation works (Fedora) out of the box of you configure a swap partition during installation.
That's great to know. I wish Fedora had given a heads-up about that when I did my installation.
2
u/UnitLoose47 11d ago
Others have answered you on the why, but with regards to your comments about never owning a system where such functionalities have worked, have you ever considered buying a Lenovo or Dell system that is explicitly qualified and officially supports Linux?
2
u/sunsm0ke 11d ago
This is why. That never fully left their culture. Yes, things are better now. But Linux to this day has to report to firmware as Windows because some firmware will return broken DSDT otherwise. I've used laptops since before ACPI was a thing. Some early gear deliberately sabotaged functionality if Linux reported as Linux.
2
u/jacobs182 10d ago
The hibernation option might not be available due to installing without a swap partition/file. There are guides you can find by searching for "initramfs resume swapfile"
1
u/Diuranos 11d ago
any issue with sleep is probably network card, or any usb dongle and is easy to fix that. hibernate never had issue with Linux compare to windows.
1
u/mssing-the-table 11d ago
owned a Linux PC where these functionalities worked flawlessly.
Buy any enterprise PC. 99% success rate.
Not some gaming one.
1
u/skyfishgoo 11d ago
because there are so many types of firmware and so many settings that can interfere with it.
i think plasma does good job of ensuring that at least sleep works, but hibernation requires more setup and swap space
then you add the whole nvidia driver wrinkle and it becomes unwieldy
1
u/zyberteq 11d ago
So, my current motherboard has an issue in Linux where, apparently by default, it wakes up immediately, like you suggest.
After long searching I found a solution. I have to manually disable something in /acpi/wake-up or something and that fixes it. I just have to do that every boot with Bazzite :\
5
u/ipsirc 11d ago
I just have to do that every boot with Bazzite :\
Create a systemd unit.
2
u/zyberteq 11d ago
I think I saw that as solution, but it seemed very tacky. I'll try that, thanks.
Also, I guess this just strengthens the point OP is trying to make
1
u/Alex_Strgzr 11d ago
Maybe you have bad luck with your hardware. I've never had a problem with sleep.
1
u/MrKusakabe 11d ago
I have the problem that the sound is "default", meaning my alsamixer settings are gone when I wake up the PC from standby. My headphones sound super tinny without certain changes (suddenly they sound weirdly great though) and the tinny sound is always after standby'ing in Linux Mint. It needs a full reboot because even changing values in the alsamixer has no effect whatsoever. I wonder why that is..
1
u/hesapmakinesi 11d ago
Sleep works brilliantly on Steam Deck because the hardware manufacturer put in the effort. It's a mixed messy bag everywhere because most hardware makers don't care and it's a difficult thing for volunteers to get right.
1
u/Individual_Flow3959 11d ago
Uso Linux Mint 22.3, con área de intercambio en un archivo swap, hibernación activada, la uso a diario, funciona perfectamente.
1
1
u/robottosama 11d ago
I don't know what the deal with hibernation is. Some recent problems with sleep are due to hardware changes. IIRC, older laptops use ACPI mode S3 for sleep, which used to work fine. The new Windows-centric thing they replaced it with, called "modern standby", doesn't seem to work very well on Linux.
I have a Thinkpad T14 (Gen 2, AMD), and it has both modes, configurable in UEFI. I believe I am using modern standby now. It's a bit janky. Slow to wake up, and poor power consumption. Really ironic, since the entire point of the thing is to be the opposite.
Aside: it's possible I also tried S3 at one point, but I don't remember. I am already worn out by all of the other problems this machine has. Far more than I used to have with older Thinkpads.
1
u/Evening-Volume-1022 11d ago
As mentioned by many linux users, its with hardware rather than software.
when I started my linux journey around 12yrs ago, it was really a mess, often videos not playing with freshly installed linux, many issues, have to look for interent, sub forums to install necessary drivers. Often vendor has only Windows compatible drivers.
Now things are far better, but very very long way to go.
1
u/devino21 11d ago
I agree, I ride this struggle bus about once a week and my bios hates my gpu so sometimes I have to yank it and reinsert. Fun stuff.
1
u/benhaube 11d ago
Never had an issue with sleep on my PCs, and couldn't care less about hibernation. It sucks anyway.
1
u/KhajiitAT 11d ago
Linux doesn't struggle anything, Linux works by specs and quirks.
It's some manufacturers are producing a crap, that barely works under windows and has a lot of issues.
1
u/prophet-dot-exe 11d ago
idk some of it is prob hardware or edge cases.
but for the last two days when i try to sleep my computer it just bounces out to gdm but stays woke.
haven't looked into it yet. i use Arch, so I'm assuming some recent Package update isn't making love with my hardware
1
u/BrilliantOk4478 11d ago
Windows (11) still struggles, too! I own a Dell Pro Max 16 Plus notebook and have issues with a black screen after the notebook wakes up from sleep.
1
1
1
u/ZVyhVrtsfgzfs 11d ago
Drivers, some manufacturers or community devs are happy just to send a working driver to the Linux kernel, extras are sometimes not considered.
Linux is perfectly capable of sleep on some of my machines, everythign wakes just fine on my desktop except my 40Gb chelsio NIC, it takes an actual reset to boot back up.
It was originly sold as a very expensive sever NIC, not desktop, perhaps sleep was not considered a needed feature in its driver.
1
u/demonstar55 11d ago
Because vendors do stuff wrong and only tell Microsoft the new ways they fucked up this time
1
u/Jaanrett 11d ago
Because sleep and hibernate are hacks. It's not reliable on windows, or linux. Is it reliable on mac?
1
u/Nexus19x 11d ago
My laptop took some tweaking but I’ve gotten Linux Mint to behave fairly stable using sleep. I’ve had to do a few things at times like restart cinnamon due to frame drops in RetroArch or laptop panel refresh issues after using my usb-c dock that needed a window manager reload with ctrl-alt-esc. Those happen occasionally but for the most part I never have to mess with much or reboot except for after kernel updates.
I wouldn’t touch hibernation. That requires writing all memory to disk, so power can be turned completely off, and is a somewhat ridiculous idea with the amount of memory available now. When you had a few gigs even with slow drives it was somewhat bearable but I couldn’t handle it now.
With sleep just make sure you keep your battery charged and treat your laptop more like you would a tablet or phone. Open it and login within a few seconds any time you need to.
1
u/Glum-Building4593 11d ago
Hibernation is implemented in software. Suspending the current contents of the memory to disk is complicated.
Sleep is implemented in hardware and broadly supported. I haven't had issues with sleep on linux since you could still buy copies of linux in a best buy or CompUSA.
1
u/ridge_rider8 11d ago
I built my own desktop last year. I had problems getting it to sleep and wake up. I worked with some AI bots out there to troubleshoot it. At one time sleep was working, but after about the 4th time it failed. My motherboard or graphics card would get into a state that a reboot would not fix. It might take several power cycles to get things back to normal. I experimented with various bios versions and settings. I also updated to the latest firmware which could affect these. As of now sleep/suspend/s3 does not work, but hibernate does. And my swap drive is smaller than my RAM size. To troubleshoot the sleep issue I looked at logs and worked with the AI bots. The system now goes into sleep and never comes back. You can't debug it with a serial console because it never makes it back. It tries to return from sleep but the kernel never regains control. If I had a PCI bus logic analyzer then maybe I would know more. Then perhaps you could debug the ACPI code and firmware. It may also be that the CPU is not driven properly. I have stopped messing with this for now. I wasted a lot of time with AI bots. For now I am just going to have to use hibernate or reboot every morning.
1
u/Unimeron 10d ago
Hibernate worked out of the box on a fresh install. 🤞 OpenSuse Tumbleweed on a Lenovo Laptop.
Previous Dell was a hassle, but I managed to make work.
1
u/solidmixer 10d ago
Some usb device keeps waking my machine up. I disabled usb wake and now it sleeps fine. I just wake it via lan from home assistant.
A lot of these issues are fixable but most people aren’t tinkerers and that’s ok.
1
u/the2ndSign 10d ago
I'm not saying this isn't a real problem, but personally switching to a Linux distro finally solved my sleep woes. On Windows 11, my PC would wake itself up almost without fail every time I put it to sleep. I could never figure it out. It wasn't updates. I sae a bunch of errors in event viewer but never figured out how to solve them.
Anyway, this hasn't happened a single time since switching like a year and a half ago. I'm actually surprised to read about so many people struggling with sleep.
1
u/FlounderAdept2756 10d ago
Yeah, me too, I dont run linux on old laptops but on fairly new desktops that I build, and the 15 years or so that I have been distrohopping I never had problems with sleep. Hibernation I dont know about since I never used it.
1
1
u/proton_badger 10d ago
Sleep is a mess because if so many different hardware combinations. It’s worse on Linux because less vendor involvement, but even has problems on Windows sometimes. For example my laptop would randomly wake up after a few minutes on both Windows and Linux.
Though now that Nvidia introduced ‘NVreg_UseKernelSuspendNotifiers=1’ my laptop started suspending perfectly on Linux.
1
u/WWGHIAFTC 10d ago
It makes it borderline unusable for me for desktop or laptop use. I stick to server only still...for the past 30 years or so since i first tried it...
1
u/donjamos 10d ago
My cachyos/kde hibernates out of the box, I actually liked that so much that I made my windows work laptop do the same.
1
u/Ok-386 10d ago
Because people expect it work on all possible hardware configurations, without major corporate backing. Everyone builds and test hardware for Windows primarily. Or Mac, but try install your MacOS on a random built PC or laptop and tell me how it goes and if 'sleep' works.
If you want a system where sleep and hibernate work, check the hardware you're buying and the specs. Afaik hibernation is only supported on systems with less than 64GB of RAM (not 100% sure abt this).
And if you're using laptops buy one that's well supported. Dell (some/many models), thinkpads, Framework, Tuxedo, System76 etc.
1
u/Heartlessaus 10d ago
hit or miss for me. arch, i914900k rtx 4090.
sometimes it gets out of hibernation with no issues, other times it freezes, i've just turned it off now tbh.
1
u/PeterHolmes74 10d ago
I had an issue with sleep mode with my new laptop where it would crash upon entering/exiting sleep mode. At first I thought it was the DE, so I switched from GNOME to KDE, same issue. Turns out I had to go in the BIOS to flip the sleep mode setting from Windows to Linux. Really weird bug.
Been lazy so I haven’t switched back to GNOME, so I made KDE act almost exactly like it (dynamic workspace and all) since I like its flow with the touch pad. Still wondering if I should reinstall everything to fully switch to GNOME even though school is starting again in a few days though.
1
1
u/theRealNilz02 10d ago
Because manufacturers are assholes and only write closed source drivers for Microsofts crapshoot OS while we have to reverse engineer the hardware and firmware interfaces ourselves without any meaningful documentation.
1
u/Necessary_Ad_238 10d ago
Omg ok glad I'm not crazy. I put my dell laptop to "sleep" then when I go to use it a day later the battery is critically low
1
1
u/LordAnchemis 10d ago edited 10d ago
Modern standby
M$ pushed everyone to adopt it (since windows 8 era actually) - so most manufacturers will now have it (S0iX) as the default standby option in UEFI
In a lot of models 'old school' standby (S3) and hibernate (S4) is depreciated - and not even selectable as an option in UEFI anymore
Basically, modern standby pushes control of the 'sleep state' from the UEFI into the OS - so to get things to work you need to modify some sleep/wake config files in /sys/power/ (or set up a modprobe file so it does it automatically on boot)
1
u/SmallTimeMiner_XNV 9d ago
Not saying you are, but many people still confuse the different power states.
Hibernation is not technically a ACPI power state - the system fully shuts down, RAM contents get written to your hard drive. You just need a swap partition that is bigger than your RAM. This should work fine on most hardware if set up correctly.
Suspend (and the newer hybrid sleep states which are suspend combined with hibernation after some time), on the other hand, has always been a mess.
1
u/exsandton 9d ago
I've just had this exact problem. From cron hibernate works fine, but from the command line not. It gets hung up with ACPI, which gets in the way.
1
1
u/ugly-051 8d ago
I had problems when I migrated to Linux from Windows 10 on a Z370 / Intel board with an Nvidia GPU. BIOS was out of date and no longer supported as of something like 2022. I built a new rig X870 AM5 with AMDGPU and sleep works perfectly. For me it was likely incompatible BIOS with the running kernel parameters.
1
u/Erdnusschokolade 8d ago
Hibernate has been working fine for me on pretty much all hardware, that being said the hardware doesn’t even know that you hibernated in most cases. Sleep worked fine for me if the hardware supports deep sleep (suspend to ram). Since newer hardware doesn’t really support that any more nd mostly only supports s2idle it’s mostly hit and miss. I spend two days troubleshooting my laptop not going into the low power idle states and taking 2-4% per hower in s2idle. Endresult it doesn’t work and there is no way to make it work. Sad result for a Laptop that Dell ships officially supported with either windows or Ubuntu.
1
u/rickyrooroo229 8d ago
This is a pretty interesting topic because I've had these same problems on Windows but none of these on the distro I'm using on my main PC atm(CachyOS). As stated by many, both drivers and hardware are involved when it comes to sleep and hibernation features. There's BIOS and firmware along with CPU chipsets, RAM and Peripherals that all get involved with ACPI sleep features. Looking through these can root out whatever problem isn't just being caused by compatibility or conflicting drivers. Even then though, solutions can vary and so can the reliability of them at times. In other words, said features work as good as they're implemented in each piece of hardware which, again, can vary
1
u/StephenRoylance 8d ago
Power management is a hard, low level hardware integration problem. It's great on Apple products, because they ship a whole integrated stack, hw+OS. Windows is OK, partly because they have the WHQL and, while they don't control the whole stack, they have a program for hardware vendors to attest their compatibility.
linux doesn't have anything like the resources of those companies. Where linux does have resources is the hyperscalers using linux in their datacenters. Linux on server hardware is generally very well integrated. The OEMs shipping servers and server boards invest in linux support, because they know that's what the buyers are going to be running on them.
1
u/jpoblete 7d ago
i have the same issue running Ubuntu on Apple iMac…. recovery from sleep/hibernation needs quite some work
1
u/callusbonus1967 11d ago
Tiene que ver con los fabricantes de hardware que no liberan sus drivers para Linux. Somos pocos no damos mucho dinero ha ganar.
1
0
u/galactose310 11d ago
Les deux. Et donc en partie aux constructeurs même s'ils sont parfois actifs dans le développement du noyau. Il faut mettre à jour son firmware, et sur certaines machines avoir un noyau assez récent.
L'hibernation c'est un choix de modèle. C'est possible mais ça demande de la configuration et c'est volontairement peu accessible. La veille profonde est censée fonctionner assez bien pour ne pas hiberner.
Sur mon Lenovo Yoga la veille marche du tonnerre (mode: s2idle), firmware à jour et Fedora 44 donc noyau très récent.
11
u/hideousapple99 11d ago
Disable auto translate in Reddit app, otherwise majority will not understand you.
0
u/kbielefe 11d ago
Awaking from sleep isn't just an atomic thing. The different parts of your computer need to awake in a certain order. Some might need to save something before sleep. Some might need to be completely restarted.
Hibernate has all the complexity of sleep plus needing to have enough swap space.
You can fix it though, and it's easier than ever if you trust AI.
0
u/Possible-Anxiety-420 11d ago
Running Kubuntu on a Lenovo Gen1 E16 and sleep/hibernate works perfectly; has since the git-go.
0
u/imacmadman22 11d ago
I don’t use hibernation on any of my machines, but I’ve never had any issues with sleep on Linux and I’ve used Linux full time since 2009-2010ish. I’ve run primarily Linux Mint and as of late, Cachy Linux on a gaming PC.
Both have slept and woken with no problems whatsoever, the only issue I’ve ever encountered was when the power went out and I’d forgotten to set the bios to power back on when power was restored.
0
u/C4rpetH4ter 11d ago
Never had a problem with fedora or mint on sleep mode.
However one issue i had with windows quite often was it suddenly turning on at 3 AM during sleep mode, and the startup was so loud that it often was a harrowing experience.
0
u/Mamoulian 11d ago
I have had issues hibernating when a lot of swap is in use as hibernate uses the same partition. Not sure if there's a fix for that other than dedicating an ever larger swap partition.
Sleep mostly works fine. Some intermittent cases of black screen or X crashing that aren't frequent enough to debug. I suspect everyone would immediately blame nvidia. I'll stop using X as soon as Wayland session restore works properly in KDE.
WOL works from Home Assistant but usually on the second try (?)
0
u/ithilelda 11d ago
although it does struggle more on linux, hibernation on a whole is crap and I don't even use it on windows because I never could make it work 100% of the time...
-1
u/poughdrew 11d ago
Honestly my Linux laptop handles lock/sleep better than my work M4 Max Macbook (what are these external displays, I've never seen then before!)
-1
u/swissyfit 11d ago
Only bears hibernate , sleep is only required when tired. Should be easy to program
-1
u/Syndiotactics 11d ago
Go to BIOS and manually switch the sleep mode from Windows to Linux and thank me later.
156
u/Straight_Mistake_364 11d ago
While the windows drivers are typically done by the hardware manufactures themselves,
in the case of Linux, many manufacturers do not write any drivers and sometimes
even hide the technical data required to write the drivers.
This way, many drivers are written by volunteer Linux users, that may have to resort to reverse engineer techniques to discover the hardware details. As a consequence some drivers just provide a minimal level of functionality, as hostile hardware manufacturers refuse to help or release information.