Setting the UUID of a VirtualBox VDI

I wrote this script over a year ago because I needed a way to set the UUID of a VirtualBox hard disk (VDI) to a specific value. It will allow you to set the UUID in the headers of a VDI to a specific value.

To use this script:

./set-uuid.py {6918cef1-d9c4-4420-b0ef-01920c992a25} path/to/virtual-disk.vdi

The dashes and brackets are not required.

The script is available on my GitHub site: https://github.com/jordoncm/misc/blob/master/set-uuid.py

We had been distributing a VDI as the only file on a second physical hard drive on a dual hard drive Windows system and we wanted to be able to upgrade systems by simply removing the second hard drive with the VDI on it and putting in a new one. However the UUID of the new VDI we created did not match the UUID of the virtual hard disk record in the XML configuration of the virtual machine. So I read up on the binary header block of a VirtualBox VDI and wrote a Python script that will allow you to change the UUID to whatever you want.

It seems that VirtualBox may now have some internal commands to do this now as well, although I am not sure they are released or officially supported.

http://forums.virtualbox.org/viewtopic.php?f=6&t=4821&start=15

Bridged Networking with VirtualBox

I have been playing around Oracle 11g and Microsoft SQL Express inside of virtual machines. I wanted to be able host these databases to other computers in my LAN which meant the virtual machines needed an IP address on my subnet. I am using VirtualBox to host the virtual machines and unfortunately bridged networking (needed to make this work) is not setup when you install VirtualBox. However I found this walkthrough and I worked really well.

The guide is written for VirtualBox 1.6.2 but it worked fine for me in version 2.0.4.

http://samiux.wordpress.com/2008/07/30/bridging-virtualbox-162-on-ubuntu-8041/

For quick reference the basic steps are:

Install bridging utilities.

sudo apt-get install uml-utilities bridge-utils

Change the permissions of this file so others can access it.

sudo chmod 0666 /dev/net/tun

Add the bridge to the networking configuration (you can give the bridge device a static IP if need be).

sudo vim /etc/network/interfaces
auto br0
iface br0 inet dhcp
bridge_ports eth0
bridge_fd 9
bridge_hello 2
bridge_maxage 12
bridge_stp off

Restart networking.

sudo /etc/init.d/networking restart

Add a virtual network device to the bridge

sudo VBoxAddIF vbox0 `whoami` br0

Then you can in and assign the virtual machines networking configuration to Host Interface: vbox0. Something to note is that only one virtual network interface can be used at a time. So if you want two virtual machines to run at the same time using the bridge, you have to create additional ones (sudo VBoxAddIF vbox1 `whoami` br0, etc) and assign them to machines accordingly.

Demoing Distributions

I finally got my big desktop computer organized and rebuilt to the latest version of Ubuntu. The computer has two 500GB SATA drives on it, so I also put Sun's Virtualbox on it and am now downloading Open Source operating systems like crazy. I have already got two Linux distributions and one Unix installed and about five or so more downloaded.

I want to get back into trying out all kinds of distributions again because for about the past year I have stopped hopping from one distribution to the other and settled on Ubuntu. So I am a bit out of touch on non-Debian based operating systems.

I have been taking some notes on my experience installing and playing with these systems and I will post my thoughts here as I get time.

Xen on Ubuntu 8.04 (Hardy Heron)

I have been setting up Xen based virtualization and I just wanted to post the useful links I have found. Unfortunately (at the time of this writing) there are couple of bugs in the Ubuntu repositories for Xen that can make installing and configuring Xen a bit of a headache.

This article on HowtoForge pretty much gives you everything your need to get going (even how to get around the current bugs).

http://www.howtoforge.com/ubuntu-8.04-server-install-xen-from-ubuntu-repositories

This is the user manual for Xen. Unfortunately it is not very descriptive in places, but it is still a good resource.

http://tx.downloads.xensource.com/downloads/docs/user

This is the manual page for xen-create-image. It has some really great examples to base your DomU creation commands from.

http://man.cx/xen-create-image

Below is the Ubuntu community documentation for Xen. They still need some time to update to Hardy.

https://help.ubuntu.com/community/Xen