39 ms·
Why does Linux have so much trouble sleeping and waking?
Been running Linux for years and one thing that has always been frustrating is finding my laptops have either woken themselves up, or won't go to sleep.
The majority of time they do work as expected, but maybe 20% of the time they don't, is there a logical explanation for this?
I've had Macs and PCs which don't seem to suffer from the same issue.
- PaulHoule 6y agoWindows was that way back in 2000. Some android tablets are like that too.
- mattmanser 6y agoWindows still does sometimes. I've had two different windows 10 machines constantly wake themselves up (one was at at 1am!) regular as clockwork because a scheduled task you couldn't turn off had gone bonkers. My laptop still has problems with a .NET "optimization" task you can't remove that basically thrashes the disk constantly erroring for x86 assemblies I don't even use. I ended up replacing the program with an empty one, but every year or two it restores the broken program. I know it's back when my fan starts trying to take off like an aeroplane. I tried figuring out which .NET assembly was causing the problem, but in the end it was easier to just replace the offending program. The most annoying part of that process is that you can actually remove the task, but windows would then see it was missing within a few days and add it back.
- INTPenis 6y agoI've been lucky with Thinkpads. Have you been using Thinkpads? I know what you mean, it hasn't all been roses. But in general I have no major gripes with my latest Thinkpad laptops. Lately it's been amazing actually, on a Thinkpad X1 Yoga 4th gen with Fedora 31 atm. I can't remember the last issue I had.
- meibo 6y agoMy 2013 thinkpad on Ubuntu 20 with newest drivers doesn't wake up 1 in 5 tries. It's frustrating, but at least now that I don't have to leave my house anymore, it doesn't matter too much!
- WillYouFinish 6y agoI have this issue with my T470. I'd love to use some Linux distribution, but not waking up brought me back to Windows. A temporary solution was just keeping it on, which used up about 13% of the battery per night, but that's not a long term solution.
- qz2 6y agomy T440, T470 and T495s all do the same thing. Nightmare. I use a mac mini most of the time now though.
- est31 6y agoThe first wakeup issue I had was on a T495... but a software upgrade fixed it thankfully. Now another software upgrade broke my desktop's waking up which has been working fine for 4 years...
- war1025 6y agoMy Thinkpad is the only computer I've ever had hibernate issues with. At some point three or four years ago there was an article I saw where someone realized the way Linux handled memory layout during hibernate was way over complicated and they redid it much more simply. Ever since then I haven't had any issues with hibernate, either on my Thinkpad or my multiple Dell machines. I did have a fun regression recently where my ~10 year old desktop machine started randomly hanging and it seems to be a regression of some sort in the nouveau drivers since reverting to a previous kernel version fixed the issue.
- alwaysontime 6y agoI use a Lenovo X1 Gen 3 with Fedora 33, and have always had issues with lid close sleep/wake/hibernate. I needed to use this UPower workaround (https://www.ctrl.blog/entry/linux-laptop-low-battery-suspend.html https://www.ctrl.blog/entry/linux-laptop-low-battery-suspend...) to get it to work halfway decently, and it is still problematic.
- mushufasa 6y agoI've always assumed this is more a factor of installing linux "aftermarket" versus the manufacturer able to be careful about the bios+os interop, rather than anything with the OS itself. I imagine hackintoshes are similar. AFAIK linux-only distributors like System76 don't have this problem.
- skykooler 6y agoIn my experience, hackintoshes sleep/wake much more quickly than Linux, even on the same hardware.
- yjftsjthsd-h 6y ago> AFAIK linux-only distributors like System76 don't have this problem. Doesn't need to be linux-only, just well supported. My Dells and Thinkpads don't give be any trouble.
- mlonkibjuyhv 6y agoMy XPS13 9360 or similar has given me a few issues over the years: Occasionally not sleeping, inability to wake WiFi-circuit from low-power mode, sometimes the touchpad would freak out - I think it would latch a multitouch state pressed down.
- wpietri 6y agoWhich hardware are you using? My assorted Thinkpads haven't had that trouble in quite a while. (Although the sleep/wake stuff definitely seems janky to me in terms of UI behavior.)
- tonyarkles 6y agoNot the OP, but I've got an older W530, and it's a very careful dance for me with sleep and power. If I'm using it at a desk, I have to unplug the power, wait a few seconds, and then close the lid. If I close the lid and then unplug the power, the power change event seems to wake the system back up and I'll find it hot with a dead battery in my backpack when I get to my destination. Running Ubuntu 18.04. When I finally get around to the 20.04 upgrade I'll test it again and see if it's fixed, but I have my doubts.
- vvillena 6y agoI have a T495 with a Ryzen processor running Arch that has some issues waking up (maybe once or twice a month). Sometimes it refuses to wake up, and sometimes it wakes up but CPU clock speed gets stuck at minimum frequency, making the laptop extremely sluggish until the next reboot. I also have a Legion Y520 that has been working perfectly for the past two years, so for me, the answer is that it indeed varies from laptop to laptop.
- steviedotboston 6y agoDrivers. The way laptops sleep and wake is pretty unique to each type of computer, and many manufacturers don't care about Linux support so kernel developers are left to figure it out on their own. I haven't used Linux on a desktop/laptop in a decade so it's sad to hear that things are still the same.
- kreetx 6y agoE.g on my 2015 macbook pro I need to remove and re-add the wifi driver module to make it connect.
- Klonoar 6y ago...what? The 2015's were incredibly solid machines, I've never heard of an issue like this happening. I still daily my 2015MBP and the thing is an absolute tank where everything just works. I would literally bet money that your issue is hardware, not software. Edit: I realize now that this comment could be referring to running Linux on a 2015 MBP, in which case I'm a moron and we can just disregard my comment.
- kreetx 6y agoYeah, it's Linux. :) macOS always ran nicely, and the hardware itself is great. I think if somebody more capable in Linux kernel/drivers' hacking looked into it they could fix it, it's just that nobody cares (and `rmmod brcmfmac && modprobe brcmfmac` is simple enough).
- pwg 6y agoThis ... If the OP does some internet research into this topic they will find articles detailing how almost all [1] non-apple laptop makers build to a single target: ms-windows. They also test against a single target: ms-windows. If it works there, they are done. Linux compatibility is not even an afterthought. And as each makers various models all seem to also have slightly different ways to perform sleep/hibernate and subsequent wakeup, the result is that Linux kernel dev's are playing a continuous game of catch-up. One thing I've found is that upgrading the kernel to a later release sometimes fixes the issues (assuming patches were supplied by someone in the interim to fix them). [1] Very few makers have any laptops that ship, from the maker, with Linux preinstalled, the few that do (one or two Dell models, the aftermarket "Linux Laptop" vendors, maybe a sliver of others) will more than likely work properly for sleep/wake. The reason why these work better is because the maker should, in theory, test for Linux compatibility and help fix any bugs (or simply build with compatible chipsets from the outset) since they are selling these with "Linux pre-loaded".
- cashewchoo 6y agoMy last 2 laptops: T440s and an XPS 13 (9310) have both not had this issue, and that accounts for about the last 6 years of linux laptop usage for me. Several crummy laptops (the 300-700 dollar range at best buy) prior to that have had it, though.
- MrOwen 6y agoI have a similar experience with T4xx laptops. I think most likely answer is every engineer at Red Hat is given a thinkpad T or P series so I figure plenty of them contributed fixes for sleep, power, etc. Dell obviously has Linux certified laptops so I'm sure it's a similar story.
- peatmoss 6y agoAs a widespread counterpoint, look at Chrome OS. I’ve never seen any ChromeBook, clear back to the very first CR-48 ever fail on this. That said, I have a work laptop (HP Elitebook G5) running Ubuntu that wakes and sleeps perfectly. Same situation with Ubuntu on my desktop PC.
- toyg 6y agoIt's easy to make things work when you control both hardware and software.
- chungus_khan 6y agoWhich is also the Apple approach. Mac OS is pretty terrible at sleep and wake on non-Apple hardware, but of course it is, Apple doesn't test against hardware they don't support. In both cases it isn't anything wrong with the Linux or Darwin kernels, it's inconsistent implementations and little manufacturer care.
- sgt 6y agoWhy would Chrome OS be considered an alternative to Linux? The only thing in common seems to be the kernel running somewhere under the hood.
- mikelward 6y agoLast I knew, they did not support hibernate. I understand it's not quite the same thing, but it means you either need to turn it off, or charge it every week, even if you're not using it.
- lbhdc 6y agoI have experienced this on desktops that I have built. I haven't had this problem on my laptops in a while though. I am running stock Fedora on thinkpads for my past few laptops, and hardware support has been great. I haven't experienced the same hardware issues that I did on my desktop.
- sheepdestroyer 6y agoUse a thinkpad and avoid problems
- nichch 6y agoActually, my T480 on Ubuntu 20.04 drains battery drastically while “sleeping”. I believe it isn’t hitting S3, but I haven’t done too much troubleshooting.
- jusssi 6y agoI had some success with T480 sleep battery drain by finding a bios option to turn off all USB when sleeping. Went from empty overnight to can sleep over weekend.
- nichch 6y agoJust tried it and it made no change, thank you for the tip anyway!
- jusssi 6y agoYeah. All the PM stuff with Ubuntu and T480 was a bit of a disaster, there was issues at least with Thunderbolt and NVIDIA discrete graphics eating up the battery. IIRC in the end I think I just found a way to completely disable both. The T480 I had was a company laptop and I don't have it anymore, so I can't check.
- nichch 6y agoWhat's your daily driver now, if I may ask? I was seriously considering the T14, but the M1 Air is tempting me.
- jusssi 6y agoI now have a P14s, as a weird compromise between what I wanted (14", under 2kg), company requirements for the size class (Lenovo with Intel i7 or i9 and NVIDIA discrete graphics), and what the supplier had available with short notice. Given free choice, I'd probably got a T495 or T14 with AMD. Mostly the P14s feels the same as the T480 did. I have none but the usual complaints (+ too new hardware so drivers are still a bit flaky), though I think the underpowered discrete graphics is a waste of money at least for my use.
- ruste 6y agoI've spent the last decade exclusively on lower-end and more obscure linux laptops. Haven't had a single issue. I'm probably the exception that proves the rule though. I've found that most of the time it's not a linux / kernel issue, it's a udev or config issue. If you write 'mem' to the right file in /proc or /sys (I forget which) they just go to sleep. Any acpi event will wake them back up. I've done this with all sorts of custom kernel configurations on older chromebooks and cheap chinese laptops. Never had an issue. Sleeping to memory works great. Sleeping to disk or 'hybernate' is another story though. You need swap properly configured for that and it's finicky.
- londons_explore 6y agoSleep/wake/hibernate isn't a feature servers, home routers, or a whole host of other Linux powered commercial devices use. That means it doesn't get much attention from Linux kernel developers. In turn, the implementation is rather poor. For example, it is impossible to suspend any machine while any ssh directory is mounted. It's been a bug for 10+ years. The bug is architectural and pretty much impossible to fix (Any file or directory read hangs on the SSH connection, and a process can't be paused for hibernation while a non-restartable syscall is running.) While this kind of architectural bug exists, Linux hibernation will never be good. Fixing that bug properly is probably $500k worth of developer resources. Nobody wants to pay.
- halz 6y ago'Cloud-space' seem to be making use of hibernate to some acclaim (e.g. https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Hibernate.html https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Hibernat...)
- idoubtit 6y agoAre you sure this bug was not resolved long ago? My laptop auto-mounts a sshfs directory at startup and hibernates with no problem. On resume, the sshfs mount still responds. Having an open shell on that directory is no problem, except that I can't manually unmount a FS being accessed. I remember configuring this when this Debian Testing laptop switched to systemd, years ago.
- kasabali 6y agoNot by a long shot. Simply being mounted isn't a problem. A syscall needs to be hung on a network request. I regularly hit this issue. Most recent one was last year on 4.19 kernel when using NFS mount. I found the bug report for that one and they said it was fixed in 5.1 or similar. Beware they were talking about that particular bug. Because as the parent comment says it is architectural issue that can't just be "fixed". It's a whack-a-mole. Developers need to be careful on all the call sites to avoid it. FUSE, NFS, CIFS code is all susceptible to it (and to my horror I've bitten by every single one of them several times in the past).
- inetknght 6y agoI've always found it to be a software problem. There's a lot of software that inhibits the computer from sleeping. I use Synergy to use a single keyboard/mouse across multiple computers. It also seems to completely inhibit sleep in whatever computer is running a client. Then there's shit like Discord or Firefox or Steam. Any time you run a full screen app or play music, the OS seems to think "oh hey you're playing a game" and then inhibits sleep.
- yetihehe 6y agoMy HP laptop with windows and other desktop with windows both have BIG troubles with waking up. Typically after I accidentally put them to sleep, I have to somehow restart them, otherwise they wake up to black screen. For me, sleeping in windows never worked right, I'm always disabling it on new installs.
- rescbr 6y agoMainly driver issues. I have once solved AMDGPU not waking up from hibernation just by compiling the driver into the kernel. The AMDGPU modules weren't loading somehow and even after spending some time, I couldn't fully debug the issue, as I'm missing an USB debug cable, the hardware didn't had Intel AMT serial over LAN and it lacked a real serial port.
- segfaultbuserr 6y ago> as I'm missing an USB debug cable, the hardware didn't had Intel AMT serial over LAN and it lacked a real serial port. You can try netconsole, a debug console over UDP/IP, implemented within the Linux kernel at a very low-level. It can keep sending logs over the network even if a kernel panic has occurred. If both netconsole and the Ethernet driver is built into the kernel, it's almost a serial-port substitute, a really handy debug tool for all kinds of black-screen-of-death issues. To debug an issue like that, I prefer connecting my workstation directly to the target (without routers and switches) and assign a static IP address on both ends. Netconsole for kernel space, SSH for userspace. The only thing it cannot do is collecting logs from the very earlyboot process. "The AMDGPU modules weren't loading" may or may not be an earlyboot problem, just try and see if you are lucky enough. https://www.kernel.org/doc/html/latest/networking/netconsole.html https://www.kernel.org/doc/html/latest/networking/netconsole...
- rescbr 6y agoI have tried netconsole, but the kernel froze right after PM restored memory from swap. IIRC it wasn't sending logs to my target machine at this boot stage, and I couldn't even get a flash of a kernel panic message to record it in slow motion on my phone. That's why I think only an USB debugger cable could help in this case. And to be fair, I'm just guessing the modules weren't loading, after they got compiled in, everything worked like a charm. Didn't debug it further, as this happened in the beginning of the pandemic and finding an USB cable not shipping from China, with reasonable costs, was impossible.
- segfaultbuserr 6y ago
- AshamedCaptain 6y agoWhy do people still use sleep? The lowest power saving modes are basically so great these days I can at least a couple of days out of them without any configuration whatsoever... On Windows many newer laptops don't even use actual "sleep" modes but rather simulate them with lower power active modes. Linux' problems with traditional sleep modes are only going to get worse as a consequence since manufacturers are going to abandon them. I'd stop using them ASAP.
- sandworm101 6y agoYes. The core reason that linux is horrible in this area is that so few people care about sleep functionality. Sleep was developed when turning on/off a windows computer took minutes (boot, antivirus self-scan, updates to xyz, reboot, scan again etc). A modern linux machine boots in seconds. So the usefulness of sleep/hibernate modes on desktops/laptops has shrunk.
- NikolaeVarius 6y agoI dislike having to enter my extremely long decryption password every time I boot. Also, I have no idea how your computer boots in seconds. POST to UEFI is at least 3-5 seconds. Than I have to wait about 5-10 ish seconds after I type my password to decrypt my drive. Than it gets to OS selection screen which takes 3-5 seconds. Then it has to load all services after boot which takes about another 5-10 seconds before things get into a vaguely usable state. This versus 2 seconds to wake.
- sandworm101 6y ago10+10+5=35 seconds, not minutes. As i said, sleep was developed when boot took minutes. So the motivation for this feature has been greatly diminished and is now less of a priority in the linux community.
- NikolaeVarius 6y agoI don't believe you. This is a community that recompiles kernels for imaginary performance increases. Who would forgo practical increases in speed. And when someone says "seconds" the implication is that its at max around 5-9 seconds. I would be pretty pissed if a application that took "seconds" to boot actually took 59 seconds.
- cat199 6y agoas someone who also dealt with this and finally decided to just support a linux vendor (system76), i'm glad i did - the extra $$ is worthwhile & it feels much better knowing I supported an open-source friendly company
- wyldfire 6y agoI've had a couple of Dell XPS13 models over the past ~6 years. Linux on XPS13 for the most part 'just works'. Dell does ship a configuration of XPS13 with Ubuntu, and that's likely the biggest factor in its success. Plus: it's an attractive design, tiny bezels, super light.
- pxeboot 6y agoSleep/wake has been 100% perfect on my X1 Carbon running Linux. Not a single issue since I got the device over a year ago. Battery drain is higher during sleep than a Mac though.
- alwaysontime 6y agoWhat distro are you running? What are your UPower settings?
- smagoun 6y agoOEMs perform rigorous stress-test cycles during development. For example they might require a machine to suspend+resume 1000 times in a row. This shakes out both OS + driver issues before they go to market. This level of rigor is important to avoid support calls + RMAs, which are expensive for the OEM. Many Linux drivers can't pass this level of rigor. Back when I used to care about this professionally (before 2014), video + wifi drivers were some of the worst culprits. Each variant of each chipset would need its own driver, and often those drivers needed tweaks for stability. Firmware implementations are (were?) also built + tested exclusively for Windows, and Linux is different enough that it can trigger untested/broken code paths or otherwise cause firmware to misbehave. Linux also has its own set of issues with ACPI + UEFI. Canonical, RedHat, etc have teams dedicated to enablement and testing for OEMs like Dell that ship computers with Linux. Back when I was involved, Canonical had 60+ people dedicated to this, and qualified hundreds of SKUs each year. Even then they don't cover all hardware. The fixes+workarounds those teams produce also take time to make their way upstream.
- segfaultbuserr 6y ago> Why does Linux have so much trouble sleeping and waking? To successfully suspend and resume a laptop, BIOS/UEFI and all drivers in the system, e.g. GPU, network, audio, USB, must have perfectly working power management code, a single bug in a driver is enough to prevent the entire system from sleeping. > [...] I've had Macs and PCs which don't seem to suffer from the same issue. Macs and PCs are fully tested by the vendor with all driver issues fixed before they are shipped - if they can't wake up, it's vendor's problem. On the other hand, if a laptop does not offer explicit Linux support, they are not tested at all. Linux developers are left on their own to figure it out. Worse, for some types of hardware, documentation is often lacking or nonexistent (OEMs have internal support from all device vendors). By saying "on their own", I really mean it - I've personally diagnosed and fixed a driver issue in the Linux kernel for my laptop, despite not being a kernel developer. If you have a popular machine, someone else will eventually fix it. But if you have an unique machine, sometimes there's really nobody that would do it for you. By far, the most notorious suspended/wakeup problem I've ever encountered was on a Windows tablet. Once the machine is suspended (ACPI S3), it's impossible to wakeup the machine again. After a long thread in the Linux bugzilla, ultimately the problem was identified - a developer disassembled the ACPI DSDT from BIOS, and discovered this scandal. Device (PWRB) { /* * Power Button Device. * _PRW: Power Resources for Wake. */ Name (_HID, EisaId ("PNP0C0C") Method (_PRW, 0, NotSerialized) { Return (Package (0x02) { 0x00, 0x00 }) } } Yes, it means what you think it meant, even if you don't speak ACPI. power_button_wakeup() { return 0; } There's literally no code in BIOS to wakeup the system from ACPI S3, the only instruction is "return 0", it's not implemented at all! Why does it work in Windows then? In Windows, it uses Microsoft InstantGo (ConnectedStandy) - a proprietary Microsoft standby mode with network connection (to allow smartphone-like "push notification"). The vendor decided that implementing industry standards are not necessary - you only need to implement Microsoft - and simultaneously, they also decided that, rather than simply saying ACPI S3 is not supported, you should define a broken ACPI S3 just to screw up everyone who is not using Microsoft Windows.
- gobblegobble2 6y agoIsn't InstantGo/ConnectedStandby basically the same thing as S0IX ACPI state? (according to this: https://www.thurrott.com/mobile/microsoft-surface/64867/trying-to-explain-the-surface-sleep-problems https://www.thurrott.com/mobile/microsoft-surface/64867/tryi...) It's seems doable with modern kernels: https://01.org/blogs/qwang59/2018/how-achieve-s0ix-states-linux https://01.org/blogs/qwang59/2018/how-achieve-s0ix-states-li.... Maybe you should give it a try.
- bennyp101 6y agoMy Lenovo laptop with Pop_OS seems to work just fine - keyboards lights, wake/suspend/flippy screen to tablet mode. I get the impression more manufacturers are testing with linux nowadays, I think they realise that for a small (relative) amount of effort to just test the most obvious of things gives a good payoff, and the community will fix the quirks.
- gtf21 6y agoI haven't really had this experience. My Macs have had far more issues waking from sleep than my linux machine. I'm on System76 hardware though which is built for linux so could explain the driver issue mentioned in other comments.
- fsflover 6y agoJust find a laptop officially supported by Linux, just like you do with Windows and Mac.
- qz2 6y agoI've got one, a T495s, which is officially supported by Ubuntu and it still goes bananas occasionally.
- fsflover 6y agoEverything is flawless on my Purism Librem 15. Upd: I don't see any mentioning of Linux on the official page of your laptop: https://www.lenovo.com/us/en/laptops/thinkpad/thinkpad-t-series/T495s/p/22TP2TT495S https://www.lenovo.com/us/en/laptops/thinkpad/thinkpad-t-ser...
- qz2 6y agoSee: https://certification.ubuntu.com/hardware/201906-27170 https://certification.ubuntu.com/hardware/201906-27170
- gravitas 6y agoI've been using Linux on Dell laptops (various distributions and desktops, Precision / Inspiron) since the late 90s and it's always just sort of worked, had an IBM Thinkpad along the way as well. As another few comments mention, solid vendor firmware really seems to be a key factor and I prefer ATI/AMD gpu chips for their no-nonsense out of the box performance (I'm not a laptop gamer).
- wheybags 6y agoI am also extremenly frustrated by this. Even on my linux-only librem 13, it still occasionaly fails to start after a sleep. Suspend to disk is even worse. If there was a kernel dev out there accepting donations / patreon to fix this, I would be willing to sign up for a decent amount.
- busterarm 6y agoWorks flawlessly on all of my thinkpads. In both Linux & BSDs.
- SoSoRoCoCo 6y agoWhich Thinkpad model and Linux distro? I have a brand new Thinkpad Yoga 9i running a fresh Ubuntu 18.04 and I have to type "systemctl suspend|hibernate" because the power switch ALWAYS powers off. Annoying as heck.
- input_sh 6y agoI've experienced no sleep issues on T490 and two Yogas (920 and some 500 series before that, can't remember exact model). Mostly elementary OS, though I've also used Ubuntu GNOME while that was a thing and Ubuntu + pure GNOME shell afterwards.
- busterarm 6y agoI have a 7th Gen X1 Carbon and an X270. Arch & OpenBSD.
- bamboozled 6y agoFunny because I'm running a ThinkPad X1 Extreme Gen 2, last night I put my laptop down, closed the lid, didn't connect a charger, came back an hour later and my battery was at only 1% and died after opening the lid. Running Linux 5.9, but it's been doing this on occasion for a while now.
- busterarm 6y agoThe X1 Extremes are less compatible. I mean you've got an Nvidia GPU, which is basically a no-go from my perspective.
- tgflynn 6y agoI think this must depend very much on the laptop. I have a Dell Inspiron that's been running Ubuntu for several years and I haven't noticed any significant issues with sleep/wake.
- diffeomorphism 6y ago> I've had Macs and PCs which don't seem to suffer from the same issue. Seem to, but windows also has these problems, for example https://forums.lenovo.com/t5/ThinkPad-X-Series-Laptops/X1-Carbon-Sleep-Problems/td-p/2147929 https://forums.lenovo.com/t5/ThinkPad-X-Series-Laptops/X1-Ca... https://forum.thinkpads.com/viewtopic.php?t=127945 https://forum.thinkpads.com/viewtopic.php?t=127945
- liveoneggs 6y agosame as everyone else -- not enough Vitamin D
- hpb42 6y agoIf you are running a Linux distribution that uses systemd, you can check how long it takes to boot with $ systemd-analyze # if you prefer a nice diagram: $ systemd-analyze plot > boot-sequence.svg My 6-year old laptop takes 7 seconds to boot (dual core i5, 8GB DDR3, SSD, ArchLinux). My previous computer used to take ~10 seconds do boot. If you don't have a bloated OS, there's no need for sleep/hibernate. I guess Kernel/driver developers have a computer that boots fast as well, so they don't care about optimizing sleep/hibernate functionality?
- xyzzyz 6y ago10 seconds to boot is 10 times longer than 1 second to wake up, and after waking up all my state is back, vs extra seconds required to start apps and restore them to their previous state on boot.
- mekster 6y ago> If you don't have a bloated OS, there's no need for sleep/hibernate.. What are you talking about? Sleep and hibernation can keep the state of the computer on next use. Glad you can boot quickly but that's not the point.
- mtsr 6y agoThe biggest advantage to sleep/hibernate isn’t time to first work. It’s being able to resume exactly where you last were. I came from Linux laptops to MacBooks 6 years ago and that was such a big improvement. Not having to think about where I’m pausing my work. Even with the Linux laptop only failing to wake up about 20%. Although sometimes it’d fail to sleep and empty my battery and heat my backpack.
- lxgr 6y agoFor what it's worth, macOS (at least on Intel) is quickly catching up. I've never had as many sleep problems on my Thinkpad running Ubuntu many years ago as I'm seeing on my fairly recent Intel MBP.
- k__ 6y agoMy MBP doesn't sleep correctly anymore after I replaced the SSD. Either the battery is empty when I open it again, or it somehow shut itself down and boots anew with battery intact.
- RIMR 6y agoI mostly use ThinkPads as Linux workstations, and I was not aware that this was a big issue.
- spoonjim 6y agoHaha. As a parent of a one year old I definitely can empathize with sleeping and waking difficulties.
- microtherion 6y agoSo your hypothesis is that after 30 years, Linux is still experiencing teething problems?
- jokethrowaway 6y agoTo simplify, the hardware is sending some ACPI signals which tell the laptop to wake up. For some reason, sometimes they fire when you don't want them to fire. Incidentally I had this very problem when using Mac Os on a Macbook 2015 and I couldn't do much about it. When I started using linux on said Macbook at least I could disable ACPI signals. The first thing I do in any linux laptop I own is disable all ACPI signals and setup a script to do so at every boot. Then you just need to have a DE to suspend after X amount of inactivity (often the default) and you're set. Sure, you won't turn off/on your laptop by closing the lid, but it should work fine, turning on / off with power button.
- tartoran 6y agoI just had this problem a few moments ago under Ubuntu. After resuming from suspended mode, the laptop's touchpad doesn't register the leftclick. Not being able to access browser I restarting the system. This is happening intermittently without any clear pattern
- tpoacher 6y ago"You're using it wrong" ~Steve Jobs.
- MarkusWandel 6y agoI run a number of Linux laptops ranging from 10 to 3 years old (i.e. nothing bleeding edge) and except for one long retired ancient one, and one in current use, suspend/resume has been flawless (hibernate not so much; if the kids leave one unplugged and it auto-hibernate as the battery runs low, it seems about 50/50 success whether it emerges from hibernation in a usable state). Now what is not flawless: There are any number of ACPI things that, if set, will immediately re-wake the computer once suspended. The following script is on my current problematic one as /usr/lib/systemd/system-sleep/wakefix.pl #!/usr/bin/perl open(FILE,"/proc/acpi/wakeup"); while(<FILE>) { chomp; if(/enabled/) { ($a,$b) = split / /; system("echo $a >/proc/acpi/wakeup"); } } [Sorry about the mangled formatting] It just turns off everything that is enabled to wake the machine up. As this list happens not to include the power button - the only thing I want to be able to wake the laptop up - this works fine. I've never experimented with auto-suspend on lid close and auto-resume on open; maybe that's what's more troublesome. Another thing that's not suspend-resume, but nonetheless annoying - if the machine is running an SDL fullscreen thing (Tuxpaint) or if the MATE desktop has a pop-up menu open, the power button won't suspend the computer, because something intercepts the button press. My experience with suspend/resume on Desktop machines has been 100% bad, on the other hand. Usually they suspend just fine, but don't resume to a usable state.
- rektide 6y agoYour experiences matches my own closely. My desktop machines have done as well though! Suspend/resume to memory and to disk have been exceedingly reliable on every machine I've touched for a decade for me. On my old Dell convertible laptop, the wifi would only turn on every other time it woke up. The machines waking up is a real problem. I have `HandleLidSwitch=ignore` in systemd's logind.conf[1]. I see there are other options though, which I might also try setting to ignore. I too sometimes have unexpected wakeups. I'd like to learn more about how to debug these. I've asked twice on IRC & gotten no reply. My backup plan has been to write a daemon to make the system go to sleep, and whenever it wakes up, put it back to sleep, unless I "disarm" the daemon. I'm in a fairly low-visibility environment now though- I feel like I should work the problem some, fix whatever is going wrong, rather than hack around, but I have not been successful at figuring out second steps in debugging systemd daemons, once `systemd status` & upping the logging level falls short. I too have problems with some desktop things intercepting my power button, which again, I wish I had better visibility in to. I don't know other than trial & error to figure out who might be grabbing the input devices. [1] https://www.freedesktop.org/software/systemd/man/logind.conf.htmlloginctl https://www.freedesktop.org/software/systemd/man/logind.conf....
- api 6y agoJust punt on the problem. Get a good quality high performance ARM64 chip, pair it with a larger than typical battery, and build a laptop that never actually shuts off unless the battery charge falls below 10% and the lid is closed. This would be a better machine all around anyway. You could close it with ssh sessions open and open it again and they're still open. You could run P2P software in the background and it would never have to re-bootstrap. You could connect to it remotely to access files any time. Computers that turn off all the time suck.
- mcv 6y agoThis is not specific to Linux. Windows also constantly wakes up whenever it don't want it to. A lot more often than 20%. It's incredibly annoying. Sometimes I put a PC to sleep, and it will wake up a minute later. Sometimes it wakes up in the middle of the night to spin up its fans. Laptops I put to sleep without being hooked up to power will have their battery drained next time I want to use them. I can't imagine any OS being worse at sleeping than Windows.
- riggsdk 6y agoCheck your USB devices - they can wake up your PC. You can disable this on a per-device level in the device manager. Find the device, open it's properties and find the setting under the "Power management" tab. A windows PC can also be woken up by "Wake-on-LAN" magic packets sent to your network card. Go to your network adapters and open it's properties. Press the 'Configure' button. Go to the Advanced tab and find "Wake on Magic Packet" and turn it off.
- mmwelt 6y agoI found it to be my USB mouse. I'd already disabled the option to wake the PC in the mouse device, but then found out that you also have to do that with a separate "keyboard" device[1]. But ever since disabling the option on both devices, things have become a lot better. [1] https://answers.microsoft.com/en-us/windows/forum/windows_10-power/windows-10-cannot-disable-the-mouse-from-waking/706340c2-1fcc-4cd0-b747-c736d8a31b34 https://answers.microsoft.com/en-us/windows/forum/windows_10...
- dyingkneepad 6y agoCrappy drivers. Is there a chance you've been using some device that fails to suspend? Are you using NVidia or other proprietary drivers? My suggestion is that you run Linux on laptops that everybody else buys. These days the famous ones are Dell XPS and Lenovo Thinkpad. Also, please make sure you report your issues. Regressions on S3 are often common. Unfortunately developers lack properly testing S3, because it's difficult to test. Oh, and forget Hibernation (S4). It's crap and it's just never going to work fine. It's not even worth it since the machines boot fast.
- bamboozled 6y agoI actually run a year old model Lenovo ThinkPad and the latest stable kernel. I mean it's mostly good at hibernating, but it's just not solid like other systems I've used. You're right in saying that it's better on these systems with later kernels, I do remember a time when I was younger and buying the wrong laptop without suspend support though :)
- BruiseLee 6y agoFor me, my Mac Mini (running OS X) is the worst. It just wakes up whenever it wants to. Usually in the middle of the night.
- cyrialize 6y agoMy T530 wakes up and sleeps just fine. I don't have hibernate set up. I know there's a command line command I can do, but I also know there's a way to "enable" it somehow so that it appears as an option in the shutdown menu. It probably works so well on my T530 since it's an 8 year old thinkpad.
- ThePhysicist 6y agoCheck syslog, often there's either a PCI device (e.g. an ethernet card) that wakes up the machine immediately after it goes to sleep, or a process refuses to freeze/stop. ACPI wakeup problems can be fixed using /proc/acpi/wakeup, there you'll also see which devices can wake up the machine and you can disable them one by one to find out where your problem lies (though syslog should already tell you what woke up the machine or kept it from suspending). That said I haven't had a single suspend/wakeup issue with my Linux machine in years, I even find Windows considerably more buggy and unstable in this respect.
- smallstepforman 6y agoI triple boot my MacBookPro with OSX, Ubuntu 20.04 and Haiku. Ubuntu is unusable with the fan noise and low battery life. Funnily, Haiku has best battery life of all 3.
- rwmj 6y agoChoosing the right hardware can help. I've had Lenovo Thinkpads from work and I never have a problem with suspend or hibernate.
- agapon 6y ago[This is just for laughs] I also never had problems with suspend. Resume is a different story, though.
- neolog 6y agoWith all the experts in here, I might as well post my suspend/wake issue: Here's my kernel log from today's a failed wake-from-suspend. https://bpa.st/VIPQ https://bpa.st/VIPQ Linux 5.4.81 with amdgpu I notice in particular: kernel: amdgpu 0000:09:00.0: [drm:amdgpu_ring_test_helper [amdgpu]] *ERROR* ring gfx test failed (-110) kernel: BUG: kernel NULL pointer dereference, address: 0000000000000008
- segfaultbuserr 6y ago> Linux beta 5.4.81 with amdgpu I don't know anything specific about AMDGPU, but if I were you, the first step I'd always try is to reproduce it in the latest mainline kernel, it's currently 5.9. Check the documentation of your distribution to see how can you get one. Often a partial fix exists in a newer kernel, and you may be able to identify and debug a different part of the issue.
- segfaultbuserr 6y agoA web search shows the problem has already been "git bisected" by users on Bugzilla with a workaround [0]. And according to > Ahzo 2019-10-11 18:33:10 UTC > bisection between these two, while backporting 533aed278afe on every step, lead to commit 2a91f272e34c, which failed to boot and thus had to be skipped, and commit e0128efb08b3d628d767ec8578e77cdd7ecc8f81 looks like a likely root cause. Indeed, adding 'return 0;' at the beginning of uvd_v6_0_enc_ring_test_ib makes the problem unreproducible, even on the latest linux 5.4-rc2. And, > Ahzo 2019-10-11 18:37:48 UTC > By the way, some of the kernel NULL pointer dereferences, that can happen after a resume failure, also happen always on shutdown. Attached patch prevents them. Do you know how to build a kernel? I suggest you to build Linux 5.4 (you can avoid reconfiguring the kernel by using /proc/config.gz) with the code workaround (adding 'return 0;' at the beginning of uvd_v6_0_enc_ring_test_ib) applied, and see whether it fixes your problem. You should also check the NULL pointer patch and see whether it's already included in the source code by manual inspection, if not, also apply the patch. If it fixes your problems, report it to the Bugzilla thread. Nevertheless, I still recommend you to try reproducing it in Linux 5.9 first and see whether you can reproduce the original problem. The comments in Bugzilla suggests that the latest kernel has already fixed the issue. > Alex Deucher 2020-10-01 14:59:58 UTC > The original issue reported in this bug was fixed long ago. If Linux 5.9 fixes it, good. If not, see whether the error messages are different. If so, you should chase the new issue instead of the original issue. --- [0] https://bugzilla.kernel.org/show_bug.cgi?id=204241 https://bugzilla.kernel.org/show_bug.cgi?id=204241
- tkainrad 6y agoSurprised to see this. I have never had any problems with sleep. Used plenty of distros and machines. Hibernate has been a bit tricky for me. But a few months ago I have finally found a solution that has since worked on all Ubuntu 18.04 and later machines I have tried it on. Described in detail in a blog post at https://tkainrad.dev/posts/setting-up-linux-workstation/#hibernation https://tkainrad.dev/posts/setting-up-linux-workstation/#hib... Commands and config there can be copy-pasted and should hopefully fix any hibernation problems. It depends on explicitly creating a large enough swapfile and setting the UUID and offset in the grub configuration.
- dgrabla 6y agoStrategy: "use couple of years old Thinkpad". Tons of linux devs use thinkpads and a couple of years are needed for all userland / driver patches to land at your favorite distro. It worked so far for me with the x40, x230 & t470s.
- mike_ivanov 6y agoI concur. It is usually possible to get sleep/hibernate working after tinkering with video/wifi driver settings, but it almost never works out of the box.
- jdoliner 6y agoDoes anyone every refer to these problems as their Linux install having insomnia? Or is that just me?
- cassepipe 6y agoThe problem I have on a six year old laptop running Linux is that, only sometimes, when powered off, everything closes normally, systemd exits but then the laptop never goes off. It has happened to me on other laptops. Not a big deal but I really wonder why.
- tubularhells 6y agoIt works on my computer. Are you using Gnome? That might be your problem. Try KDE. It works.
- asciimov 6y ago> I've had Macs and PCs which don't seem to suffer from the same issue. It's funny, I don't have a problem with sleep/wake on my 6.5 year old HP laptop under Linux but on Windows 10 it can't seem to ever stay asleep. It loves to wake up at random times and stay awake, even when it is only on battery. With that said, Linux can't successfully manage the laptops P-States. I have to force the system to just not manage them under Linux because it will randomly lockup.
- FreeFull 6y agoWindows 10 has a setting where it'll wake up the machine to run Windows Update, and it's on by default. Perhaps if you turn that off, the random wakeups will stop.
- asciimov 6y agoI'll double check that. This is an intermittent issue, across multiple installs of windows 10, and I'm almost certain it's an issue created by one of the laptops drivers. Fortunately, I don't normally live in Windows, so I have little desire to spend much time hunting down and fixing the problem.
- fart32 6y agoTurn off wake-up by alarm in BIOS, if you can. Windows just wakes up whenever it wants and if you, somehow, manage to make it stop in the settings, it only works till the next update. At least that was my experience.
- nedsma 6y agoI figured out the best way to deal with WiFi and sound issues in Linux is to run it as a VM guest. With plenty RAM and fast SSDs it runs more than acceptably well.
- mvanbaak 6y agoWhy? Developers ;) they have exactly this problem ;) Ps: this is not a serious answer
- bamboozled 6y agoI am the OP, I should've mentioned when I originally posted that I _am_ using a Lenovo ThinkPad, X1 Extreme Gen 2 to be precise. I love the laptop a lot, but the sleeping isn't as dependable as my Mac was. Overall the laptop has performed well running Linux, although I must say, the Nvidia GPU is a massive let down from a driver / support perspective. I'll never buy a Laptop with an Nvidia GPU again so long as I run Linux or probably ever because they treat open source like crap. In the interest of giving a fair review, I'll explain why this laptop falls short with an Nvidia GPU (in my view), it might even explain why the sleep issues: Basically the USB-C ports are hardwired directly to the Nvidia GPU, this is so the GPU drives external monitors. Which is fine, but what's not fine is that the GPU must be on an enabled permanently to use an external monitor. If I turn off the GPU, the external monitors can't be used. I can turn off the GPU by changing modes (dramatically improving battery time and life), but this means I need to go change my X configuration, login and log out. So either having good battery life, or working at my desk is a compromise, because it's highly inconvenient to change settings and reboot. It basically lets the entire machine down when it comes to functioning as a Laptop. Apparently there is talk the drivers might support the offloading behaviour one might expect in the future. To be able to drive external monitors just using the integrated graphics. The HDMI port might not be hardwired, but I'm not really interested in using that as I like the USB-C port because I use my monitor as a USB Hub / docking station.
- vlan0 6y agoHuh, been running Fedora on my Latitude 7280 for years without any sleep/wake issues. Starting to feel like I might be lucky.
- billylindeman 6y agoIf you want good support for this I recommend getting a lenovo. My X1 yoga 4 has been the perfect linux laptop. Sleep wake works flawlessly
- boatsie 6y agoSleep or hibernate? I have a Lenovo t480 on Ubuntu 18 and it sleeps/wakes ok, but hibernate refuses to work. So I’m fine being off AC for hours, but not day(s).
- tinus_hn 6y agoThere is a standardized way you can tell devices to go to sleep or hibernate. This is implemented by the firmware core. The people who write that firmware code test a lot to make sure it works when the device is programmed the way Windows programs it. If Linux turns out to use the device in a different way the procedure is untested and often this firmware is very buggy which is why it isn’t reliable.
- Codazoa 6y agoStrange. Of all my computers it is only my 2 windows machines that have trouble sleeping and waking. All of my linux machines sleep no problem and only wake up when I have scheduled it. I even have them set up to receive sleep and wake commands from my phone from anywhere. Windows doesn't play nice with that type of setup either. My windows computers will wake up less than 5 minutes after going to sleep but I've left my linux systems on sleep for days and sometimes weeks at a time with no problem at all.
- alexeiz 6y agoMy experience is exactly the opposite. Windows and Linux are installed on my laptop in dualboot mode. Linux goes to sleep and wakes up just fine 100% reliably. Windows, however, uses this "connected standby" or "modern sleep" mode by default that on multiple occasions lead to waking up while the laptop was in my backpack and then draining the battery to zero. I got fed up with this and decided to disable this shitty sleep and go back to normal S3 sleep mode. It's not so easy on Windows 10 anymore! It took me a couple of hours but I finally found a solution. And S3 is now the default sleep mode instead of the modern sleep. Looks like the sleep mode is fixed. However! My laptop began to go to sleep as soon as I activated the lock screen even if it was connected to power. Wtf! More hours spent on searching for solution (other people experience this issue as well). It turns out there is a hidden (!) power option. You need to unhide it by changing the registry and then disable it. Now my laptop when connected to power still spontaneously goes to sleep, but it happens after 20 minutes or so. I don't know what other option I need to change. I just can't spend any more time researching this crap.
- dpc_pw 6y agoYour laptop manufacturer doesn't care so it's buggy. Buy a Thinkpad, Zenbook, Dell XPS, System76 laptop or some model known to have good Linux support next time. Can't remember any problems like this in the last decade, but I always, always research Linux compatibility before buying any hardware.