Ticket #11980 (new defect)

Opened 9 months ago

Last modified 8 months ago

guest additions should write system time to RTC after adjusting it

Reported by: yrro Owned by:
Priority: minor Component: other
Version: VirtualBox 4.2.16 Keywords:
Cc: Guest type: Linux
Host type: Windows


When booting a Linux distribution using systemd, the system time is not automatically written to the RTC during shutdown. For further information & rationale, see <>.

As a result, booting my system under VirtualBox results in the following:

Jul 22 03:46:06 wintermute kernel: rtc_cmos rtc_cmos: setting system clock to 2013-07-22 02:46:03 UTC (1374461163)
Jul 22 03:46:07 wintermute systemd-fsck[443]: /dev/sdb1: Superblock last write time is in the future.
Jul 22 03:46:07 wintermute systemd-fsck[443]: (by less than a day, probably due to the hardware clock being incorrectly set).  FIXED.
Jul 22 03:46:07 wintermute systemd-fsck[443]: /dev/sdb1: clean, 340335/39321600 files, 138917904/157286139 blocks
Jul 22 03:46:08 wintermute systemd[1]: Started LSB: VirtualBox Linux Additions.
Jul 22 13:57:43 wintermute systemd[1]: Time has been changed

After boot, we can observe the RTC is still wrong:

$ date
Mon 22 Jul 14:10:15 BST 2013

# hwclock -r
Mon 22 Jul 2013 03:58:44 BST  -0.070616 seconds

After the guest editions have set the system clock from the host clock, they should set the hardware clock to match. That is, perform the equivalent of hwclock --systohc.

Change History

comment:1 Changed 8 months ago by yrro

Workaround: write the system time to the RTC during shutdown by creating /etc/systemd/system/vbox-hwclock.service and then running running systemctl daemon-reload && systemctl enable vbox-hwclock.service.

Description=Save system time to RTC

ExecStart=/sbin/hwclock --systohc

Last edited 8 months ago by yrro (previous) (diff)
Note: See TracTickets for help on using tickets.
ContactPrivacy policyTerms of Use