-4

I've been looking at lots of web content about sleep, suspend, hibernate modes of a computer but I have not come across any discussion of this seemingly simple question:

What, if anything, is the difference between

  1. just walking away from a linux computer, running, let's say Ubuntu 22.4 LTS but it really could be any distro and version, and
  2. explicitly invoking the suspend command, either from the command line or a gui?

Both cases are supposed to enable you to come back to the computer later, click the mouse or type a key and "wake it up".

If there is a difference, what is it? If there is no difference, why is the suspend command necessary?

And by the way, is there a name for "just walking away"? Is that what "sleep" means?

I find these terms thrown around without any precise definition of what each means.

Update: Why am I asking this?

Most of the material I find in relation to the different forms of computer sleep, suspend, or hibernation assume that the main concern of anyone asking it is power consumption. This is not my concern.

My concern is that when I leave my computer I can reliably come back to it and not need to reboot.

My concern is that I have purchased a fairly expensive laptop computer from Lenovo, with an nVidia graphics card (not going to get into the technical details here) that I cannot walk away from and reliably assume the system will wake up when I come back to it and press a key or make a mouse click. Sometimes it works, sometimes it doesn't. It seems that explicitly invoking suspend is a little more reliable, doesn't crash as often, but it is not 100% reliable, maybe 90%. On my previous computer, a 10-year old Lenovo laptop, I did not have to worry about any of this.

Update 2: correcting original to mention "getting rid of Secure Boot under UEFI" rather than "getting rid of UEFI" as a prerequisite of achieving hibernation.

Hibernation suggests itself as the most reliable way to achieve what I am after, but it is not currently available on my computer which uses Secure Boot under UEFI. So one option is disabling Secure Boot. I was reluctant to do it but that seems to be the way I have to go.

My main concern is reliability, not power consumption.

9
  • 3
    It really depends on how you set up your computer. Mine for example will never suspend, so I'd have to do it manually (or configure it to do it). Check your energy management configuration, you can state what you want the computer to do when you "walk away from it". Commented Mar 6 at 20:52
  • 1
    Sorry, but the definition of these terms does NOT depend on how your set up your computer. These terms are thrown around as if they all mean the same thing, and they do not. What does "sleep" mean? What does "suspend" mean? What does "hibernate" mean? They should mean the same thing regardless of how someone sets up their computer. That's what I am looking for. Commented Mar 6 at 23:06
  • 2
    @SteveCohen the good thing is that within the realm of Linux, they are well-defined and not at all arbitrary. The bad thing is that people still throw them around as if they meant the same thing. I promise, they do not. Commented Mar 6 at 23:39
  • 1
    "the definition of these terms does NOT depend on how your set up your computer", sure, but which of these actions are taken depends very much on how you set up your computer. After it is idle for a while (because of you "just walking away"), will it sleep? Hibernate? Shutdown? Start downloading and installing updates? Cause dragons to come out of your nose? Who knows, except whoever configured it? Commented Mar 7 at 2:21
  • 1
    Seems to be an XY problem related to this Commented Mar 7 at 4:33

2 Answers 2

1

If there is a difference, what is it?

"Suspending" on Linux has a pretty well-defined meaning, especially (but not exclusively) on the x86_64 platform. When people say "suspend", they mean "suspend to RAM"; only on platforms where that is not supported by the hardware would "suspend to idle" be something that one might consider. I'm not aware of any current Linux platform that doesn't support suspend-to-RAM; they might exist, but for your PC, there's no doubt about "suspending" meaning "suspend to RAM", as described below.

It means that you stop all CPU cores, after saving all the state of devices to RAM, bringing all devices into a state where they can be put to sleep and be consistently awoken later on, actually put them to sleep, and finally bringing the registers of all CPU cores into a well-defined state, before putting every CPU core into a specific sleep state.

In that sleep state, the CPU actually is stopped; only the memory controller keeps running to refresh the RAM, so that the state you stored to RAM doesn't get lost. Only the units necessary to be able to wake up (e.g. the USB controller so that you can press a button on your keyboard to wake up) are powered and operate autonomously. Things like hard drives and SSDs are literally told to power off.

(These sleep states are well-defined things on x86 and most other platforms you might encounter in reality. Going into these states is a well-documented procedure, and you have to do specific things to wake up. It is not at all undefined what that means!)

If you just walk away, at least one CPU core will continue to run, and even if a running Linux system didn't have things to do regularly (update the display 60 times a second, keep the sound card fed with samples, update counters, maintain the storage media, and generally do a lot of things in the background), it would never completely power off.

Thus, when you walk away, your power supply would still supply your full CPU, all your devices, and be ready to suddenly supply large amounts of power.

On the flip side of this big power saving of suspending is the fact that, well, you're really stopping your CPU! No software is running anymore. If you just walk away and someone wrote you in chat, and you had left your chat program open, you'd get a sound. In suspend, none of that could even happen, because, there's nothing "talking" to anything anymore.

why is the suspend command necessary?

