VMWare Server on Debian Linux with Accurate Timekeeping

Home, Elsternwick, Australia, 2007-12-30 16:43 +1000


I just replaced my old Red Hat 9.0 web server with a new VMWare Server platform with one of the VM’s being a web server.

VMWare Server is pretty easy to install if you’re not scared of using shell commands, but there are some steps beyond the basic install that you need to go through to make sure the clock on your guest operating system is correct. None of the tutorials or howtos I’ve come across (such as this, this or this) seem to cover this, so this post walks through those steps.

Host Operating System

OS Install

I use a barebones Debian installation which I’ve automated with a preseed script. On my hardware I had to also use the noapic parameter, so the full boot command for the Debian installer looked like this:

auto file=/floppy/preseed_orange-cluster.cfg noapic

Time Keeping in Virtual Machines

In my early trials of VMWare I tried to run ntp inside my virtual machines and had all sorts of trouble with the guest OS’s interfering with the host OS’s clock and vice-versa. After a bit of Googling around I found this document about time keeping in virtual machines on the VMWare site. It’s really required reading if you want to setup your VM’s properly.

The key points from this document are:

  • It’s just too hard to make guest operating systems run accurate clocks because they are sharing the hardware with other machines.
  • Don’t run NTP in your guest OS because it will end up wrestling with the host OS
  • Run NTP in your host OS and use VMWare Tools to synchronize the correct time from the host OS to the guest OS’s.

So in the host OS, I also installed ntp (actually I should add this to the preseed script for the host OS):

apt-get install ntp

Another point about time keeping which is probably obvious to many - use UTC on your servers as it makes life so much easier. On my old server I was never completely sure what to do about daylight savings time in my timezone (Australian Eastern Time). Should the clock be put forward? Left on Standard time all year? Also because I spend a lot of time on SE Asia Time, when I sync’d log files down to generate reports, I was always having to reconcile different timezone offsets. With the clock set to UTC, there’s no timezone changes through the year, and timezone offset reconciliation becomes much easier.

The clock on my host OS is set to UTC in the preseed file with the line:

d-i time/zone      string        Etc/UTC

VMWare Server Installation

Once the install was finished, I added a few more packages needed to compile VMWare Server (again I should stick these in the preseed script)

apt-get install autoconf automake binutils cpp gcc 
   linux-headers-$(uname -r) make psmisc libxt6 libice6 
   libsm6 libxrender1 libXtst6 libXext6

I want to give props to this post on howtoforge about installing VMWare Tools which gave me the first half of the previous command. I’ll come back to that HOWTO later when I start setting up virtual machines.

With all the required dependencies in place it’s just a matter of unpacking the tar.gz file and running the install. See the tutorials linked above if you need details on this process. It’s pretty easy really. I literally accepted every default in the install process - it could have been automated with a drinking bird, Homer Simpson style. As the server has two NICs, the only thing I had to be careful of was that the installer picked the right one for the bridged network (which it did).

I found that the Linux installer for VMWare Server didn’t accept my license keys properly. If this happens you can just skip that step and once your VMWare Server is up and running, you can enter the license key through the VMWare Server Console GUI.

Guest Operating Systems

OS Install

My guest OS’s are all Debian 4 as well, and I have preseed scripts for each VM. The preseed scripts are quite similar to the one for my host OS, so I won’t go into details on those.

If your virtual machine is some kind of production server, you’ll probably want it to boot up when the host OS boots, and shutdown cleanly when the host OS shuts down. To enable these settings, open the Virtual Machine Settings window, select the Options tab, then select the “Startup / Shutdown” category. On the right, set:

  • On host startup - Power on virtual machine
  • On host shutdown - Shut down guest operating system

Clock Hacks

On my hardware, when the guest OS is running and even during installation of the guest OS, the following message is printed repeatedly and rapidly on tty1 of the host OS:

rtc: lost some interrupts at 512Hz.

Aside from making tty1 pretty much unusable, this doesn’t seem to be serious problem except that it indicates that the guest OS’s clock is almost certainly losing time.

The VMWare Knowledge base article 1420 provides work arounds for slow or fast running clocks. In my case, I created a new Grub profile in the guest OS which I called “CLOCK FIX” to pass a few extra boot params by adding the following to /boot/grub/menu.list:

title           Debian GNU/Linux, kernel 2.6.18-5-486 CLOCK FIX
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.18-5-486 root=/dev/sda1
                    ro nosmp noapic nolapic
initrd          /boot/initrd.img-2.6.18-5-486

Then make sure the new entry is set to be the default. The “default” parameter is zero-based, and my new menu entry was the second, so in /boot/grub/menu.lst I set:

default         1

Booting with this profile, the RTC warnings stopped, but after a while I noticed the clock was running significantly faster than the host OS clock, so I updated my CLOCK FIX Grub profile to also include the clock=pit boot parameter as described in the knowledge base article:

title           Debian GNU/Linux, kernel 2.6.18-5-486 CLOCK FIX
root            (hd0,0)
kernel          /boot/vmlinuz-2.6.18-5-486 root=/dev/sda1 ro
                    clock=pit nosmp noapic nolapic
initrd          /boot/initrd.img-2.6.18-5-486

VMWare Tools and Host to Guest Clock Sync

Next we need to install VMWare Tools in the guest OS so that it can sync it’s clock from the host OS as described before. The aforementioned howtoforge post walks us through this.

My host OS doesn’t run X Windows so vmware-toolbox can’t be used to enable host-to-guest time sync. This can be enabled manually by shutting down the guest OS and setting the following parameter in the virtual machine’s .vmx file:

tools.syncTime = "TRUE"

It seems like this option should be available through the Virtual Machine Settings dialog box, but it’s not.

Now, booting into the guest OS again, we should find that it’s clock is showing the same time as the host OS’ clock.