Expand C Drive on a Virtual Machine
We ran into an issue today, one of our Virtual Machines running Windows Server 2003 had a full C: drive. Turns out whoever had built the box had only given it 7GB for the system drive and we were only about 74mb from maxing it out. I looked around for directions on how to expand the C drive and found some different directions, including these from VMWeekly. His instructions were really long and complicated, but they were my starting place. I found a MUCH easier way to do what I needed to do.
Check it out.
- Shut Down the Virtual Machine (We’ll call it VM1)
-
On the Host machine open a command prompt and go to C:\Program Files\VMware\Vmware Server and run vmware-vdiskmanager.exe -x 15Gb mydisk.vmdk. That will take a few minutes while it resizes the disk.
- Where 15Gb is the size you want your disk to be, and mydisk.vmdk is the path and name of your virtual disk you want to resize (make sure to put it in ” “’s. I forgot.)
- This changes the disk size, but NOT the partition size, which is what you’re really after.
- Assuming you have multiple VMs on this machine, shut down one that’s not system critical. (If you don’t have one, make a copy of the one you’re currently working on and keep going)
- Edit the settings on this second VM (we’ll call it VM2) and on the Hardware tab Add a new existing Hard drive and point it to the original “mydisk.vmdk” (the disk we just resized) thus mounting it as a second hard drive.
- Boot VM2 and open a command prompt
-
Next we’ll use Diskpart to extend the “new” volume on this machine.
- To use Diskpart, just type diskpart and hit enter. This puts you in the diskpart program.
-
Type list volumes
- From the list find your new volume (probably D or E, depending on how many drives VM2 already had. Get the Volume # from it)
- Type select volume # (where # = the new volume from above)
-
Type extend
- This assumes that you’re extending this to fill the rest of the space on the disk.
- You should get a confirmation that it’s done.
- Shut down VM2
- Edit the setting for VM2 and Remove the hard drive that we’d added before
- Now go back and start VM1 and you should find that it has the larger hard drive that you were hoping for!
June 6th, 2007 at 8:38 am
Kyle,
One modification to your instructions: the dispart command should be “list volume” instead of volumes, otherwise it jsut pulls up the types of things you can list (Disk, Partition, Volume).
Great guide! I could have used this about6 months ago when I had to do the same process to one of our VMs. I, also, found the vmweekly article to be laborous.
July 7th, 2007 at 1:40 pm
It should be noted here, however, that this won’t work on system drives.
To do it on a system drive, you can expand the disk itself using the vmware command you used, but then you can download a live Ubuntu CD image, boot the machine to the ISO, and use the GPartEd (or whatever the partition magic-like app is called) to resize your NTFS volumes.
If you need more disk capacity on the fly in ESX, you can also add a disk and create a dynamic volume, and span the multiple VDisks.
January 4th, 2008 at 4:15 pm
There is a much easier way to do this:
1. Power off VM
2. Add a blank larger target disk
3. Add a temp disk (formatted NTFS) to hold a ghost or acronis image
4. Boot to Ghost or Acronis CD
5. Image source disk to image on your temp disk
6. Restore temp image to your larger disk
7. dismount your source and temp disks and test a boot
8. If all goes well your done, you can delete your temp and source disks.
9. If all is not well you have your original disk to go back to.
No need to expand the disk and expand the partition. No risks and very fast.
April 4th, 2008 at 9:21 pm
Can w expand a real life C Drv 4GB almost full on Server 2003 Ent Edition into the D Drive volume also 4GB with nothing on it, both NTFS, both on the same physical hard drive.
Thanks in advance.