Tuesday, December 21, 2010

Breaking up with VMware at home. Hello Virtualbox..

For several years I have run many VMs at the crib using VMWare server. It is free and easy to use so it was a great choice for the house. I could see past all the bloat of the tomcat web interface stuff since it was easy to use and maintain. Well recently a security vulnerability came out for VMWare Server and if you run it on linux you are SOL. I finally found the motivation to move to VirtualBox.

First thing I did was shut down all of my existing VMWare VMs. I then issued the command:
sudo /etc/init.d/vmware stop

In my experience this is not enough to kill all of the tomcat crap so find those lingering processes and knock them down kill -9 style.

The next thing I did was make a copy of my current virtual machine so if I jacked something up I could always fall back to VMWare. Since VMWare has root owning the Virtual Machine you need to own it like pow.
sudo cp -R (vmwarevmpath)/(vmname) /whatever/vmname.vbox
sudo chown -R me:me /whatever/vmname.vbox

Ok so now we got the hard part done so lets go ahead and install VirtualBox. This is an Ubuntu 9.04 jaunty box so I did the added following to my /etc/apt/sources.list. If you are using a different Ubuntu version substitute your version:
deb http://download.virtualbox.org/virtualbox/debian jaunty non-free

If you are using something other than Ubuntu install VirtualBox following the instructions for that distro. Let's continue on for those using Ubuntu:
wget -q http://download.virtualbox.org/virtualbox/debian/oracle_vbox.asc -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install virtualbox-3.2

Ok now we need to do a little more prep work so we can get this rocking. Add your userid to the vbox user group:
sudo useradd -G vboxusers me

Log out then back in and you should be cool to continue. Ok time to make the donuts. First lets find the correct OS type.You do this with issuing the following:
$ VBoxManage list ostypes

This will give you a big list of OS types. Find the one that applies to your old VM. I was running Ubuntu 64 bit on this particular VM. So lets register our new VM.
VBoxManage createvm --name "SweetVM" --ostype Ubuntu_64 --register

VBoxManage storagectl Ubuntu --name "IDE Controller" --add ide
VBoxManage modifyvm "SweetVM" --hda "/whatever/vmname.vbox/SweetVM.vmdk"


When I ran the modifyvm command originally it complained about the IDE controller so I did some googling and found the IDE controller stuff. I had my vmware disk busted into 2 gig files and Virtualbox didn't hate on me. I read some stuff about converting stuff to the virtualbox native format but I figured what the heck and pointed it at the VMWare virtual disk file and it was cool and the gang.

At this point I started it but found I had no network card listed. So let's add a NIC:
VBoxManage modifyvm "SweetVM" --nic1 bridged
VBoxManage modifyvm "SweetVM" --bridgeadapter1 eth0

So I added an interface to the VM that is a bridge adapter as well as pointed the VirtualBox secret sauce to bridge that traffic on eth0 on my host box. There are a lot of other things you can add to your vm via the modifyvm command depending on your hardware needs inside your vm. For a full list check out this link.
Now for the purpose of testing lets fire it up with the remote console enabled so we can make sure everything is working.
VBoxManage modifyvm "SweetVM" --vrdp on --vrdpport 6464 --vrdpauthtype null --vrdpmulticon on

Now kick the tires and light the fires. I brought it up in the foreground so I could watch any errors:
VBoxHeadless --startvm SweetVM

You should see:
Oracle VM VirtualBox Headless Interface 3.2.12
(C) 2008-2010 Oracle Corporation
All rights reserved.

Listening on port 6464.


Now go ahead and connect via a rdp client to your host ip and the port you specified. I specified port 6464. When I connected to the box for some reason eth0 was missing. When I did an lspci it was finding an Intel nic. I found that my NIC was now eth1 so I modified my netowrk config in /etc/network/interfaces and changed everything to eth1. After I did that I did a:
sudo ifconfig eth1 up

Make sure you can ping out and all that jazz now shutdown your VM. Now lets shut off console access to the VM:
VBoxManage modifyvm "SweetVM" --vrdp off

Now we are ready to start this thing and toss it in the background so we don't need to see it any more.
nohup VBoxHeadless -s SweetVM&


That's it.. I am now Virtualbox at the crib.