30 Jul
The other day I had an issue with my main Virtual Machine (VM) image at work. Inside the VM runs a version of Windows XP SP3 that I use for application automation testing and manual testing. The issue I was having was my VM was out of virtual disk space.
On my work laptop I run 64bit Arch Linux and the virtual machine software I run is VirtualBox version 3.0.2. VirtualBox has server me well over the past few year, but the one issue I have always run into with running VMs is disk space constraints. I typically give a VM the least amount of space it will need to run the operating system and the essential applications that I will need for testing and/or development. For Windows XP that is usually 8GB and for Windows Vista it is about 10 to 12 gigs.
So as I mentioned, I was running out of space on my main VM. I bitched about it on identica/twitter and received a great response to my complaining. Excid3 mentioned that I should create a new larger virtual disk and then use dd to clone the original virtual disk over to the new virtual disk. Once I read that it was like getting slapped in the face. I was shocked and ashamed that I never thought of doing that in the past.
The last time I looked into cloning a virtual disk, I did a google search and most of the suggestions mention creating a second virtual disk, but then using something like Symantec’s Ghost, PartImage or Clonezilla to perform the task of duplicating the disk data structure. I tried this solution once before and it ended in disaster and a waste of time.
Now with new insight and a fresh idea [something I should have thought of before] I set up to add a bit of extra space to my main dev/test VM. First I created a new 10GB virtual disk using the VirtualBox Virtual Media Manager. While creating the virtual disk I was downloading the ISO image of SystemResuceCD. Once the virtual disk was created, I went into the settings of my VM and added the new virtual disk as a secondary IDE drive. I then set the VM to point to the SystemRescueCD ISO and boot from that ISO image. Once I was booted into the SystemRescueCD environment I executed the following command:
dd if=/dev/sda of=/dev/sdb bs=64
I let the duplication process run it’s course, which took about 15 to 20 minutes. Plus, since I am a bit paranoid, I was running the following bash script from a terminal on the physical system from inside the folder that holds my virtual disk to make sure the virtual disk was being created:
while x=0 do ls -lh *.vdi df -h | grep home sleep 2 done
Once the dd process was complete I shut down the VM, released the SystemRescueCD ISO image, then I changed the order of the primary virtual disk to the new disk and booted the VM to make sure the all was good. Once I was certain the new virtual diskĀ was good, I shut down the VM, re-mounted the SystemRescueCD ISO to the VM and booted the VM to re-enter the SystemRescueCD environment. Once inside, I ran a startx to bring of a graphical interface for running gparted (Gnome Partition Editor). I then used gparted to expand the unused portion of the virtual disk from 8GB to 10 GB. Once that was completed, I rebooted the VM & unmounted the ISO. Windows run a CHKD on the expanded virtual disk and my VM came to life with an addition 2 gigs of space.
Thanks to Excid3 I now have a new & quicker process for expanding the virtual disk size constrains I set upon myself.
-Ken