I recently had to look at expanding the capacity of the C: drive on a virtual server running Windows 2003, as the existing C: drive had completely filled up, despite us having installed all applications etc on a second, dedicated virtual drive (perhaps I’m showing my age, in IT-years, but I remember fitting a complete installation of Windows onto 4Gb drives and still having room left over for applications and data. Ah, good times).
Anywho, there seem to be a number of articles documenting different ways to expand the C: drive using third party tools such as Partition Magic, so I thought I’d document the method I used this morning, using nothing more than the VSphere client and Windows 2003 diskpart tool. It took less than 5 minutes, and the server booted back up with not so much as a whiff of a blue screen of death (always a concern when you mess with the boot volume!)
Firstly, remove any snapshots that you have for the Virtual Machine.
Next, shut down the virtual machine and resize the affected hard drive using the VSphere client. In my case, I increased it from 20Gb to 40Gb. This increases the size of the virtual drive, but doesn’t change the size of the c: partition.
Now, you must attach the virtual hard drive to a second virtual machine. The reason for this is that Windows won’t let you extend the partition of the boot/system volume. Attaching it to a different VM as, for example, the E: drive gets around this restriction. In my case, I had to open the Disk Management tool and assign the virtual disk to E: as it wasn’t automatically given a drive letter.
Now, open a command prompt and run the diskpart tool. At the diskpart prompt, type “list volumes” to show all available volumes. Each will be assigned a number, mine was number 2.
Select the volume using the “select volume 2” command, and finally use “extend” to extend the partition to the full size of the drive. Extend does take option switches that let you control how far to extend but if you omit these, it’ll extend to the end of the virtual hard drive (40Gb in my case).
Now, shut down the second virtual machine and remove the virtual hard drive from it’s settings.
Boot up the original virtual machine. If all goes according to plan, the C: drive will be the new size, although you will probably have to reboot the server once more as Windows will give you with the “found new hardware” prompt.
I should point out I did this on ESXi 5 using Windows 2003 Standard with SP2. If you attempt this, make sure you have a good backup of the virtual hard drive in case it all goes pear shaped and you have to restore!