Linux (CentOS) Hyper-V time drift

linux timeOverview

In virtual environments CPU processing is shared between the virtual machines, typically this uses a method called time slicing; Each virtual machine is allocated a period of time where the core’s will be free to use, during that period other machines are actually just waiting for their time slice. This generally is a fast process, to fast for us humans to notice.

However Linux machines use the CPU to keep track of time, this is find for dedicated servers where the CPU is dedicated therefore a cycle always takes a specific amount of time. However in the virtual environment where a cycles processing time varies this calculation is no longer accurate. As a result this causes what’s know as time drift, where the clock is not kept synchronized.

How To

The easiest fix is change the way in which the system keeps track of time, you do this by editing the kernel boot options as shown below.

Take care as an error’s will prevent your system from booting.

Make a backup should anything go wrong.

cp /grub/grub.conf /grub/grub.conf.backup

Open the file to make the required changes.

nano /grub/grub.conf

Add the following text to the kernel line.
If the OS is 32 Bit:

divider=10 clocksource=acpi_pm

Or if the OS is 64 Bit:

notsc divider=10

Finally save the file, and reboot the server.

reboot

Technology enthusiastic with many ongoing online projects one of which is this personal blog PingBin. While also working full time within a data center designing and maintaining the network infrastructure.

6 comments On Linux (CentOS) Hyper-V time drift

Leave a Reply to Tom Cancel Reply

Your email address will not be published.