Oct 2

VirtualBox 3 will allow you to have up to 8 virtual interfaces per VM. 4 of those you can create and control via the GUI, the other 4 you will need to use the command line for. No fear, Virtualbox makes this a very simple operation.
Here I’m adding virtual interface number 5 to a VM named pfsense. I’m setting that interface to be bridged to eth5 and making sure that the virtual cable is plugged in.

VBoxManage modifyvm pfsense –nic5 bridged
VBoxManage modifyvm pfsense –bridgeadapter5 eth5
VBoxManage modifyvm pfsense –cableconnected5 on

It’s that simple. You can use all of the connection types (nat, etc) and even change the type of nic hardware. It’s all fully documented on page 110 of the user manual.

Aug 10

When you are working with VMs, the hierarchy of needs tends to be Memory, Storage, Network, CPU.  You can never have too much RAM when you are talking about a VM server.  Since you usually consume all of your memory first, it’s nice to have a little one liner that lets you know how much memory you have allocated to VMs, and using the VirtualBox command line, this does exactly that. You’ll note that this isn’t my best work, but it’s quick and I’m not worried about all of the forking because we’re only talking about a dozen or so lines at most. Feel free to add tweaks in the comments if you can pretty it up!

VBoxManage list -l runningvms |grep Memory | awk {‘print $3′} | awk -F”MB” {‘print $1′} | echo `sed ’s/$/+/’` | sed ’s/+$//g’ | bc

Or this one is a little fancier and takes the total memory installed in the system, subtracts the VM memory in use +512 for the host and gives you the total physical RAM left for VM usage

VM=`VBoxManage list -l runningvms |grep Memory | awk {‘print $3′} | awk -F”MB” {‘print $1′} | echo \`sed ’s/$/+/’\` | sed ’s/+$//g’ | bc`; MEM=`grep MemTotal /proc/meminfo | awk {‘print $2′} | sed ’s/$/ \/ 1024/g’|bc` >/dev/null; echo “$MEM – $VM – 512″ | bc -l

Aug 5

I have really enjoyed Beta3 of virtualbox and have stood up a server that runs headless in my  basement and acts as my VM host. I have about 6 VMs running at any time but don’t have easy access to the VirtualBox GUI. Fortunatly, VBox has a really great command line that allows me to do pretty  much everything I need right from the shell. Here is an example of creating a new VM called Zenoss with 1548MB of RAM, a bridged network connection using the hosts eth0 adapter, a 10G drive and running in headless RDP mode at boot. The iso image “test.iso” is mounted at boot time, so the VM will boot from the CD at first boot.

VBoxManage createvm -name “Zenoss” -register
VBoxManage modifyvm “Zenoss” -memory “1548″ -acpi on –bridgeadapter1 eth0 -nic1 bridged
VBoxManage createvdi -filename “Zenoss.vdi” -size 10000 -register
VBoxManage modifyvm “Zenoss” -hda “Zenoss.vdi”
VBoxManage registerimage dvd test.iso
VBoxManage modifyvm “Zenoss” -dvd test.iso
VBoxHeadless -startvm “Zenoss”

Jul 22

Jolicloud and ubuntu netbook remix are minimal linux distributions designed to run on netbooks. Netbooks don’t have CDROMs but can boot from USB.  VirtualBox doesn’t support booting from USB, but can boot from CDROM.  I am running Alpha 2 of Jolicloud and wanted to install it in VirtualBox before I put it onto any real silicon, but since VB doesn’t have USB BIOS support, I quickly ran into a hurdle.  I figured the easiest way around this little problem was to simply create a VB disk image (vdi), write the jolicloud boot image to that vdi and just boot it that way.  Fortunately, this turns out to be a simple one liner. Substitute the correct path if you are on a linux host.

“C:\Program Files\Sun\xVM\VirtualBox\vboxmanage” convertfromraw jolicloud-robby-alpha2b-live.img jolly.vdi

When that finishes, you will have a 600MB file called jolly.vdi. Just add that to VBs disk manager as the primary drive in a new VM, add another disk as a secondary drive and install away!