Sunday, March 2, 2008

Creating VM's in a breeze

CreateVM is a shell script I created to automate the process of creating VMware virtual machines (VM's). It makes it trivial to create one or more VM's with specific conditions.

At work I used this script to create VM's with static MAC addresses which are known in our DHCP server, and it helped me a lot to instantly have a clean VM while working on unattended OS installations.

The script is written in bash and runs on any system which supports bash. It depends on vmware-vdiskmanager , which is included in VMware Server and VMware Workstation.

To run the script you first need to download it.
wget -O

Once downloaded you have to flag it executable:
chmod +x

Now you can run the script. Run it without any parameters to see the options available:

The script has one parameter that needs to be set, and that is the guest OS you want to run in your VM. To see a list of OS'es that are supported run the script with parameter -l :
./ -l

To create your first VM decide on which Guest OS you want to run and pass it as the first parameter to the script. In this example I am creating an Ubuntu virtual machine:
./ ubuntu

To create the same VM with some more memory pass the -r (for ram) parameter with the wanted RAM value:
./ ubuntu -r 512

The script will display a summary of what will be created (see screenshot). The defaults are displayed here. All the settings displayed here can be manipulated by the command line parameters.

To see some of the examples of creating Virtual Machines run the following command:
./ -ex

Any major updates on this script will be displayed here.

Screenshot of CreateVM running in an xterm.



Jadu Saikia said...

really good one.

Matthew said...

OMG you sir are the SHIT!!! Nicely done!