Keeping time in a Virtual Machine

 Unlike suspend/resume on a laptop the guest operating system in a Virtual Machine doesn’t know when it has gone to sleep and woken up. The best way to get it to keep time correctly is to use ntpd (see ntpd(8) and ntp.conf(5)).

In order to keep ntpd running you have to tell it not to panic when it gets a very large time offset. The ntp daemon will accept an offset of up to 1000 seconds by default, but if you suspend your machine for more than that length of time the daemon will exit. In your /etc/ntp.conf file add the following lines:

tinker panic 0

The 0 says “accept any offset” which means that if your machine is suspended for a long time, as mine often are, when it unsuspends and gets a very large offset from the server everything will be OK.

You can also decide to specify the -g flag to the ntpd daemon in the flags section in rc.conf but it’s likely better to use the configuration file since you’ll need one anyway, and then upgrading and making a mistake with mergemaster won’t kill your settings.

0 Responses to “Keeping time in a Virtual Machine”


  • No Comments

Leave a Reply

You must login to post a comment.