I wanted to test a multi-machine solution in VirtualBox, but I was brought up short because the user interface only allows the creation of four network interfaces. I needed 7 interfaces on some of the machines I was created.
The solution is to use VirtualBox's VBoxManage.exe application to create virtual machines from the command line. And once I figured out how to create virtual machines from the command line, I find it easy to create a number of machines, all with consistent properties. Or if some machines require special properties, it becomes easy to adjust the recipe on an individual virtual machine basis. And the if a property needs adjusting, it becomes easy to delete and rebuild the machine.
By putting all the properties into a script file, and then running the file, the properties are updated in the user interface, right before your eyes, as each property is adjusted. This certainly removes a bunch of repetitive point and click. And makes for a reproducible environment.
Read the full article to see the examples.
Here is a common include file I use for the bulk of a configuration. I use this configuration file in a cygwin shell. This makes it transportable between Windows and Linux environments. This configuration is for a simple 64 bit Debian Linux based server.
$ cat vm.common.sh
#!/bin/sh
#http://www.virtualbox.org/manual/ch08.html
#ln -s /cygdrive/c/Program\ Files/Oracle/VirtualBox/VBoxManage.exe vbm
vbm=./vbm
drive1=D:\\Data\\VirtualBox\\$1\\sda.vdi
# delete existing configuration
$vbm unregistervm $1 --delete
# create a new configuration
$vbm createvm --name $1 --register
# basic elements for configuration
$vbm modifyvm $1 --ostype Debian_64
$vbm modifyvm $1 --memory 512
$vbm modifyvm $1 --cpus 1
$vbm modifyvm $1 --cpuexecutioncap 80
$vbm modifyvm $1 --boot1 disk
$vbm modifyvm $1 --boot2 net
$vbm modifyvm $1 --boot3 none
$vbm modifyvm $1 --boot4 none
$vbm modifyvm $1 --audio none
$vbm modifyvm $1 --usb off
$vbm modifyvm $1 --usbehci off
$vbm modifyvm $1 --pae off
# add storage mechanisms
$vbm storagectl $1 --name SATA --add sata --controller IntelAhci --bootable on
$vbm createhd --filename $drive1 --size 16000
$vbm storageattach $1 --storagectl SATA --medium $drive1 --port 0 --type hdd
# standard first nic configuration for pxeboot and management
# mac is assigned in the specific configuration
$vbm modifyvm $1 --nic1 hostonly
$vbm modifyvm $1 --nictype1 82545EM
#$vbm modifyvm $1 --macaddress1 "080027000001"
$vbm modifyvm $1 --hostonlyadapter1 "VirtualBox Host-Only Ethernet Adapter"
Then for each specific virtual machine, I create a script, which calls the above script for any common attributes. 'macaddress1' assigns a mac address for the common interface created in the included file. With this configuration, I am creating a number of private networks. The 'intnetx' names match with like interfaces on other virtual machines, and thus create specific point to point links between machines. [note: the string associated with the 'intnetx' is just a name used for matching purposes, and is not actually performing the ip address assignment] The mac addresses are defined to make monitoring and troubleshooting easier.
$ cat vm.edge1.sh
#!/bin/sh
vm=a.edge1
vbm=./vbm
sh vm.common.sh $vm
$vbm modifyvm $vm --macaddress1 "080027004101"
$vbm modifyvm $vm --nic2 intnet
$vbm modifyvm $vm --nictype2 82545EM
$vbm modifyvm $vm --macaddress2 "080027004102"
$vbm modifyvm $vm --intnet2 "ipv4_10.31.41.2/31"
$vbm modifyvm $vm --nic3 intnet
$vbm modifyvm $vm --nictype3 82545EM
$vbm modifyvm $vm --macaddress3 "080027004103"
$vbm modifyvm $vm --intnet3 "ipv4_10.32.41.2/31"
$vbm modifyvm $vm --nic4 intnet
$vbm modifyvm $vm --nictype4 82545EM
$vbm modifyvm $vm --macaddress4 "080027004104"
$vbm modifyvm $vm --intnet4 "ipv4_10.41.42.2/31"
$vbm modifyvm $vm --nic5 intnet
$vbm modifyvm $vm --nictype5 82545EM
$vbm modifyvm $vm --macaddress5 "080027004105"
$vbm modifyvm $vm --intnet5 "ipv4_10.41.52.2/31"
$vbm modifyvm $vm --nic6 intnet
$vbm modifyvm $vm --nictype6 82545EM
$vbm modifyvm $vm --macaddress6 "080027004106"
$vbm modifyvm $vm --intnet6 "brdg_41.51"