Creating VMs

I’ve been working on packaging our application, which has been a bit of a nightmare since we want to package some extra third-party libraries with it and finding the dependencies is proving interesting. Testing the package is also a bit of challenge. If I install the package on my machine, then it picks up the libs the were built locally and everything works. However testing on a fresh install shows up missing dependencies and libs packaged into the wrong locations.

Since I don’t have an extra machine to play around with I decided to install a VM to test against. I’ve traditionally used VirtualBox but this time I decided to try something different. After a bit of searching I decided to give vmbuilder a go. Turns out it was really easy. I made a few modifications to the steps that I’ll document here.


I have my own package repository that I’m using to install packages from using apt. This is handy because unlike dpkg apt will resolve all the dependencies and offer to install them. This repository is simple hosted on an ftp share on my NAS. To save having to add this repository to sources every time I create a VM I instead edited the sources.list.tmpl template file to add my repository.

deb $mirror $suite #slurp
#echo ' '.join($components)

deb $updates_mirror $suite-updates #slurp
#echo ' '.join($components)

deb $security_mirror $suite-security #slurp
#echo ' '.join($components)

#if $ppa
#for $p in $ppa
deb$p/ubuntu $suite main

#end for
#end if

deb ./


If you follow the vmbuilder guide above you end up with a giant command to build your VM. All these options can instead be added to ~/.vmbuilder.cfg.

arch = amd64

mirror =
suite = quantal
flavour = virtual
components = main, universe, restricted
addpkg = linux-image-generic, wget, openssh-server

libvirt = qemu:///system
mem = 1024
cpus = 2
  • mirror: alternate ubuntu repository to download from. This is my closest.
  • components: My app requires nvidia-current so I’ve added the restricted component. Of course without X I won’t be able to run the app, but I’m just testing installation.
  • addpkg: I’ve added openssh-server so I can ssh from konsole. I also had to add linux-image-generic as there is a bug in 12.10 that causes the setup to fail if this isn’t explicitly listed.
  • libvirt: register the vm.


With the above configuration done setting up the VM becomes quite easy:
sudo vmbuilder kvm ubuntu -o --hostname visualcortex --dest /data/VM/visualcortex --bridge virbr0 -v

  • hostname: required to identify the VM
  • dest: where to store the resulting image. Note it does blow away the containing folder
  • bridge: use bridge networking (specifically virbr0) so I can ssh into the machine

To check that the bridge network is up and running you can run:
virsh net-list --all

If everything works you can list the VM with
virsh -c qemu:///system list

or just run virt-manager.

Loading Facebook Comments ...

Leave a Reply

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