Home > Software Development, Windows > Expanding a drive within a VMWare image

Expanding a drive within a VMWare image

November 20th, 2006 Sean Leave a comment Go to comments

There are many ways to expand a drive within a VMWare image and I have outlined two approaches below depending on your setup. I have used both these methods successfully on a Windows Server 2003 Vmware image (Vmware Workstation 5.0)

Method 1

Advantages: You get to keep your Vmware snapshots
Limitations: You can’t extend all volumes, I had trouble trying to extend the system/boot volume. According to a Microsoft Knowledge Base article you can’t extend a volume if the system page file is located on the partition. You could try to move the page file to a partition that you do not wish to extend.

My setup:
C: System Drive 10 GB
D: Data 4GB

Let’s say that we want to expand the D drive from 4GB to 10GB

  1. Shutdown the VMWare Image
  2. Add a new disk to the VMWare image (the size should be that which you want to allocate to another volume, in this example 6GB).
  3. Boot up the VMWare image into Windows and go to Disk Management (Administrative Tools -> Computer Management -> Disk Management)
  4. A wizard should be displayed to initialize and convert the new disk. If you are not prompted then you may need to Rescan. Do not assign a new volume at this stage.
  5. You need to convert the D drive and the new drive to both be dynamic disks.
  6. Once both the drives are dynamic, then right click on the D drive and select Extend Volume.
  7. Follow the wizard to allocate the new space to the D drive.

Once you complete the wizard, the D drive should now be 10GB. That’s method 1 complete. If this worked for you, great! If not then take a look at Method 2 below.

Method 2

Advantages: You can successfully expand a system/boot drive.
Limitations: You have to remove all your snapshots (the vmware-vdiskmanager utility requires this.)

My Setup:
C: System Drive 8GB
D: Data 4GB
E: Data 4GB
Disk before resizing

Let’s say that we want to expand the C volume from 8GB to 12GB. Assume that the C drive is full to capacity (that’s why we are expanding it right!)

  1. If the Vmware image is running, shut it down.
  2. You need to find the name of the Vmware (.vmdk) file that represents the virtual disk that you want to expand. Go to VM->Settings and locate the drive
    that you want to expand. The disk file field on the right hand side will display the name of the .vmdk file. Virtual Machine Settings
  3. You need to remove any snapshots present in the Vmware image. Note: By deleting the snapshots the system still remains in its current state.
  4. Open up a command prompt and issue the following command: vmware-vdiskmanager -x 12GB “Windows Server 2003 Standard Edition.vmdk” where 12GB is the desired size of the expanded volume.
    Running vdiskmanager
  5. This expansion may take a while but when it is complete, boot up into Windows and go to Disk Management (Administrative Tools -> Computer Management -> Disk Management)
    You should see something similar to the following screenshot. The disk has been expanded but the new space is as yet unallocated. Now in theory you should be able to use the Windows diskpart utility to allocate this space but this would not work on a boot/system disk for me.
    Viewing the new unallocated space
  6. So with diskpart not up to the task, what are your options?:
    • Buy some Windows partition software (i.e. Partition Magic) at a cost of USD200- USD300 for a Server edition or
    • You could use Knoppix (free) to allocate the new space to the C drive. Knoppix is a bootable Live Linux CD and it happens to have a utility called QTparted.
  7. Since everyone likes free stuff, I went with Knoppix in this case. Download Knoppix (the iso image) to the machine which hosts the VMware image.
  8. Now you need to point your CD/DVD drive in your VMWare image to the iso image. How do I do this?
  9. Reboot your VMware image and have it boot from the cd drive. You may need to modify the BIOS settings in order to change the boot order to have the system boot from the CD drive. The exact settings that you need to modify will depend on the exact BIOS that you have. It should be straightforward to change this.
  10. After Knoppix boots , start at the large letter K at bottom left. Select K | System | QTParted to launch the utility. You will see the list of disks within the VMware on the left hand side. Selecting one of these disks will provide you with more details about that disk. In the following screenshot you can see the C drive with the 8GB allocated and the 4GB unallocated.
    Viewing disk in QTParted under Knoppix
  11. Right click on the drive that you want to expand and select Resize.
    Knoppix Context menu
  12. A dialog will be displayed and you can expand the allocated space by dragging the partition to the right. You could also type in the values into the textboxes. After allocating all the new space you now see that the total size is approx. 12GB.
  13. Click OK to exit the dialog. At this stage you have not commited the changes yet. Go to the main menu of QTParted and select the Commit option. The following prompt will be displayed.
    Commit Changes Warning
  14. Choose Yes to commit the changes. You will see the following two screenshots as it commits the changes.
    Commit Changes Progress 1
    Commit Changes Progress 2
  15. After the operation completes, you should see that the new volume now is 12GB in size with only 8GB in use (we now have 4GBs free :) )
    Drive after changes commited
  16. Now, shutdown the Vmware image and boot back into Windows (you may need to change the boot order to accomplish this).
  17. Don’t be alarmed if CHKDSK wants to run some tests on your drive. It detected the changes you made in Knoppix and wants to verify that everything is ok.
    Chkdsk scan
  18. You may need to restart Windows again because it will have detected new hardware.
    Windows detect new hardware
  19. Once Windows is back up, go to Disk Management (Administrative Tools -> Computer Management -> Disk Management) and you should now see that the C drive has the extra 4GB as promised.
    Disk Management
    Disk with new space
  20. Also, in Windows Explorer, right click on the C drive and choose Properties. You will see now that there is over 4GB of free space. :) )
    Disk Properties showing free space

