How-to extend the VMDK and the Windows disk

I see a lot of environments where the Virtual Machine (VM) disk space must be extended.

Prior ESX 3.5 the way to extend a VDMK was to use the vmkfstools command with the -X parameter from the VMware ESX server console. With the coming of ESX 3.5 it is possible to extend the VMDK file when the VM was shutdown. Now  with VMware ESX 3.5 Update 2 it is possible to online (hot) extend the VMDK file.

In the Virtual Infrastructure Client (VIC) go to the VM and edit the settings, click on the disk there is a property New Size (figure 1).

image

Figure 1. The VM disk extend function

The first step is to see if there is enough free space on the LUN (datastore). You can check the disk space (realtime) by using the command vdf -h on the ESX server console or in a SSH session. Keep in mind to have a average of 10% free on the LUN for snapshots and swap files etc. 

If the disk space on the LUN is okay you can extend the disk. In this example we extend the 16GB disk to 20GB.

image

Figure 2. The VM disk extend function

When the VMDK is extended the disk space must be added to the Windows volume.  In the Windows Disk manager when using VMware ESX 3.5 Update 2,  use the "Rescan Disks" function to discover the new added space when you use the hot extend function. The new added space is seen as Unallocated

image

Figure 3. Windows disk manager

To extend the volume by using diskpart use the following commands:

  • Start – run – type diskpart
  • type list volume
  • type select volume 1
  • type extend

    When trying to extend the C partition with diskpart you got the following message "The volume you have selected may not be extended"

    image

    Figure 4. Diskpart tool

    It is not possible to extend the system- and bootvolume by using the diskpart built-in command (for MS Vista, Windows 7 and Windows 2008 and higher you can extend the volume by using diskpart). For MS Windows XP and MS Windows 2003 there are other options you can use:

  • Add the system- and bootdisk volume to the other Virtuele Machine (VM) as disk.  Start the other VM and use the diskpart command to extend this disk or use an 3e party partition tool.

  • Use the command line tool from Dell called Extpart. Usage:  expart [drive] [sizetoextend]  

  • Use the Gparted tool. You can download the ISO file from here.  When the download completes upload the ISO file to your storage and attach and connect the ISO the to the VM.

  • image

    Figure 5. Connect the ISO file to the VM

    Start the VM, the ISO gets started

    image

    Figure 6. Start the Gparted tool

    – Press Enter

    image

    Figure 7. Keymap choice

    – Press OK

    image

    Figure 8. Keyboard layout

    – Select your keyboard layout

    image

    Figure 10. X-windows graphical warning

    – Press Enter

    image

    Figure 11. GParted Parition tool

    – The partition layout is displayed. Select the disk the extend and press Resize/Move

    image

    Figure 12. Partition resize window

    – Enter the new size or drag the bar the the right and press the Resize/ Move button

    image

    Figure 13. Partition resize

    – Click the Apply button

    image

    Figure 14. Partition resize warning

    – Press Apply

    imageur

    Figure 15. Partition resize process

    – If the extending process completes and is successfully, restart the system and disconnect the ISO from the VM and restart the VM.

    image

    Figure 16. Windows Disk Manager

    – After the restart open the Windows disk manager and you see the new space is added to the volume.

    [ad#verticaal]

  • 25 thoughts on “How-to extend the VMDK and the Windows disk”

    1. Yes you can. Make a direct connection using the VIC to the ESX server that host the VC. Connect the ISO and boot the VC server from it.

    2. Thanks Guido! I’ve been trying to remember that thing for two days now. I’ve used it in the past, and it’s far and away the best utility for this I’ve seen.

    3. I’ve been pulling my hair out trying to get the boot drive on one of my servers to expand. Thanks Guido, your post was a life savor!

    4. I just tried using ExtPart on Windows 2008 R2 and of course it didn’t work due to ExtPart being 32-bit and 2008 R2 being 64-bit. So I tried diskpart anyway (expecting it to fail) and it worked! Instantly extended a 40GB boot/system partition up to 100GB without a restart. 🙂

    5. wow, Guido.. what a life saver!!! After 2 hours fighting with partition magic and GNOME boot.. it was a small miracle to see Drive Management partition expand after typing 5 letter command.. I could not believe my eyes.. I read 12 KBs on the subject from MS, did not find how to make their utility work.. why wouldn’t they include this little thing with server 2003? THANKS AGAIN!!

    6. Why would you want to install third party software when you can extend a vmdk through Windows 2003 svr? I’m not sure I understand this post!?

    7. In the original post it says:

      “It is not possible to extend the system- and bootvolume by using the diskpart built-in command. There are other options you can use:

      – Add the system- and bootdisk volume to the other Virtuele Machine (VM) as disk. Start the other VM and use the diskpart command to extend this disk or use an 3e party partition tool.”

      So I did exactly that, I shutdown the vm who’s boot partition I wanted to extend (lets call him vm1), added that vmdk to vm2 and booted vm2. In order for diskpart to let me extend the vmdk of vm1 I had to assign it a drive letter. So I did that and then extended the volume without any issue. I then powered off vm2 and disconnected the vmdk for vm1. Then, when I started back up vm1 I got this error:

      “Windows could not start because the following file is missing or corrupt: \WINDOWS\SYSTEM32\CONFIG\SYSTEM

      You can attempt to repair this file by starting Windows Setup using the original Setup CD-ROM.
      Select ‘r’ at the first screen to start repair.”

      Did I do something wrong? Why would I get this? Why didn’t anyone else in this thread run into this?

      I’m running vSphere 4.0 and vm1 and vm2 are both w2k3 x64 VMs.

      Any info / help as to why I ran into this issue (this is the second time I’ve run into this issue) as well as any resolution on how to fix it would be greatly appreciated!

      Thx!

    8. Clone VM1 and call it VM2. Follow through the same steps and see whether you still get the same problem.

      Is VM1 a clean install of w2k3 x64?

    9. The .ISO would not boot. Tried attaching it to several VMs, forcing connected/connect at power up but it is ignored. Was really hoping this would work.

    10. Wow… Just had a single partition system VMDK to extend and was looking like I’d have to do ISO boot jiggery pokery or perhaps even purchase some software then I found ExtPart details here. wow… a 37k exe from 2003 did the job in less than 1 sec. Kudos for sharing this dudes… one for the utils folder for sure 🙂
      Cheers
      Gaz

    Leave a Comment