This is a little off topic, but it took me a while to find the fix: if you’re running CentOS on a Virtual Server and you find the clock is racing ahead, read on.
I’ve just been updating software on one of the servers I use, in advance of the launch today of a new website I’ve been working on for a client; I wanted to make sure that it was up to date with all the necessary security fixes and so forth, before unleashing it on the world.
So, I’ve updated the Plesk control panel, and all the various CentOS packages. And everything looked pretty normal. And then the messages began to arrive from users of another of my sites, the Toppy.org.uk forum, which is used by many PVR users.
The forum, they said, was telling them they couldn’t post so soon after their last one, misdating posts, not showing posts since their last visit correctly, and various other issues, all time related.
And, yes, the database for that forum runs on the same server that I’ve just updated. My first thought was the timezone was wrong – and yes, once again, a Plesk update had changed the timezone to somewhere in the US, for reasons best known to itself.
But, fixing that wasn’t enough. It was still wrong, and a check showed that it was actually running almost double speed. Manual pages weren’t much help, and it took a while with Google to turn up some useful results – looking for something like ‘centos virtual server’ does tend to bring up far too many useful hits, but along the way I found a page at Microsoft that referred to problems on a Linux kernel in a virtual host environment, plus a bug report on another version of Centos.
That gave a few more clues, and the fix I found was contained in this post on the VirtualBox forum.
Essentially, the fix I’ve adopted has been to add the following boot options to the virtual server’s config
noapic nolapic nosmp divider=10 nolapic_timer
On the 1and1 virtual server I’m using, the way to do this is pretty straightforward. Log in to the server, via ssh or the serial console. Change directory to /boot/grub and edit the file grub.conf
You’ll see various entries that start “title Centos”, each followed by three indented lines, beginning “root”, “kernel” and “initrd”. The entry you need is the default, which should be the first one – it’ll have the most recent kernal version listed as part of the title.
All you need to do is add the options to the end of the appropriate kernel line, which on the virtual server will probably already have an option like this for the serial console access via the 1and1 control panel
So, just add the new options to the end of the line
console=tty0 console=ttyS0,57600 noapic nolapic nosmp divider=10 nolapic_timer
then save the file, and restart the server with
shutdown -r now
When it’s started up again, sync the time
and hopefully all will be back to normal.
And, I hope this helps anyone else with the same problem who’s been trying to track down a speeding clock.