bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#64937: boot time on Linux


From: Bruno Haible
Subject: bug#64937: boot time on Linux
Date: Wed, 09 Aug 2023 16:29:38 +0200

More info about this problem: I wrote
> I have a VM running in VirtualBox, that I booted 6 days ago, then "saved"
> it (i.e. all the state gets frozen) and resumed it today around 20:30 UTC.
> ...
> So, both programs show a "boot time" that is just 5 hours ago, at a moment 
> when
> the VM was in fact frozen.

1) The issue can be more easily reproduced by simply setting the date
   ("sudo date MMDDhhmm") in a VM, be it in VirtualBox or QEMU.
   The result of
     (time now) - (kernel's uptime notion)
   becomes wrong at that point.

2) Fedora Rawhide has the 'virtualbox-guest-additions' package installed
   by default, and these guest additions contain a "time synchronization"
   feature [1]. Within 5 seconds after resuming a VM from sleep, they
   do effectively the same as a "sudo date MMDDhhmm" command.

So, all approaches that compute the boot time through a subtraction are
going to be wrong in these scenarios.

The better approach is really to read the boot time from a time stamp —
inside a file such as /var/run/utmp or /var/log/wtmp, or attached to
a file such as
  /var/lib/systemd/random-seed    (first file touched during boot)
  /var/log/boot.log               (one of the last files touched during boot).

And on Alpine Linux, while /var/run/utmp is empty, its time stamp is
essentially the boot time.

The approach used by Emacs, namely to look at the time stamp of
/var/run/random-seed, is therefore essentially one of the best approaches.
It just needs to also look at /var/lib/systemd/random-seed and - on Alpine
Linux - /var/run/utmp .

Bruno

[1] 
https://docs.oracle.com/en/virtualization/virtualbox/6.1/user/guestadditions.html#4.1.-Introduction-to-Guest-Additions








reply via email to

[Prev in Thread] Current Thread [Next in Thread]