Categories

Archives

 

September 2010
M T W T F S S
« Aug    
 12345
6789101112
13141516171819
20212223242526
27282930  
free counters

HowTo: VirtualBox Guest Additions (Command Line) – Time

Due to the nature of how Virtual Machines are operated, maintaining time is quite difficult.  With the Oracle VirtualBox, this is no exception.  Time keeping on some of my VMs has been a serious issue.

I tried to used NTP to resolve the problem, however the clock accuracy is so poor within the VM, that the offsets and jitters are far too large for the clock correction algorithms to correct.  So an alternative solution was needed.

It appears this was a well documented problem.  The resolution was to make sure that I was using a version where this issue had been fixed in the Guest Additions.

It appears that the Guest Additions were the fix.  I had never loaded these onto a ‘headless’ system, like my servers.  I considered most of the features of the additions were to do with display and input.  It appears it is also of use with this problem of time too.

This article provides instructions on how to install the Guest Additions onto a ‘headless’ server system.

Note: You may need to shut-down your VM to perform these corrections.  I had to, but only to mount the ISO.  Why this could not be achieved ‘hot’ I have to work out.

Note: You may need to adapt this method to suit your set-up.  Don’t forget to correct paths to files to suit your set-up and change the names of your VM(s) where I have used generic names.

Note: Before you start, you must be sure that your VM hosts system has an accurate clock source, e.g. via NTP.  Loading the Guest Additions onto your VM’s will only make their clock as accurate as the host.  Also it appears that the Guest Additions disable all other time synchronisation functions within Linux to ensure they are the master time source for the VM.

Link ISO image for ‘Guest Additions’

First of all, we need to access the VirtualBox Guest Additions CD, which is supplied with the install as a standard ISO file.

As I have a special user called ‘vmuser’ which is used to manage all my VMs, rather than using a root account, I need to gain access to the guest additions ISO image for this account.  VirtualBox installs a copy of the required ISO file in the /usr/share  area on Ubuntu.  As I use a special VM account, it has its own set of ISOs used to build and maintain VMs.  To save on disk space, a link file can be created to the supplied Guest Additions ISO image.

The advantage of linking to this ISO file is that if you ever update the Virtual Box software, then the ISO image will be updated too.  This can be done with the following command in the area you wish to have a linked copy of the ISO image:

ln /usr/share/virtualbox/VBoxGuestAdditions.iso VBoxGuestAdditions.iso

I normally change the ownership of the linked file with the following:

chown vmuser:users VBoxGuestAdditions.iso

Note: Every time you update the VirtualBox software on your host, you need to re-install the Guest Additions of each of the host client systems too.

Attach the Guest Additions

Next we need to instruct VirtualBox to use this ISO and add its details to the library.  To do this, use the following command:

VBoxManage openmedium dvd /home/vmuser/VBoxGuestAdditions.iso

Next, for each VM hosted, we need to attach the registered ISO:

VBoxManage storageattach "Ubuntu Server" --storagectl "IDE Controller"  --port 0 --device 1 --type dvddrive --medium  /home/vmuser/VBoxGuestAdditions.iso

On my systems, the VM had to be stopped in order to attach the ISO and then restarted.  So I stopped each system, attached and restarted.  All the VMs shared the same ISO at the same time.  Why this is I have not figured out as yet.  It was more important to fix the time.

Install the Guest Additions

Now, inside each VM, we can install the Guest Additions and fix our time issue.

First make sure your system is up to date as Kernel level functions are added during installation.  Do this with the following:

# apt-get update
# apt-get upgrade

And follow any prompts.  Now we need to add the ablity to add Kernel level functions with:

# apt-get install dkms

Next we need to access the Guest Additions CD that the host mounted for us:

# mount /dev/cdrom /mnt/

Finally we can run the script to install the Guest Additions:

# /mnt/VBoxLinuxAdditions-x86.run

or if you have a 64bit VM, then the following is required:

# /mnt/VBoxLinuxAdditions-amd64.run

If your system is ‘headless’, then you will probably get the following error message at the end of the install process:

Installing the Windows System drivers …fail!
(Could not find the X.Org or Xfree86 Window Sytem.)

This is because servers do not normally have a GUI and so can be ignored.  Finally dis-mount the CD from inside the VM with:

# umount /mnt/

And that is about it.  The VM clock should remain pretty accurately linked to the host clock.

VN:F [1.9.3_1094]
Rating: 0.0/5 (0 votes cast)

Related posts:

  1. Series: Ubuntu VirtualBox Host II – Completing Install Now that you have the basics of your first Virtual...
  2. HowTo: Change Hostname With root permissions, edit the following file: /etc/hostname And change...
  3. Series: Ubuntu VirtualBox Host I – First Install While planing my move to Orkney, I need to move...
  4. Series: Ubuntu VirtualBox Host III – Control Now that you have the basic controls of your Virtual...
  5. HowTo: Enabling a USB device in a VirtualBox VM in Ubuntu I recently had the need to get a USB to...

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>