Fix Virtualbox Guest Time Skew

If you have been running a Linux Virtual Machine on Virtualbox for any amount of time, you have probably noticed that clock skew can be an issue. The fix is a throwback I have been using on all our Linux templates for years and had almost been forgotten until we recently built a new Debian Virtual Machine from scratch. We always use ntp for a clock source yet in our new Virtual Machine we noticed after 2 days that our system clock was off by more than 20 hours. After digging through some old notes, our first attempt to fix the issue was to disable host time sync on the Virtual Machine using the VboxManage command on the host as seen below.

After running the above command and checking the system clock the following morning, our clock was still skewed. No we are thinking, what the hell is the problem. Once again, we headed back to our template documentation and sure enough we found fix #2. The solution in our notes point us to a Microsoft Support article available here, which tells us we need to set the clock=pit kernel option to our /etc/default/grub file as seen below.

Once this option was implemented, we updated grub and rebooted our machine with the commands below.

after that was completed, we checked our clock the following day and sure enough, everything was in sync as we expected. While the fix appeared to work, a colleague had made us aware that our fix was deprecated in the newer kernel and needed to be updated. This could be checked by navigating to /var/log/messages and searching for clock. Sure enough, there was a message indicating that clock=pit has now been deprecated and should be replaced with clocksource=pit. Okay, so we edited our kernel options once again in our /etc/default/grub file as seen below and then followed the rest of the steps in our how-to again.

After making these changes, our clock source is ntp and being properly synced and our kernel is no longer complaining about using the deprecated options.

Did you find this article useful? Why not share it with your friends?

Leave a Reply

Your email address will not be published. Required fields are marked *