Howto: Expand VM boot partition

One of my virtual machines, running on ESX Server 3 (VI3) was in dire need to get it's boot partition expanded. Obviously I had miscalculated the storage requirements for this particular VM, but luckily there is an easy way to expand the VMDK file and then use third party tools to let Windows utilize the new space.

  • 1. Shut down the Virtual Machine
  • 2. Expanding the VMDK
    Log into the ESX server via ssh (I prefer Putty) Find the .vmdk file you want to expand and use vmkfstools to expand it:
    vmkfstools -X 20g vmname.vmdk That expands the existing virtual disk to 20 Gigabytes, now we need to make the extra space available to Windows.
  • 3. Resize boot partition
    As Windows doesn't allow you to resize the active boot partition, you'll need a third party tool to accomplish this step. GParted Screenshot In this case I used the GParted LiveCD, but you could also use BartPE or other bootable disk partition/resize tools.
    All I did was to download the GParted ISO, copy the .ISO to my datastore, mount it as a Virtual CD-ROM device and boot my VM from it. Then use the tool of choice to expand the existing partition.
  • 4. Remove the virtual CD-ROM device and reboot the VM

Thats it. How painful would that have been if this was a physical machine?

April 10, 2007 at 10:07am | 25 Comments
Tagged: , , , , , , , , , and

25 Comments so far

  1. Planet V12n, on April 10, 2007 at 12:22pm, said:

    [...] Howto: Expand VM boot partition [...]

    Edit Comment

  2. Brad Baughn, on April 10, 2007 at 3:09pm, said:

    I would also recommend the article below from vmprofessionals. It does not require any 3rd party tools, and works on both boot and non-boot partitions. It basically takes advantage of diskpart that is built into W2K3.

    http://vmprofessional.com/index.php?content=2k3resize

    Edit Comment

  3. h0bbel, on April 10, 2007 at 3:25pm, said:

    Sure, but this requires using a second VM to and mounting the partition you need to extend. See "Step 4: For this step you will need an additional Virtual Machine running Windows Server 2003".

    The method outlined above doesn't need a second VM, and you can do the partition extension inside a nice friendly GUI-based application like GParted.

    Edit Comment

  4. J.Cruz, on April 10, 2007 at 3:55pm, said:

    Another option would be to use the VMWare Converter to "convert" one VM to another with a larger boot partition. We've had good success with that over here.

    Edit Comment

  5. h0bbel, on April 10, 2007 at 4:41pm, said:

    Ah, good idea. I never thought of that!

    Edit Comment

  6. Mike, on April 10, 2007 at 5:50pm, said:

    Thanks for the tech tip, I just have to comment on the part about "How painful would that have been if this was a physical machine?"... Um, exact same effort on a physical machine, really. Partition Magic, Acronis, or any number of other partition editors will let you easily resize partitions if you have free disk space - been there, done it. :)

    Edit Comment

  7. crouton, on April 10, 2007 at 6:01pm, said:

    One tip when resizing Windows VMs - you must shutdown the VM cleanly, or the GParted process will fail to resize correctly. You'll end up with a correctly resized partition, but Windows won't be able to see or use that extra space.

    Edit Comment

  8. h0bbel, on April 10, 2007 at 7:53pm, said:

    @Mike: Sure, if you have the free space, the effort would be the same.

    @crouton: Of course, a clean shutdown would be essential.

    Edit Comment

  9. VMTN Blog, on April 14, 2007 at 3:58pm, said:

    [...] a disk in a virtual machine is not hard, but usually takes two steps: h0bbel on a boot partition, Gagazote, [...]

    Edit Comment

  10. News und Stories » Howto: Expand VM boot partition, on April 14, 2007 at 4:53pm, said:

    [...] Howto: Expand VM boot partition One of my virtual machines, running on ESX Server 3 (VI3) was in dire need to get it’s … [...]

    Edit Comment

  11. random bits of useful knowledge, on April 16, 2007 at 9:57pm, said:

    resizing of a disk

    Edit Comment

  12. StumbleUpon » Your page is now on StumbleUpon!, on April 17, 2007 at 3:31am, said:

    [...] Your page is on StumbleUpon [...]

    Edit Comment

  13. Virtualized Automaton, on April 24, 2007 at 1:10pm, said:

    Defragging virtual disks - http://www.vmware.com/community/thread.jspa?threadID=77661&tstart=0 Resizing Windows VM disks - http://www.vmprofessional.com/index.php?content=2k3resize Resizing Windows VM disks - http://h0bbel.p0ggel.org/2007/04/10/howto-expand-vm-boot-partition/ Resizing Windows VM disks - http://linux.softpedia.com/get/System/Recovery/System-Rescue-CD-188.shtml Unable to log on if the boot partition drive letter has changed - http://support.microsoft.com/kb/249321/en-us

    Edit Comment

  14. Be virtual, My friend, on May 3, 2007 at 6:34pm, said:

    Defragging virtual disks - http://www.vmware.com/community/thread.jspa?threadID=77661&tstart=0 Resizing Windows VM disks - http://www.vmprofessional.com/index.php?content=2k3resize Resizing Windows VM disks - http://h0bbel.p0ggel.org/2007/04/10/howto-expand-vm-boot-partition/ Resizing Windows VM disks - http://linux.softpedia.com/get/System/Recovery/System-Rescue-CD-188.shtml Unable to log on if the boot partition drive letter has changed - http://support.microsoft.com/kb/249321/en-us

    Edit Comment

  15. Kurrin, on May 3, 2007 at 9:02pm, said:

    Defragging virtual disks - http://www.vmware.com/community/thread.jspa?threadID=77661&tstart=0 Resizing Windows VM disks - http://www.vmprofessional.com/index.php?content=2k3resize Resizing Windows VM disks - http://h0bbel.p0ggel.org/2007/04/10/howto-expand-vm-boot-partition/ Resizing Windows VM disks - http://linux.softpedia.com/get/System/Recovery/System-Rescue-CD-188.shtml Unable to log on if the boot partition drive letter has changed - http://support.microsoft.com/kb/249321/en-us

    Edit Comment

  16. vmware , on May 5, 2007 at 1:11pm, said:

    [...] VM disks - http://www.vmprofessional.com/index.php?content=2k3resize Resizing Windows VM disks - http://h0bbel.p0ggel.org/2007/04 ... -vm-boot-partition/ Resizing Windows VM disks - http://linux.softpedia.com/get/S ... Rescue-CD-188.shtml Unable to log [...]

    Edit Comment

  17. News und Stories » Booahh ist der dick Mann, on May 19, 2007 at 4:34pm, said:

    [...] Howto: Expand VM boot partition One of my virtual machines, running on ESX Server 3 (VI3) was in dire need to get it’s … [...]

    Edit Comment

  18. VMTN Discussion Forums: Lots of Vmware Links.... ..., on June 1, 2007 at 10:50am, said:

    [...] [...]

    Edit Comment

  19. VMware Links, on June 15, 2007 at 2:20pm, said:

    [...] [...]

    Edit Comment

  20. Virtual Disk (VMDK), on August 14, 2007 at 3:52pm, said:

    [...] of Windows 2003 VM Resizing Windows VM disks Defragging virtual disks Resizing Windows VM disks Resizing Windows VM disks Resizing Windows VM disks Unable to log on if the boot partition drive letter has changed How to [...]

    Edit Comment

  21. silicon massiah, on November 4, 2007 at 9:17pm, said:

    Let's be rigerous in our distinction.
    We're expanding the logical drive size of a virtual Windows 2003 server's primary boot partition. Drives are divided as follows:

    physical hard drive (or virtual)
    partition
    volume
    logical drive

    1. On the host with the vm not running, make a copy of the drive with the primary boot partition and place it in it's own folder.

    2. Add it to the vm as an additional drive.

    3. Use the vm disk utility to expand the drive size.

    3. Boot the vm, and in a dos window launch the diskpart utility (c:\diskpart). (expand drive #) is the command to expand the drive.

    4. Shut down the vm and delete (have a good backup of the host machine) the primary drive.

    5. Copy the vm drive with the newly expanded logical drive to the location of the deleted original drive.

    6. Boot the vm and thank god for my existnace. Everything is possible with the software you already have. Stop spending money.

    Silicohn Messiah
    aka tom davis

    If you done it, it ain't braggin.
    - Will Rogers

    Edit Comment

  22. Jonathan Ng, on October 16, 2008 at 9:46pm, said:

    Just a note of caution (I learned this the hard way). I decided to try this technique after the GUI didn't allow me to resize my system disk.

    If you use this technique, ensure that you do not have any snapshots present. If you do, and you are resizing your system disk in this fashion, ESX will either error out or will unilaterally return you to your base snapshot.

    Luckily I was working on a lab machine when this happened, so I can rebuild it, but if this were a production machine, I would have been in big trouble.

    Edit Comment

  23. Christian Mohn (h0bbel), on October 16, 2008 at 10:36pm, said:

    @Jonathan Ng: That's a valid point. I've never had any snapshots present when I've done this, so I've never had any problems with it. I don't usually have snapshots on any of my production servers though.

    Edit Comment

  24. ijaved, on March 19, 2009 at 12:11pm, said:

    Alright i wana thank you for awesome tutorial. Neat and small. Only thing i wana add is Gparted live cd didnt detect my scsi partition after booting it was just blank.

    So i had Hiren's Bootable Cd 9.5 which i tried but couldnt load the software cause the virtual cdrom was not supported. After googling i found out that Hirens Bootable CD 9.8 works on esx servers and it did. Tried partition magic and it gave me some log error. No problem restarted and using Acronic Disk Director and it resized the pri hard drive to the unallocated space.

    One thing to add is if your vm is created with spaces in the name then you have to add backspace \ after each word that has space.

    eg :-

    If your vm name is New Virtual Machine_1 then you have do the following command. Took me awhile to figure out.

    vmkfstools -X 10g /vmfs/volumes/DataStore/New\ Virtual\ Machine_1/New\ Virtual\ Machine.vmdk

    Also i couldnt run vmkfstools cause i was only doing (su) and not (su -) from putty. So it couldnt run vmkfstools cause of the $PATH was not copied.

    I hope it helps someone else cause all i wanted was this yesterday. Hopefully this will save someone's time. Cheers

    Edit Comment

  25. Howto: Using ExtPart to Expand Windows Server 2003 VM Boot Volume - h0bbel.p0ggel.org, on October 28, 2009 at 2:28pm, said:

    ...xpand the boot volume, at least not without downtime. I've previously talked about using tools like GParted to expand the boot volume but there are easier ways to do it and prevent downtime at the same time!All you need is love. No,w...

    Edit Comment

Leave a Comment?


« My Personal Gallery 2 Wishlist  —  Gallery Appliance 1.1 and nice people »

Recent Comments