Linux – Clock drift in a VirtualBox guest

arch linuxclockvirtualbox

I've done this command this morning:

root@xxx:01:21:17:/home/xxx$ date --set "2015-08-06 02:54"
Thu Aug  6 02:54:00 WIB 2015
root@xxx:02:54:00:/home/xxx$ hwclock --set --date="2015-08-06 02:54" 

later on that day, I check the clock it should be 08:00, but it shows a delay by 10 minutes:

root@xxx:07:49:59:/home/xxx$ date
Thu Aug  6 07:50:00 WIB 2015
root@xxx:07:50:00:/home/xxx$ hwclock
Thu Aug  6 07:50:01 2015  .392298 seconds

What are the possible cause of this? I'm using 64-bit ArchLinux under VirtualBox

$ uname -a
Linux xxx 4.0.4-2-ARCH #1 SMP PREEMPT Fri May 22 03:05:23 UTC 2015 x86_64 GNU/Linux

The timezone is GMT+7

$ date +'%:z %Z'
+07:00 WIB
$ strings /etc/localtime | tail -n 1
WIB-7

As suggested on the comment, installing ntp temporarily solves this problem:

sudo pacman -S ntp
sudo systemctl enable ntpd
sudo systemctl start ntpd
timedatectl set-ntp true
timedatectl

but after one day, the time drifting again:

      Local time: Fri 2015-08-07 23:52:10 WIB --> 30 minutes late
  Universal time: Fri 2015-08-07 16:52:10 UTC
        RTC time: Fri 2015-08-07 16:52:10
       Time zone: Asia/Jakarta (WIB, +0700)
 Network time on: yes
NTP synchronized: yes
 RTC in local TZ: no

Best Answer

This is an issue with the paravirtualisation

Changing the para-virtualisation parameter in virtual box will help solving the issue. In the settings of your virtualbox machine go to: System > Acceleration enter image description here

Hopping that will help many people.

Related Question