To stop scheduling userland processes, to finish writing things to storage, to get hardware components into a power-offable state, to shut them down, to save CPU states to RAM and finally put the CPU cores to the correct sleep mode. (You'll find that things like systemctl suspend do a lot of things to make your computer well-prepared.)

My concern is that when I leave my computer I can reliably come back to it and not need to reboot.

Sure, in the absence of driver and hardware bugs, that's reliable. In practice, that's not been an issue for the last ~ 13 years or so on well-supported laptop and desktop hardware. There's annoying exceptions to that – proprietary kernel drivers for graphics cards come to mind. But that has gotten better! So, in general, yes, you can expect that.

It seems you get hit by that, and frankly, nvidia, who's literally making many billions by selling GPUs to Linux users (mostly for machine learning purposes, the gamer / laptop GPU market is relatively small, comparatively to that), is to blame for that.

Hibernation suggests itself as the most reliable way to achieve what I am after, but it is not available on my computer which uses UEFI.

that's not how that works: hibernation works well on UEFI machines. In fact, the better-defined boot state coming out out UEFI boot loaders is nicer to unhibernate from than the mess that BIOS was. Also, if hibernation would only work on "BIOS" machines, it would simply not exist anymore. "BIOS" these days is emulated by the same firmware that implement the UEFI interface. So, whatever it is that stops you from hibernating: it's not the fact that you're running on an UEFI machine.

So one option is getting rid of UEFI but I don't want to do it unless there is no other way.

not at all an option, that is what boots your computer :)

9
  • I upvoted your answer, and if you can provide me with links to sites that tell me how to do it, I will tick your answer as THE answer. My attempts to do it so far have failed. Commented Mar 7 at 0:11
  • @SteveCohen to do what? Commented Mar 7 at 0:15
  • To get hibernation to work on my machine. All my previous efforts have failed. See askubuntu.com/questions/1542904/… . You can answer here or there if you want. Commented Mar 7 at 0:20
  • What I like about your comment is that 1) you specifically target nvidia as being at least partially to blame here. I had suspected that and 2) you actually answered what I was asking. Too often these Linux sites devolve into "this command worked for me.". Commented Mar 7 at 0:25
  • I'm sorry, I can't fix nvidia's hardware. Linking an answer to a question that is asked elsewhere to acceptance of an answer here makes no sense. Commented Mar 7 at 0:47
-1

The main difference is energy consumption. Any of the following points may or may not apply to your system:

  • Hard disk hibernation: classic hard disks (the ones with rotating disks) use energy to keep the platters spinning during the uptime. Some have energy conserving electronics, which makes them stop spinning after a certain time of not being used, but some don't and the OS will power them down when suspending.

  • CPU clock cycles: especially mobile versions of CPUs can use a very wide variety of clock rates. As a rule of thumb the energy consumption of a CPU correlates with the square of its clock rate (this is why modern computers need all that elaborate heat transfer mechanisms - their clock rates are absurdly high), hence a significant amount of energy can be conserved when the clock rate is reduced to near zero.

  • switch off the monitor: laptops/notebooks typically use ~30% of the energy to power their internal monitor - if it is used. Switching it off is especially helpful for these mobile computers to last longer on battery.

  • switch off non-essential hardware: there are some devices a suspended computer doesn't need, for instance the WLAN adapter. Powering off these non-essential devices also saves energy and prolong battery runtime. Basically in suspend mode you need just RAM (this has to be constantly refreshed to keep its content) and maybe some parts of the chipset, maybe the contents of the GPUs local memory - most other things can be powered down and quickly be powered up once normal operation resumes.

Update, after the question has been rephrased

I don't know PC hardware all too closely as I work mainly on POWER and System-Z (aka: mainframe) systems, so I can give you just general pointers:

Typically the problem with failed suspend modes is the reinitialization of the graphic hardware. Many laptops have GPUs integrated into the chip set and when that is powered on again restoring the GPU registers/status is not that easily done as restoring the CPU state.

First, determine what exactly the status after a failed return from suspension is: complete system down, GPU down but system up, system and GPU up but X down, etc.. Try to ping it and/or ssh to it.

If you can connect to it: examine /var/log/kern.log and /var/log/Xorg.0.log, there might be some helpful information.

You can also try connecting a serial terminal (via USB), maybe the system is up but the network hardware is as down as the graphics.

One word about hibernation, aka suspend-to-disk: this is quite often disabled in many distributions and has to be explicitly reenabled if you want to use it. I don't use any Ubuntu, but here is some link that might help.

13
  • As I understand your answer, it is that explicit suspending of a computer causes it to use less energy than walking away from it and letting the OS do whatever it does. In such a situation, blanking the screen, and I'm not sure what else. My problem with all these discussions is that they assume that the main concern of anyone asking about this is power consumption. That is not my main concern. I am now going to modify my original post to add why I am asking it. Commented Mar 6 at 22:42
  • @SteveCohen: You asked what the difference is. I told you what the difference could be because what it actually is depends on what computer you use, what OS you use and how said OS is configured. If that is not your goal then simply don't do it, no? Commented Mar 6 at 22:45
  • @bakunin it's actually not that depending. "Suspending" has a pretty well-defined meaning on Linux. Commented Mar 6 at 23:07
  • please see my update above. I don't think I'm wrong in asserting that without precise definitions, the user is left in a kind of never-never land trying to figure out the best way to configure their system. Commented Mar 6 at 23:09
  • 1
    @bakunin it is really nonsense, sorry. "Suspending" has the same meaning on all Linux platforms, it means "bring CPU state to something that can be restored from RAM, power off all devices that can be restarted from state saved to RAM, then put all CPU cores to a sleep mode"; these sleep modes might differ in detail on different platforms, but unless you can tell me one machine that you actually interacted on that is Linux on Power, I'll just say you seem to try to distract from the fact you're not very familiar with the terminology here. Commented Mar 6 at 23:27

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.