Expanding a drive within a VMWare image
There are many ways to expand a drive within a VMWare image and I have outlined two approaches below depending on your setup. I have used both these methods successfully on a Windows Server 2003 Vmware image (Vmware Workstation 5.0)
Advantages: You get to keep your Vmware snapshots
Limitations: You can’t extend all volumes, I had trouble trying to extend the system/boot volume. According to a Microsoft Knowledge Base article you can’t extend a volume if the system page file is located on the partition. You could try to move the page file to a partition that you do not wish to extend.
C: System Drive 10 GB
D: Data 4GB
Let’s say that we want to expand the D drive from 4GB to 10GB
- Shutdown the VMWare Image
- Add a new disk to the VMWare image (the size should be that which you want to allocate to another volume, in this example 6GB).
- Boot up the VMWare image into Windows and go to Disk Management (Administrative Tools -> Computer Management -> Disk Management)
- A wizard should be displayed to initialize and convert the new disk. If you are not prompted then you may need to Rescan. Do not assign a new volume at this stage.
- You need to convert the D drive and the new drive to both be dynamic disks.
- Once both the drives are dynamic, then right click on the D drive and select Extend Volume.
- Follow the wizard to allocate the new space to the D drive.
Once you complete the wizard, the D drive should now be 10GB. That’s method 1 complete. If this worked for you, great! If not then take a look at Method 2 below.
Advantages: You can successfully expand a system/boot drive.
Limitations: You have to remove all your snapshots (the vmware-vdiskmanager utility requires this.)
Let’s say that we want to expand the C volume from 8GB to 12GB. Assume that the C drive is full to capacity (that’s why we are expanding it right!)
- If the Vmware image is running, shut it down.
- You need to find the name of the Vmware (.vmdk) file that represents the virtual disk that you want to expand. Go to VM->Settings and locate the drive
that you want to expand. The disk file field on the right hand side will display the name of the .vmdk file.
- You need to remove any snapshots present in the Vmware image. Note: By deleting the snapshots the system still remains in its current state.
- Open up a command prompt and issue the following command: vmware-vdiskmanager -x 12GB “Windows Server 2003 Standard Edition.vmdk” where 12GB is the desired size of the expanded volume.
- This expansion may take a while but when it is complete, boot up into Windows and go to Disk Management (Administrative Tools -> Computer Management -> Disk Management)
You should see something similar to the following screenshot. The disk has been expanded but the new space is as yet unallocated. Now in theory you should be able to use the Windows diskpart utility to allocate this space but this would not work on a boot/system disk for me.
- So with diskpart not up to the task, what are your options?:
- Buy some Windows partition software (i.e. Partition Magic) at a cost of USD200- USD300 for a Server edition or
- You could use Knoppix (free) to allocate the new space to the C drive. Knoppix is a bootable Live Linux CD and it happens to have a utility called QTparted.
Lessons for the future:
When you are creating future Vmware image make sure to allocate plenty of space to the drives.
You can set that they only grow as required so they only ever take up the space that you require at any point in time.