We use various VM templates which we sysprep after configuring. I have used both Virtual PC and VMWare Workstation. I have had far better results and experiences with VMWare workstation. Most of our VM templates were created using 8 GB virtual hard drives. Often we added a second drive to handle additional data and expand our capacity. Recently my work with SharePoint 2003 and MOSS 2007, I have had very little success keeping my primary drive to obediently remain a nice 7GB or below (to prevent swapping and such). I’ve even moved the virtual paging memory file to my secondary virtual drive, but in the end this has been frustrating and limited.
In my frustration, I sought out a solution on the web. I tried various methods for resize my existing virtual drive … some with more success than others. I am sharing the method which I found the easiest and least error prone for what I needed. Having said that, this may not work for you and you should backup your VM’s and data before attempting any of this. Try this at your own risk!
I found a program called Virtual DiskManager from RDPSoftware which does that trick. This program is a front-end for VMWare’s vDiskManager. The VM templates were created in VMWare Workstation 4.5. Currently (at the time of this writing), I am using VMWare Workstation 5.5. The following are the steps I took to resize my virtual drive from 8 GB to 30 GB (you can easily resize it to any size you require as far as I can tell):
Resizing the Virtual Hard Drive
- Opened the original VM Template in VMWare and upgraded it to a 5.5 VM.
- Create a full clone from the VM to eliminate any snapshots.
- Run Virtual DiskFactory (VMWare DiskManager would work too) and click on the Expand tab.
- Enter the desired target size (30 GB in my case).
- Browse and choose the Virtual Disk Drive to resize.
- Click on Expand Disk. Mine was disabled because I did step 5 and then step 4; Click on the browse button and close the dialog … it should enable the button.
- Go get coffee while you wait
- Once complete, you can use your newly resized VM Template. I have backed up these VM Templates so that I don’t have to perform these tasks again.
Now for the interesting part … if you open the VM (don’t do it yet) you will find that you have a 30 GB drive but you still have the 8 GB partition. In this example, I want to use all 30 GB but this poses a problem since the operating system is sitting on the primary partition; the same drive I want to repartition. My solution is to map this virtual drive as a secondary drive to a different temporary VM. I have created a separate temporary VM from the same VM template for repartitioning the resized virtual drives.
- Create another VM instance (preferably from the same VM Template) to use for repartitioning.
- Run Virtual DiskFactory (VMWare DiskManager would work too) and click on the Rename tab.
- Rename the newly resized virtual drive to make sure it won’t conflict with the virtual drive from our repartitioning VM. I renamed my virtual drive to “RenamedDisk.vmdk”.
- Run Virtual DiskFactory (VMWare DiskManager would work too) and click on the Convert tab. This step may not be necessary for you, you can try step #6. If you cannot add the drive, come back to this step.
- Convert your virtual drive to a Growable … catch up on some emails and the latest YouTube videos.
- Edit the Virtual Machine Settings and add the existing virtual drive (i.e. RenamedDisk.vmdk). Mine is now on IDE2.
- Start the VM.
- Go to the Administrative Tools and run the Computer Management console. Under Disk Management, make sure the second drive is recognized and has a drive letter. If not, add it and give it a drive letter.
- Using the diskpart.exe tool from Microsoft and the “How to use DiskPart.exe”. Force the partition to take the new partition size. This is from the How-To with a couple modifications:
- In a command prompt, run “diskpart.exe”
- Type “list volume” to display the existing volumes on the computer.
- Type “Select volume [volume number]” where volume number is number of the volume that you want to extend.
- Type “extend [size=n] [disk=n] [noerr]” to extend the volume. For example, in my case I used “extend” to use all the space.
- Once done, type “exit” to quit Diskpart.exe.
- Now you can restore the resized, extended ad renamed virtual disk to the original VM location. You can remove the old drive reference and add the new drive as is, or you can rename the disk to its original name. The VM should load just fine, and the drive should have taken its specified size.