Increase your Virtual machine's disk capacity
Background
The geekzilla team have been using VMWare for over a year now for desktop virtualisation. There are loads of benefits of virtualisation, but the most obvious one for me is increased stability.
For years I had a single machine with every tool under the sun installed, and stability was a real issue. Today I have a basic Windows Vista host, with e-mail, office and web browsing capability and VMWare that I use to run specific virtual machines for different tasks.
Problem
Everything has been great with my development Virtual Machine. The main hard disk was sized to 10Gb, with 2Gb free. But when I needed to install Visual Studio 2005 SP1 and SQL Server 2005 SP2 I ran out of disk space. I tried to increase the size of the disk using VMware's diskmanager but ran into a number of difficulties along the way.
Solution
Okay first thing to do is to check the VMDK (virtual machine disk) integrity. I chose to run checkdisk within my Virtual Machine. You'll need to reboot and the disk will be checked before the machine starts.
Once you're happy with the integrity of your disk its time to expand it. Using vmware-vdiskmanager. You must power the machine off first in VMWare workstation or VMWare Player.
Navigate to your VMWare folder and issue the following command from the command prompt, passing -x to increase the size followed by the new size (e.g. 20Gb), followed by the path to the vmdk file you want to resize.
C:\Program Files\VMware\VMware Workstation\vmware-vdiskmanager -x 20Gb "d:\VM Folder\vmdiskfile.vmdk"
This will take some time, and once complete the application will give you some sizing messages.
Now you need to expand the capacity of the disk to take advantage of its new size. If the disk is the system volume you will need to mount the disk in a second VM and expand it from there. If its not a system volume do it within the virtual machine it belongs to.
Once you've mounted the disk in a different VM or booted up the VM it belongs to if its not the system volume, do the following.
Go to the command line and start the diskpart utility. By issuing the following command.
diskpart
Once you've started diskpart, list the drives using the following command:
list disk
This will show you the disks assigned to your machine. Now the important command
list volume
This will show you the drives, their volume number, capacity etc. You now need to select the volume you are about to expand, using the following command. Where n is equal to the number of the volume.
select volume=n
Once selected, you can now expand it using the extend command. You can optionally specify the amount extend it by.
extend
That's it.
Once you've extended the disk, it's wise to defrag the drive. If you use the defragment tool in VMWare workstation you will find it much quicker than deframenting the drive from within the machine.
Summary
Virtualisation is great. Using an external Hard Disk, take regular snapshots of your Virtual Machine as a backup. I was fortunate to have backups prior to VS2005 SP1 and SQL 2005 SP2 trying to install on the disk when there was insufficient capacity. For some reason SQL 2005 became unusable as a result.
I hope you have discovered how useful Virtualisation, especially for developers.
If you ever run out of disk space on your Virtual machine you can use the technique above to extend the drive's capacity.