postheadericon Howto 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.  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. I like the open-source Gparted tool. You can download the ISO file from http://gparted.sourceforge.net/. After the download upload the ISO file to your DAS or shared Storage 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.

Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay
  • Live

20 Responses to “Howto extend the VMDK and the Windows disk”

  • Per:

    How about when the the VM is the VC itself. Is it still possible to use Gparted?

  • admin:

    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.

  • Guido Beijderwellen:

    There is a much easier way: http://ftp.dell.com/app/ExtPart.exe
    This will expand the C: volume instantly without
    errors. It’s written for Dell Poweredge servers
    but works flawlessly in VM’s as well. Just used
    it on a Windows 2003 VM.

  • admin:

    Thanks Guido for sharing!

  • Chemosh667:

    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.

  • Americhanac:

    Thanks Guido! Unfortunately ExtPart does not work on x64 servers :-(

  • Rocky:

    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!

  • Thanks for post. Nice to see such good ideas.

  • William:

    Thanks…this got a lot more room for my Exchange 2007 server.

  • Hi! I was surfing and found your blog post… nice! I love your blog. :) Cheers! Sandra. R.

  • Stanton:

    Thanks , This was helpfull, although gnome never work for me , I had to use acronis disk director server

  • Sam Johnson:

    I have just found an alternative way to do this that also covers vSphere. You dont even have to reboot your VM!

    http://www.jjclements.co.uk/index.php/2009/09/14/vmware-esx-vsphere-resize-disk

  • Neil:

    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. :-)

  • Steve S.:

    Thanks I have always used diskpart and it took forever this was quick and simple to use.

  • gparted is included in the latest R2 release of Bauer-Puntu Linux.

  • You may wish to download and try fatvm (http://www.gudgud.com/fatvm). You can extend a Windows vmdk with a single-click through its UI.

  • 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!!

  • Mike Tolland:

    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!?

  • todorojo:

    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!

  • Mike Tolland:

    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?

Leave a Reply