Wednesday, November 9, 2011

Creating VMs from an existing VDI file

We recently had a request to install VirtualBox and a custom VDI for a course. Students with little technical backgrounds needed to be able to launch and create a individual instance of an Ubuntu virtual machine.
We did some experimentation on configuring the virtual machine with a shared VDI file and using VirtualBox snapshots, as well as shadow disk images, for saving changes. We decided the best course was to drop a copy of the entire VDI to the students Desktop and use VirtualBox's command line tool to configure them a VM.
We stored the VDI inside a disk image and delivered it to the /Users/Shared folder of each Mac. We then had VirtualBox installed. Using Platypus we wrapped a script that will copy the VDI, create the VM, and start it.
If the VDI already exists on the desktop, the VM is created and launched. If the VM is already created, then it's launched right away.
This provides students and faculty with a simple way to launch and use the virtual machine provided to them.
Here is the script that we use: https://github.com/rustymyers/scripts/blob/master/shell/createVBoxVM.sh

After writing this, I got a lot of comments that we should check out Vagrant. http://vagrantup.com/
Do your self a favor and always google what you want to do before writing something from scratch to do it!

No comments: