Installation and Configuration of Virtual Machines


Wikipedia (virtual machines) states that a virtual machine is a software implementation of a machine or computer, in particular, we shall deal with virtual machines capable of running various well known operating systems like Windows and Linux to name a few. The real computer on which the virtual machines are running is called the host computer or host operating system. Any virtual machines running operating systems are called guests.

Our discussion will cover various implementations of virtual machines including qemu, virtualbox, and vmware running on a real machine running some version of Ubuntu.

There are some notes about virtualization on Apple hardware.


See VmWare.

If you want to startup a Vmware virtual host from the command you can do

   vmware-cmd /virtual_machines/vmware/cscfprint1/cscfprint1.vmx start
where the host in question is on trainer.cscf. Basically look for the file that ends with .vmx, it is a executable =#!/usr/bin/vmware# shell script.


Installation and Configuration on host computer

The real host vmhost206.cscf is used to run the various virtual machines. We begin by installing the requisite packages, namely qemu, kqemu=common and kqemu-source where the latter two packages allow for kernal module that permits greatly improved performance of any virtual machines installed in qemu. Alas the required device file /dev/kqemu is not generated automatically. To do this we do the following
  • create the file in /etc/udev/rules.d/60-kqemu.rules with the contents
         KERNEL=="kqemu", NAME="kqemu", OWNER="root", GROUP="kqemu", MODE="0660"
    Then reload udev configuration by running /etc/init.d/udev reload. (NOTE. This does not cause the /dev/kqemu file file, see below for what will.)
  • The GROUP specification dictates we should create a UNIX group with that name, and any users who wish to launch any virtual machines into that group
           addgroup --system kqemu
           adduser cscf-adm kqemu
  • edit /etc/modprobe.d/kqemu (part of the =kqemu-common) package so that the contents look like
         options kqemu major=0
    (Aside: Not sure why this is necessary)
  • load the kernal module kqemu by running
         modprobe -r kqemu
    This will cause the /dev/kqemu device to be created (udev responds to event requests, so we probably shouldn't be surprised this step was necessary for the creation of /dev/kqemu. Ideally the package qemu-common should have done this for us, I have reported this as a bug in

Installation and booting of virtual machines

First create a virtual disk file using qemu-img, say =gutsy-i386.img. Then install from iso image, namely run (because we are on an AMD64 machine)
      qemu-system-x86_64 -cdrom ubuntu-7.10-server-i386.iso   -hda ./gutsy-i386.img -m 512 -boot d
Then boot the newly installed machine via
      qemu-system-x86_64    -hda ./gutsy-i386.img -m 512 -boot c
By default any virtual machine can access the network that the host machine is attached to. In particular if you installed ssh on the host, you can ssh to any host on the network and it will look like you are connecting from the host computer.

It is possible to assign a network configuration to the virtual machine. For example

     qemu-system-x86_64 -hda /vmdata/qemu/gutsy-i386.img -m 512 -boot c -net nic -net tap
(Aside: To run this as a non-root you need to be in the group vde-net as the device permits users in this group rw access t /dev/net/tun) By default the network configuration in qemu will read the script /etc/qemu-ifup unless a different script is specified on the command line.

Connecting the GuestOS to the same network as the HostOS

For simplicity we shall assume our hostOS is connected via eth0 to the outside internet. First we reconfigure the hostOS's interfaces by creating a bridge br0 with the IP configuration of eth0 and we disable any configuration on =eth0. Next we join eth0 to the bridge and restart networking.

To connect the guestOS to the network of the hostOS start it up with the command line above which will result in the execution of /etc/qemu-ifup which consists of

      echo "Executing /etc/qemu-ifup"
      echo "Bringing up $1 for bridged mode"
      sudo  -p "Password for $0:" /sbin/ifconfig $1 promisc up
      echo "Adding $1 to br0..."
      sudo  -p "Password for $0:" /usr/sbin/brctl addif br0 $1
      sleep 2
We probably could just setup a tap0 interface in /etc/network/interfaces? Note the above script adds the qemu generated tap interface to the bridge when the virtual machine starts up.

Finally configure the guestOS by editing /etc/network/interfaces in the manner you would a real host with an IP address that is on the same network that the bridge br0 has been configured with.

Qemu console

You can access the qemu console by typing CTRL+ALT+2 in the qemu console running any machine. Typing help is gives a list of commands. As an example stop will suspend any machines and cont resumes them.


Installation and Configuration

   $ sudo apt-get update
   $ sudo apt-get install libqt4-network
   $ sudo apt-get install libqtgui4
   $ sudo dpkg -i VirtualBox-3.0.12-54655_Ubuntu_karmic_amd64.deb
This will create group "vboxusers" (all VirtualBox members must be in that group) /etc/init.d/vboxdrv setup to compile the kernel /etc/default/virtualbox holds the location of the kernel module From Gnome Desktop Manager menu select: Applications > System Tools > Sun VirtualBox

Install a virtual guest with expanding storage (in this example name it "VirtualMachineNameHere" /home/username/.VirtualBox/HardDisks/VirtualMachineNameHere.vdi Install the VM with CD/DVD write-through.

Download and install the Sun public key for apt-secure (This may not be necessary).

   $ sudo apt-key add sun_vbox.asc

Add the username to vboxusers group

   $ sudo usermod -a -G vboxusers username

Bidirectional Clipboard sharing requires Guest Additions to be installed in the guest OS. Guest Additions also allows for mouse capture while moving the mouse over the guest window (instead of clicking in the window and enabling "Capture" from the subsequent pop-up dialog box) and better screen resolution. While the guest Windows XP OS is running click on the Sun VirtualBox menucreate group "usbusers" and add olhotak to the group. Then I created file 40-permissions.rules in /etc/udev/rules.d In the file put in the line: SUBSYSTEM=="usb_device", GROUP="usbusers", MODE="0664" Reboot the machine.

I've tested read, write and delete to my USB memory stick. The USB key will only mount in either the VM or the host.

Devices > Install Guest Additions wait a minute for the Sun VirtualBox Guest Additions 3.0.12 Setup. This is installed into the guest WinXP OS. You should now experience a much better screen resolution. A "Sun VirtualBox Guest Additions 3.0.12r54655" icon is now in the WinXP notification area.

USB key recognition will not work. To get it working create group "usbusers" and add user name to the group. Then create file 40-permissions.rules in /etc/udev/rules.d In the file put in the line: SUBSYSTEM=="usb_device", GROUP="usbusers", MODE="0664" Reboot the machine. The USB key will only mount in either the VM guest or the host. Mounting and unmounting USB keys can be done from the Sun VirtualBox menu while the VM is running. Menu Devices > USB Devices > check the devices to be mounted.

The distinction between auto-mounting in the VM or not is determined by the filter settings. If you want a particular USB device to mount automatically in the VM guest add it to the USB Device Filters in the VM guest's Settings.

The CD/DVD drive is recognized by both the Linux host and WinXP guest machines concurrently (probably because it is read-only). If it is unmounted from the Linux machine and ejected it will still show in the WinXP OS. It should be unmounted in the Sun VirtualBox menu Devices to update the Windows OS.

To upgrade the VirtualBox system $ sudo apt-get dist-upgrade $ sudo apt-cache search virtualbox shows virtualbox-3.0 $ sudo apt-get install virtualbox-3.1 shows that virtualbox-3.0 will be removed and new packages installed including libqt4-opengl, libsdl-ttf2.0-0 Run as root $ /etc/init.d/vboxdrv setup

Set up a shared folder between host Linux and guest Windows XP in VirtualBox.

$ cd ~ $ mkdir VirtualBoxShare Make sure the guest OS is not running before proceeding. $ VBoxManage sharedfolder add "lhotakXP" -name "share" -hostpath /home/olhotak/VirtualBoxShare Start the guest Windows XP guest in VirtualBox. Run the command "net use x: \\vboxsvr\share" (without the double quotes)

Browse the Windows file system to find the share on 'vboxsvr' (X:).

External References

Topic revision: r8 - 2014-07-04 - BillInce
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback