The uptime
command gets its data from /proc/uptime
, which is exposed entirely by the kernel. So, we'll check out the kernel documentation to see what this actually represents.
In Documentation/filesystems/proc.txt
, we see:
uptime Wall clock since boot, combined idle time of all cpus
(there are two values in this file, hence the two descriptions)
The reference to "wall clock" is important here - it means all elapsed time, regardless of whether or not the machine's clocks are running. So, this time will keep increasing in suspended or hibernated state.
Putting it another way, the uptime value is effectively the time elapsed since the last boot.
xenoid kindly pointed out a generally helpful article on the ubuntu wiki.
Dead, blank, or black screen on resume
In some cases, a machine can hibernate just fine, and resume without issue, with the exception of waking up to a blacked-out screen. In other words, the computer is running just fine, but the display appears dead.
They recommend adding nomodeset to GRUB_CMDLINE_LINUX_DEFAULT
in /etc/default/grub
.
Because I like verbose boot, I did not specify quiet splash
as they did in their example, and because I followed this guide I already had GRUB_CMDLINE_LINUX_DEFAULT="resume=UUID=<my uuid>"
. So in the end my line looks like this:
GRUB_CMDLINE_LINUX_DEFAULT="nomodeset resume=UUID=93232136-5a6d-4ffc-b40d-809ccead48df"
After changing that, you need to run
sudo update-grub2
(which happens to do the exact thing as sudo update-grub).
And then
reboot
Now systemctl hibernate
should work.
This question asks the same thing you are wondering right now:
- What exactly am I doing? Why does it help?
- Can I do something to avoid doing these steps?
The answer suggests to "install suitable video drivers". That may well indicate why I had to add nomodeset
this time, but not last time I tried to set up hibernate - my audio driver is also broken, so that could be related (though I don't know why this happened).
It turns out this solution broke my audio card detection and my brightness controls. See here for more info. As of July 2020 it seems like a kernel update or something has fixed this issue for me though.
systemctl suspend
does now "work" as well... but for some reason the screen stays on. It's mostly black, but you can tell because there's a white underscore at the top left corner.
Best Answer
/var/log/pm-suspend.log
.Uptime is the time since last (re)boot. Basically the system stores at boot time what the time is and "now" -/- that time is the uptime. So in that regard: no, not a bug. The command predates notebooks and hibernate/suspend so maybe if you create a feature request someone decides it is a good feature to have. It probably is a very easy addition:just update the time stored on disk. And I can not imagine it is a lot more than adding a call to the hibernation/suspend script. But it will also be difficult to get it happen :)