Job Done!

Lessons for the future:
When you are creating future Vmware image make sure to allocate plenty of space to the drives.
You can set that they only grow as required so they only ever take up the space that you require at any point in time.

If this post has helped you please consider making a donation.

Categories: Software Development, Windows Tags:
  1. Josephraj Jayabalan
    February 6th, 2008 at 09:54 | #1

    Dear Sean,

    Great. We were stuck with Vmware Server 1.0.3 (on Suse Linux Ent 10.1) Virtual Machine. The C drive of the Windows 2003 was just 8G and it was almost full. Struggled so much with other options like vmkfstools, as it wasn’t available. Finally your solution worked like a charm. One thing I would like to add is that, instead of Knoppix, I used GPartEd Live CD ISO and connected it to the CD-ROM of this virtual machine.

    Joseph

  2. Darryl W
    February 16th, 2008 at 16:01 | #2

    Thanks a mil for this post. It worked perfectly!

    I also used GPartEd as it was quicker to download.

  3. PaulG
    February 27th, 2008 at 15:29 | #3

    Thanks, Did this on a Windows 2008 Server Web Edition HDD and Acronis Partition Manager, when the resize was compelete Windows complained \Windows\System32\WinLoad.exe was missing or corrupt, and would not boot. A “Bootrec /rebuildbcd” using the repair command prompt fixed it and rebooted to a huge drive! Thanks again.

  4. Claude
    May 2nd, 2008 at 02:24 | #4

    Thanks Sean for the time and effort to document this so clearly. It saved me tons of time and effort today (and in the future).

  5. Viren
    June 17th, 2008 at 17:52 | #5

    Thanks a lot Sean. Saved me a lot of time and efforts. Great details.

  6. mital
    July 21st, 2008 at 14:11 | #6

    Best article ever!! :-)
    I went with Method 2 and the Knoppix v5.1.1 of 2007-01-04 ( http://mirror.netcologne.de/knoppix/knoppix-cd/ )…..worked like a charm.
    Thanks a lot.

  7. Srini
    August 2nd, 2008 at 07:46 | #7

    Thanks a lot Sean for the great article.

    I followed Method 2 with Knoppix on Windows Server 2008 (Experimental) and it worked perfect. Although it failed first time when I tried to extend 100% of the newly created disk space. The second time I substracted 0.97 MB (seems like it was used for some administrative purpose) from the total size and it worked.

  8. Darius
    September 10th, 2008 at 16:18 | #8

    Thank you Sir! this solution was exactly what I needed. Thanks a lot! :)

  9. Myra
    September 30th, 2008 at 07:21 | #9

    Thanks Srini ! ;)

  10. netadmin
    October 4th, 2008 at 15:13 | #10

    Another way to do this is to use VMware converter. It is free software from VMware. It will let you take a Virtual Machine and do whatever you like with the disks.

  11. David Bernal
    October 5th, 2008 at 06:59 | #11

    Thanks for all your posts.
    This helped tremendously. Saved tons of work.
    I had to fix my ntfs partition before windows 2003 would see the new size.
    Thanks again!

  12. Micah Peterson
    October 31st, 2008 at 17:00 | #12

    You are the man, thanks a ton, you saved me a wack of time!

  13. Rick
    November 13th, 2008 at 20:26 | #13

    The reason why Explorer does not see the changes is because when you are in Knoppix, prior to commiting the changes (spanning the disk), you have to first unmount the drive, then click commit on QTParted. Then, all changes are written back to the drive, or else, the changes are never commited back to the drive entirely.

    If you are having an issue like this… boot back into Knoppix, make sure the drive is not mounted by typing “mount” (will show you all currently mounted drives), then go to QTParted and select the drive, QTParted will automatically mount it when you select it, click back to File->Commit, it will give you a warning. Do not click “Yes” yet, pull up a command prompt and type “umount /dev/drive_name_here” and it will unmount it. Then click Yes and voila!… Done.

  14. webbsolution
    November 14th, 2008 at 16:38 | #14

    Neat solution however I have a new challenge related to this method.

    I have resized the disk. In computer management it reads as the correct size with 3.9 gb free. Great.

    In my computer it reads as 3.99 gb main disk (it was 4 GB before) with 130mb free, cant run scan disk (not enough space), can’t install anything …ran chkdsk from the command prompt and then shut it down and ran it from safe mode….rebooted a few times.

    There is no unaloocated space int he drive in the computer management GUI

    Windows is freaking out…
    Any ideas?

  15. alex
    January 5th, 2009 at 01:30 | #15

    While searching for solution to my problem i ran across this very informative article.

    I may be missing something because it was way too easy. I just used vmware converted to change the only drive size on my 2003 R2 from 12GB to 50GB.

    After installing vmware converter 3.0.3 (free from vmware) i run converter and changed portion size. (all windows, all gui) It took less than 5 minutes to complete and created new set of vm files. Hit the power button and now my C drive is 50gb.

    maybe the software wasn’t around when this article was written ?

    http://www.vmware.com/products/converter/

    Best to all,
    Alex

  16. Rodney Dixon
    January 6th, 2009 at 18:56 | #16

    Used Method 2 to increase my boot partition. Worked like a champ. Thanks for the great info.

  17. adam
    February 10th, 2009 at 21:07 | #17

    As Alex stated. You can use vmware converter for this.
    Launch Vmware converter, virtual to virtual, expand disk size. Done.

  18. Tom de Vries
    March 23rd, 2009 at 15:57 | #18

    Hi, after trying to resize a couple of times without succes we managed to get it right. The main problem we had was that committing did not work because windows was not started correctly the last time in order to boot from the ISO. So the trick is to set the boot sequence first to CD so that you will not have the problem that you have to interupt windows to be able to boot from CD
    1. get into the BIOS and change the boot devices
    2. boot windows correctly and shutdown again
    3. set VMWare to boot from the ISO
    and your resize will work.

  19. May 8th, 2009 at 03:21 | #19

    It worked like a charm!! Thanks for the great advise!

  20. Young Wong
    August 3rd, 2009 at 03:33 | #20

    Like Josh from (18) I got some warning message when I commit changed in QTPart in Knoppix; that was when I downloaded and used the latest Knoppix 6.0 version.

    I got no error as described by Sean in the original post when I used version 4 of Knoppix and the resize work perfectly.

  21. September 23rd, 2009 at 20:08 | #21

    Thanks, Sean. This worked perfectly and your step by step directions were better than any vendor documentation I’ve encountered. (I’m looking at you, Oracle.)

  22. Terv
    October 23rd, 2009 at 01:21 | #22

    A much easier method to extending the boot partition is to use VMWare Converter Standalone (install it on the VM) and choose a local conversion. As part of the fourth step you can specify a new drive size for the boot partition and then finish through the wizard. The new cloned VM will have the enlarged boot partition. Boot it to make sure it is working and if it is delete your old VM.

    I have done this on multiple Citrix (Terminal Servers) and have never had any side effects.

  23. January 15th, 2010 at 01:46 | #23

    Comprehensive Survey of tehcniques to Extend / Expand virtual disks – VMWare, Fusion, VMware Server, VM Workstation, esx, including this post

    http://blog.sharevm.com/2010/01/11/survey-extend-expand-vmware-virtual-disk/

  24. Smith
    January 17th, 2010 at 01:38 | #24

    Thanks Sean, worked great for Windows Server 2003. I had the same issue as a couple others where Disk Manager showed the new space but windows explorer did not. I ended up just going back into Knoppix and unmounting/remounting by C:\ partition (the one extended) and rebooted back into Windows. New drive space showed up!

  25. Alex
    January 30th, 2010 at 17:43 | #25

    How do I move the system page file to another partion so I can extended?

  26. February 4th, 2010 at 05:10 | #26

    You should download and try fatVM http://www.gudgud.com/fatvm

    fatVM is a reliable, robust, and safe, 1-click solution for extending the C drive of your VMware Fusion or Workstation virtual disk that is becoming full.
    * It provides a simple, intuitive, interface and a reliable process that hides the technical complexity of extending a virtual disk.
    * It is robust because it can extend virtual disks having snapshots and clones.
    * It is safe because it preserves your original disk, which remains available to you for when the need ever arises.

  27. Chris
    February 16th, 2010 at 17:17 | #27

    VMware converter is probably fine but for those who want to make it
    manually, just use WiNPE instead of knoppix

    1- create the bootable WINPE ISO image (see the Microsoft WAIK, takes 2mns)
    2- boot your 2003 VM from the WinPE image (attach the ISO image created in step -1- to the DVD, make sure your VM will try to boot from the DVD first)
    3- at the WINPE command prompt
    diskpart
    diskpart> list vol
    diskpart> select vol x
    diskpart> extend
    diskpart> exit

    4- you are back to the winPE command prompt, type exit to reboot the VM

    (make sure you detach the WinPE image)

    then from the PE command prompt

    list volume
    select vol x
    extend
    exit

    (back to WinPE command prompt)

  28. Xerxel
    February 28th, 2010 at 19:12 | #28

    Whilst the comments here are true there is [b]another way [/b]to give yourself much more space on the C drive if you have another drive available (either physical or as part of a virtual machine) even if yu can’t span the system/boot volume.

    All you do is use a feature of Unix which windows has which windows admins don’t realize is a part of everyday admin work for a unix admin, ie [b]symbolic links[/b].

    For example, say you had a folder called c:\Data which was large and you wanted to free up space on the C drive but you couldn’t just move c:\Data because various programs expect it to be in the location c:\Data.

    All you do is copy your folder and its subfolders to your new drive and give it a name which reminds you that it is the new location, for example copy c:\Data to d:\DataFromCDrive

    [i](if any programs are using the files in c:\Data at the time then stop them first or boot into safe mode and carry out these steps)[/i]

    Now all you do is delete the original contents of c:\Data to make it empty. [i](which is fine as you have a copy of it).[/i]
    Using the Microsoft pstool called junction.exe you tell the filesystem where you moved the files to, ie:

    [b]junction.exe c:\Data d:\DataFromCDrive[/b]

    [i](if you are moving a folder with spaces such as “Program Files” make sure you use quotes)[/i]

    Now open up explorer and navigate to c:\Data — all the expected files will be there but you [b]just freed up space on the C drive coz you deleted the files from the original location.[/b]As this happens at the NTFS level, the applications are totall oblivious. This works for Program Files, Inetpub, infact anything taking up large amounts of space on the C drive which would be major hassle to move otherwise such as SQL server.

    Enjoy!

    Elliott
    PS. sysinternals tool are available here: http://technet.microsoft.com/en-gb/sysinternals/default.aspx
    PPS. Don’t put your swap file on the C drive – this slows your machine down.
    PPPS. Most of you are nadgers except the person who first asked the legit question ;-)

  29. Duggan Roberts
    March 19th, 2010 at 17:15 | #29

    Just to let people know who might be expanding a SUSE Lenux Enterprise server after you use gparted and reboot into SUSE you have to do a resize_reiserfs within the terminal. For example I increased my partition 50G so I here is what I had to type in:

    resize_reiserfs -s 50G /dev/sda2

    Hope this might help someone out there.

    Duggan

  30. March 21st, 2010 at 16:22 | #30

    Duggan, thanks for the comment and for dropping by.

  31. Duggan Roberts
    April 2nd, 2010 at 16:36 | #31

    No prob and should be SUSE Linux Enterprise server not Lenux but sure everyone figured that out just realized the spelling error.

  32. Nick
    May 7th, 2010 at 21:29 | #32

    hi i recently had some trouble doing this i finally was successful by doing the following method. it was alot faster then any of the other methods stated.

    To expand a VMDK first power off the VM.
    From CMD cd to VMWare Root directory and run vmware-vdiskmanager -x 12GB “c:\path\of\VMDK\Name.vmdk”
    hit enter
    you should see grow to 100%
    then open a different xp or windows server vm.
    add a disk and select the vmdk you just expanded.
    now go to cmd
    User input: diskpart
    User input list volumes
    find the volume you want to expand.
    User input: select volumeX
    User input: assign
    user input: extend
    This will extend the selected partition to the full size you grew earlier.
    Shutdown host remove HDD
    Now open the other host and power on vm ,
    You will need to reboot the vm again.
    You will then have expanded your Virtual HDD to 12GB.

  33. ESX guy
    May 17th, 2010 at 19:21 | #33

    Dell has a utility called ESX Part, wonderful tool. i can expand a disk in under a minute. increase the size of disk in vcenter, use ext part to expand! that simple

  34. June 16th, 2010 at 16:44 | #34

    HIi,

    i have tried with method 1, using
    “c:\program files\VMWare\VMWare Workstation\vmware-vdiskmanager.exe” -x 50GB “Windows Server 2003 Standard Edition R2 SP2-cl1.vmdk” Using log file C:\Documents and Settings\AVarghese_Camsoft\Local Settings\Temp\vdiskmanager.log

    but i am getting
    Diskname or some other argument is missing.
    VMware Virtual Disk Manager – build 118166.
    pls help me solve this.

    i have successfully resize with VMWare converter.

    Regards,
    Anish Panthalani

  35. June 16th, 2010 at 16:45 | #35

    Sorry i have tried with Method 2

  36. jeffster
    June 23rd, 2010 at 20:50 | #36

    Method 2 worked like a charm. Knoppix options were a bit different but I guess that’s due to updated versions but easy enough to figure out. Thanks for the info.

  37. Asad Quraishi
    June 30th, 2010 at 12:50 | #37

    Hey thanks! I haven’t tried this let but from what I already know this looks like it will work!

  38. Georg
    August 3rd, 2010 at 06:22 | #38

    Sean,

    Thank you – Method 2 worked.

    A couple of things:

    1.) Downloaded ADRIANE-KNOPPIX_V6.2.1CD-2010-01-31-EN.iso and mounted to VMWare
    2.) once booted, go to GUI (I think it was option 7 or so) tools -> load X session. From the “K” icon, went to “Preferences” to find “qtparted”
    3.) the frist run of qtparted exited with a “fail” and a message to run checkdisk. Tried from qtparted, but that checkdisk failed/didn’t finish. Logged off and exited Knoppix. (unmounted the KNOPPIX ISO here)
    4.) started from scratch (backed up VM). In WindowsXP, asked to run checkdisk (right click disk -> Properties -> Tools -> Error Checking [checked both options boxes too]). Restared Windows VM to let checkdisk run
    5.) Rebooted into Knoppix and ran qtparted – worked like a charm

    Hope that wasn’t too confusing.

    Best.

  39. Roy
    September 23rd, 2010 at 10:26 | #39

    For ESXi (or ESX) users there is an easy way to expand a system partition, commend from an other user and tested very succesfully by myself:

    “In my experience the easiest way to do this is to create another guest, call it test. Remove the C drive from the original guest you want to increase the drive space on and add it as the D drive on the new test machine. Now you can increase the size of the virtual disk. Run diskpart to expand the partition to it’s new size. Remove the D from the test machine and add it back as the C on the original guest and you now have an increased C drive. You can also run a vmware convert and increase the size that way. I’ve done them both ways and I find that simply moving the drive to a test machine is much faster.”

  40. Jon
    October 20th, 2010 at 16:57 | #40

    You can also use a free Dell tool named ExtPart… it doesn’t even require a reboot in most cases

  41. Ali
    December 7th, 2010 at 06:00 | #41

    EXT part is the fastest way to do this t took me about 2 mins !!!!!!!!

    Following is the process

    1. extend your VMdisk. My original was 20 so i extend by 10

    vmware-vdiskmanager -x 30GB “Terdata12.vmdk”

    2.download ExtPart… from
    http://support.dell.com/support/downloads/download.aspx?c=us&cs=19&l=en&s=dhs&releaseid=R64398&formatcnt=2&fileid=83929.

    3.Go into the VM and from command line

    extpart c: 10240 (to extend by 10GB )

    Voila

    Done 2mins

  42. Wayne
    December 17th, 2010 at 14:51 | #42

    Thank you so much! I have been looking for a solution to increase the size of the system patition on guest machines on esxi and this worked! I came across many soultions but this one was clear cut and accurate! unlike my spelling!

    Thanks again!

    Wayne

  43. January 7th, 2011 at 06:59 | #43

    Thanks for the info Sean, your work on this is appreciated. BTW, I was following your procedure #2 and found that Windows 2008 Server (enterprise) allows you to expand the partition without needing Knoppix. I had a full system partition, and i extended it (from 30Gb to 100Gb). After that I was able to change the partion size to make use of the full 100Gb in drive manager, which has to be new in 2008 server or I missed it in 2003.

    It worked like a charm. I’d never have tried it at all without your procedure. Definitely easier than doing BESR backups and VM restores.

    Cheers!

  44. matt
    February 16th, 2011 at 09:12 | #44

    ADRIANE-KNOPPIX is bullshit… not at all user friendly…
    1. expand hard disk first using vmware/work station settings when the system is shutdown/powered off
    2. download Partition Magic or something install it and add merg the unallocated parecian to the existing one…
    u r done..

  45. chessplayer
    May 25th, 2011 at 11:37 | #45

    Thanks alot! nice documentation!!

    i am a total linux noob, too.
    I tried gparted, because its much smaller, windows users don ‘ t be afraid – there is a graphical user interface.

    problems i had in command line with vmware-vdiskmanager: you should write the complete file name of the vmdk file (don ‘t use the ” * ” abreviation. Regardless u will have “failed to open the disk .. failed to lock the file vdiskmanager (16392)”
    thx!!

  46. ny3tclip
    July 29th, 2011 at 17:41 | #46

    awesome! Thanks for the help.

  47. Gest
    August 5th, 2011 at 12:38 | #47

    Good one.

    You can check video demonstration at

    http://windows.cskatta.co.in/?p=245

  48. tv
    October 7th, 2011 at 08:56 | #48

    Thanks a lot!

  49. James
    February 3rd, 2012 at 03:35 | #49

    expand system drive with dells extpart.exe without shutting down.
    command = extpart.exe c: 1024

  50. April 11th, 2012 at 18:04 | #50

    Thank you so much for this. I was able to expand my VMs to upgrade my company’s software to a new version. This was extremely helpful. I had to use gparted in knoppix with the version I downloaded though. Just a heads up.

Comment pages
1 2 10
  1. January 3rd, 2007 at 14:24 | #1
  2. January 29th, 2007 at 10:43 | #2
  3. June 22nd, 2007 at 15:10 | #3
  4. April 30th, 2008 at 01:32 | #4
  5. June 10th, 2010 at 19:26 | #5