I was looking through the Microsoft new groups today and answered a question that I have done a few times so I thought it would be a good time to blog about it here. The task is how to expand a system drive that is running out of space. I used to do this by creating a second VHD that was larger than my original then mount up both to the guest and boot up a BartPE disk and then use ghost to image one disk to the larger disk. This was slow and painful, especially since BartPE didn’t really have any knowledge of virtual machine additions. As more tools for virtual servers came about, this task became easier. Below I outline different ways that I do this.
VMtoolkit VHD Resizer is your friend. All of the techniques below use this utility
The problem with increasing the size of a System partition is that using the built in Windows Server 2003 utility diskpart, will not work for an "active" system drive. This is how it can be done. The trick is to make the system drive a non-active drive or secondary drive.
Use the VMToolkit VHD Resizer utility to increase the VHD file to what you want. This actually creates a secondary VHD file and moves the data over to it. Then mount this VHD file to a drive letter using the VHDMount utility in VS 2005 SP1. Then go to a command prompt, and using the diskpart utility, select the mounted volume and use the diskpart /extend command. This assumes you are using Windows Server 2003 however. Then unmount the vhd, make sure it is attach to the correct virtual guest, and boot it up. You should have an expanded system drive.
Another way to do it would be to use the VMToolkit Resizer and then attach the new VHD to another virtual guest as a secondary drive. Boot the other virtual guest. Once it is booted, go to a command prompt and use the same diskpart routine on the secondary drive as above. Then shut down this secondary guest, detach the drive, reattach it to the right guest and boot. Your system drive should now be expanded.
Still using ghost but faster: Like the old way of creating a secondary VHD file, but instead of booting BartPE in the virtual guest, you will mount both VHDs with the vhdmount utility of VS 2005 SP1 on the virtual host system. Then you will put your BartPE CD that has ghost as an application into the host. Then use ghost to do a disk to disk transfer. The benefits of this is that you use the native speed of the host system drives to do the image from one disk to the expanded disk. I don’t use this option all that often, but it is a viable option for expanding a vhd system disk.
If you have methods of expanding virtual system disks, please drop me a line and let me know.