Time Synchronization Solution Ubuntu Server

Discussion in 'Linux Virtual Machine' started by irelandshope, Aug 21, 2007.

  1. irelandshope

    irelandshope Junior Member

    Messages:
    14
    I recently installed Ubuntu Server 6.06 LT into a Parallels VM and found that the system time/clock ran fast to the extent that it would gain 5 or 6 hours in a 24hr period. I am new to Linux and it took me a long time and many searches to get it resolved. I thought I would share my experience to help anyone else in a similar position. As a disclaimer I will say again I am new to Linux so this may be old hat to Linux guru's and I may have committed all sorts of Linux no no's, let me know if anything is way off. I'll also point out this is Linux Server so its all command line stuff. I'm using Parallels 3 for Mac but I think the problem is common to Ubuntu in virtual machines in general.

    The problem as far as I understand it is, the way the Linux Kernel calculates time gets screwed up by being in a virtual machine. It seems this is common across Parallels, VMware and Microsoft's Virtual Machine product. I was unable to install the Parallels Tools for Linux as they don't support a non GUI server, so no time sync there. The solution is to change the method that the Kernel uses to calculates time. I eventually through many sources I was able to piece together the following.

    The boot loader file must be modified to tell the kernel to calculate time using a different method. So we need to edit the boot-loader file /boot/grub/menu.lst, So at the command line type,

    This will open the file in the nano editor, read down the file until you see

    Then change it to (dont uncomment the line)

    Then continue to read on down the file until you get to the list of different Linux Kernels it's just below ## End Default Options ##. By default you will be booting the first kernel and again you should add the clock=pit to the Kernel line so it looks something like this

    Now restart the system and the system time / clock should run accurately. Mine now gains about 2 seconds every 24hrs which is very acceptable.

    If you want to get even more anal about it you can have it synchronize with a time server once a day by.

    This will open the crontab for editing, put in the following. (Crontab runs jobs on a schedule).

    This will mean at 6am everyday the clock will sync with the time server ntp.ubuntu.com.

    That's it, it worked for me, your mileage may vary.
    I hope this helps.
     
    Last edited: Aug 21, 2007

Share This Page