Upgrading the size of your virtual machines disk

In order to test changes to code I write I often make use of virtual machines as local deployment servers.  From time to time I'll run out of disk space on these VMs so I thought I'd throw something together to explain how I go about resizing the disks.

I use VmWare Server in order to manage my virtual machines but this method should work across the board for the VmWare tools as it makes use of the vmware-vdiskmanager utility.  You can normally find this executable in \Program Files\VmWare\VmWare Server on Windows hosts.

Before upgrading the disk I'd recommend you take a backup of the disk just in case anything goes wrong.  You will also need to remove any snapshots related to the disk.

In order to increase the size of the virtual disk from 8GB to 12GB you would run the following command line (obviously replacing the name of the disk with yours):

vmware-vdiskmanager -x 12GB win2008.vmdk

Once this completes your virtual disk should have been grown to the new size.  What you do now will depend on the platform you are running on your VM.  As I was running Windows on the VM that I expanded I'll take you through the steps I went through to increase the disk size in windows.

To check that the re-size has worked correctly boot up the VM and log in to Windows normally.  You may get a message telling you that you will have to re-register Windows at this point as the hardware has changed significantly.  Once past this go to start -> Administrative Tools -> Computer Management and select Disk Management.  You should then be presented with a similar screen to below, showing the current partition with the additional space that has been created as unallocated.

From here you can use any third party partition manager to extend the existing partition to include the unallocated space. If you're not running a Windows Server variant then you can often use one of the home editions of EaseUS Partition Master or Partition Wizard. If you're using a Windows Server variant then the other way to extend the partition is by using the GParted Live cd.

Boot from the GParted Live CD and choose to use the GParted Live with default settings (first option) . Then choose 'Don't touch keymap' when asked if you want to change the keyboard configuration. Next select either 33 (US English) or 02 (UK English) from the language menu. Hit enter (default 0) to open the GParted GUI.

Right click on the main partition (shown above as /dev/sda1) and select Resize/Move. You can then simply drag the partition into the unallocated space.

Here I have chosen to use all the unallocated space. Click Resize/Move and then apply twice to begin the expansion of the partition. In my case this didn't take long and I was prompted with a message telling me "All operations successfully completed".

The next step is to reboot back into Windows. Normally an automatic CHKDSK will be performed at this point. If it doesn't then I would recommend that you carry one out anyway. Once this is complete go back into your Computer Management screen and if you chose to use the whole disk then you should be presented with a single partition.

Now sit back and enjoy your new free space while it lasts.