It's a good idea to have an accurate clock on any computer you access - apart from anything else it means your logs will be consistent making event replays easier. Unfortunately over time each computer will slowly drift away from the actual time. NTP - network time protocol - keeps the clock accurate by synchronising it with a group of computers elsewhere on the internet. Unfortunately, Xen guests such as those provided by Xeriom Networks tend to be tied to the clock of the Xen host. This is a quick walk-through to show how to setup NTP and remove the dependence on the physical host.

Taking a shortcut

If you're running a Ubuntu based VM and you use the package host at Xeriom Networks then you can run this simple command to setup NTP.

sudo apt-get install xeriom-ntp-client --yes --force-yes

Gaining Independence

To stop your VM's clock being slaved to the hosts simply tell the kernel that the clock is independent.

sudo su -c "echo 1 > /proc/sys/xen/independent_wallclock"

To make sure that this persists over reboots, edit /etc/sysctl.conf to include xen.independent_wallclock = 1.

Installing and configuring NTPD

An NTP daemon can be installed using apt-get.

sudo apt-get install ntp --yes

If you're on one of Xeriom's VMs you can use as a timesource. Edit /etc/ntp.conf to use it, and perhaps a few other servers from the nearest NTP pool to you.

server prefer

Restart NTP and you're done.

sudo /etc/init.d/ntp restart

What's the time Mr. Wolf?

NTP will take maybe 15 minutes to settle down and select the best possible configured timesource to synchronise with. You can check how it's doing by using ntpq -p.

ntpq -p
     remote           refid      st t when poll reach   delay   offset  jitter
*    3 u   39   64  377    0.402  -45.729   7.496     2 u   39   64  377    3.443  -54.808   6.142
+ntpt1.core.thep    3 u   40   64  377    0.723  -53.765   5.965   2 u   38   64  377    9.110  -57.739  11.427

This output contains quite a bit of information - for more complete details check out

Now there's no excuse for being late

If you found this article useful, give me some love over at Working With Rails.

written by
Disagree? Found a typo? Got a question?
If you'd like to have a conversation about this post, email I don't bite.
You can verify that I've written this post by following the verification instructions:
curl -LO
curl -LO
gpg --verify using-ntpd-in-a-ubuntu-804-xen-virtual-machine.html.orig{.asc,}