Expanding a virtual VMware disk
By Michael Pietroforte | 48 Comments | Permalink | Trackback | Previous | NextUpdate: There is a much easier way now to resize a virtual disk: Expand a virtual VMware disk with VMware Converter. Also check out this article about my first impressions of VMware Converter 3.0 final.
Today, my Windows XP test system running in a virtual machine under VMware Workstation 5.5 complained that there is not enough space anymore on the system partition. I thought it can’t be too complicated to resize a virtual disk. After all, it is only virtual. I hoped to solve this problem within 5 minutes or so. Well, here’s how it went:
I was disappointed the first time when I realized that one can’t change the size of a virtual disk with the VMware user interface. So I googled this problem, hoping to find an easy-to-use tool. What I found out was that the virtual disk can be resized on the command line using the VMware Virtual Disk Manager Utility. The documentation about this feature on the web is for VMware Workstation 4.5, but it also works with version 5.5 and also for VMware GSX Server.
The command to expand a virtual disk looks like this:
vmware-vdiskmanager -x 10GB myDisk.vmdk
The new size of the virtual Disk will be 10 GB in this example. myDisk.vmdk is the file of the virtual disk on the host system. Usually this file won’t be located in the same folder as vmware.exe. Thus, you have to specify the full path to the vmdk file. Don’t forget to enclose the path in quotation marks, if the folder names contain spaces. You can find vmware.exe in the VMware installation folder.
My second disappointment was that one can’t expand a virtual disk if it contains snapshots. With a heavy heart, I deleted all my snapshots of this virtual machine. I was surprised how much time VMware needed for this. The size of the disk was 4 GB and I had three snapshots. I didn’t measure the time, but it must have taken at least 15 minutes. This is amazing considering that it only takes a few seconds to create a snapshot.
Finally, I was able to expand the virtual disk. The virtual disk manager needed several minutes to enlarge the virtual disk to a size of 10 GB. Of course, you can only do this after you shut down the virtual machine. It is recommended that you backup the vmdk file first, just in case something goes wrong.
I was disappointed the third time when the Virtual Disk Management Utility eventually finished its task. Expanding the virtual disk was successful, but the tool suggested using a third-party tool to resize the partitions within the virtual disk. So basically I was back to where I started. I, now, had a bigger virtual disk, but the system partition of my virtual machine still remained the same size.
Luckily, I remembered that I have an old version of Partition Magic. Since my virtual disk was full, I had to create a second virtual disk on this virtual machine first to get some free space for Partition Magic. I suppose, you know that one can add a new virtual disk by changing the virtual machine settings. Partition Magic 7.0 had no problems enlarging the system partition on my VMware virtual disk.
All in all, it took me about an hour to resize my virtual disk, including the search for a solution for my problem and the time to find my old Partition Magic. I guess I was a bit too optimistic with my five minutes estimation. I hope that future versions of VMware will offer more comfort here.
Leave a Comment |
Subscribe RSS
|
Newsletter








I never manged to resize them without problems.
Resizing virtual Disks is a bit complicated. A back-up in such a case is a vry good Idea.
You can use DISKPART in Windoze in liue of Part. Mag.
It seems that diskpart is not included anymore in the Windows Server 2003 Resource Kit. Was it replaced by another tool? The download link to diskpart on the Microsoft web site doesn’t work anymore. (Check this site for the Windows 2000 Resource Kit) So maybe, it is not advisable to use this tool with Windows Server 2003.
Thanks for this valuable info. Saved me loads of time. Proves that these places realy do serve a purpose.
You can also use the gparted LiveCD to resize partitions - just download the iso image and boot from it, you don’t need to actually create a CD. gparted works beautifully, and looks nice too.
Diskpart is now part of both w2k3 and wxp.
The other way I have done this is to simply add a 2nd disk and then let windows span the two partitions to make it look like one drive. In 2003 you can convert it to a dynamic disk no problem (2000 is a problem) and then let it span. Because it is not a physical drive, it doesn’t really matter and you can keep doing this as much as you like to get a bigger and bigger drive.
Jim
[...] Today I was setting up an image for some of our summer demos. The image I was working with had a paltry 4GB of pre-allocated disk space. It turns out that increasing the size of the disk is not something that can be done from the VMWare GUI. Fortunately, I found helpful blog post. vmware-vdiskmanager is a command-line utility used to resize disks. Not sure why this stuff hasn’t been incorporated into the GUI, but it’s reasonably easy to work with. [...]
Thank you very much. I actually am in the same boat as you were then. Now I’m off to partition. Thanks!
Expanding a virtual VMWare disk is fair from straightforward especially if you are trying to expand the boot disk like me. I have put together a tutorial based on my experiences at http://www.seandeasy.com/expanding-a-drive-within-a-vmware-image/
have read your article as recently I’ve had this problem myself. Here I found a good method to expand the disk without any third-party tools or additional OS: http://www.vmweekly.com/articles/expanding_the_virtual_disk_size_in_4_steps/1/
Jeff
After using either vmksfstools or vdiskmanager, I use Gparted, a linux live boot CD. It’s free and works great.
You can also use it the other way, if you need to shrink a VM. However, the only thing you’ll have to do in this scenario is to create a 2nd disk with the required space, and do a disk to disk copy.
Cheers.
[...] Just in case that VMware day comes: “Expanding a virtual VMware disk.? [...]
I have had success at resizing the boot disk in ESX 3.x as well. I found out the hard way, do not try this when you have already taken snapshots. The hosted server failed to boot. I had to delete the VM from inventory than point a “new” VM to the drive file. All changes after the first snapshot were lost.
I bit the bullet that day.
1. Used the vmware-vdiskmanager -x 10GB myDisk.vmdk
2. Booted the vm machine, with Hirens boot cd and launched Partion Magic and resized the partion and then rebooted the wmware machine.
ETA 15 minutes.
That was it for me
Thank you.
1. Use vmware-vdiskmanager x
2. Boot the VM with winPE iso image, run diskpart extend command
3. boot VM and windows will tell you new HW has been installed. Reboot machine and you are ready to go.
and its all using free tools
[...] musste ich das File vergrössern. vmware-vdiskmanager -x 2gb myDisk.vmdk Siehe dazu den Bericht Expanding a virtual VMware disk. Unglücklicherweise muss die Partition des Betriebsystems dann selbst noch vergrössert werden. [...]
Using the VMWare graphical utility, I attempted to convert the vm image of my Win2k3 Domain Controller to an independent persistant file, but i’m not sure it worked quite as i had expected. I then went to the command prompt and attempted to use diskpart to extend by 1000mb but that was unsuccessful. any suggestions?
I have used VMware Converter to convert the existing VM into one with bigger hard disk.
Jeff, that’s not the way to do it. Microsoft’s diskpart is for partitions, and NTFS does not resize with it. Vista finally includes NTFS resizing though, you’re supposed to use VMware Converter from inside the guest, using a remote mount (On the host is fine) and expanding it. Converter will let you expand “physical” machines even if they’re really just guests. I don’t use VMware Converter directly on .vmx/vmdk files, it doesn’t work right with Workstation 6.0. Physical to Virtual works every time.
Vista “Disk Manager” allows to extend the volume, it took me 2 minutes to add 12GB of space
(about 90% of it was vista shutdown and restart)
When running linux in a virtual machine, use the XFS filesystem if you expect resizing.
XFS supports online resizing, even when the filesystem is “in use” or mounted, through the command xfs_growfs (device node). It actually took me under 5 minutes, including stopping and starting the virtual linux machine.
Thank you for pointing out the commandline tool vmware-vdiskmanager.
I had a similar experience as you did. The article explains some thing, however there are some free or open source tools to help you partion or resize the disk and resizing the “virtual disk”. I used the following command to resize my disk in linux: sudo vmware-vdiskmanager -x 14Gb /vmware-distrib/share/Windows\ XP\ Professional/Windows\ XP\ Professional.vmdk
after this completed, I change the boot options in vmware and changed it so that i was able to boot from live cd. I powered on the virtual machine with the disk I resized. Insert gparted live cd and choose boot. I change the basic boot option to select video card manually (I selected generic,which worked). Virtual disk is detected, resize the disk and apply. Done, now reboot the virtual machine and wait for windows to check the file system.
Using these steps without research makes it a five minute or less process. Thanks for the article.
Folks as the author has pointed out, there is a much easier way to do this than the multistep procedure outlined above - using the vmware Converter tool.
There is ALSO a way to do this using a standard vmware workstation v6 without any extra functions, addons or tools, or using any commandline tools. You do it all from the plain vanilla vmware GUI. I cannot vouch for earlier versions - you may need to use the vmware Converter tool.
Use the VMware Import Wizard from the vmware GUI. Follow your nose through the wizard.
Choose a “standalone virtual machine” as your source and point the wizard to your vm which has run out of space.
The wizard will connect to the machine, and retrieve info like OS and disk info etc.
The next step is the important one for your purposes here:
Make sure to deselect the default option “import all disks and maintain size”. Instead you should choose to “select volumes and resize to save or add space”
This will reveal an info panel showing the disks inside the old VM and their sizes and free space.
Note the drop-down arrow in the “New Disk Space” column. Choose that, then select the option to “type size in GB” (or MB as your case may be) then type the required new size of the new VM disk to be created.
It’s probably a good idea to leave the “ignore page file and hibernation file” setting selected.
You then need to specify the destination machine type (ESX server/VirtualCenter VM or Standalone VM) then the target VM location and Virtual Machine name (yes, you must change these although the Windows machine name can stay identical). You also need to specify the destination VM format for compatibility purposes ie v6.x, v5.x or v4.5x.
You can then choose whether the new VM disk will be pre-allocated (option to split into 2GB chunks) or allowed to grow.
You then have an option to confirm VM network settings and finally can optionally customize all windows settings like Windows Hostname, and registered Owner/Organization , generate new SID (yes, it can run Sysprep!!), re-enter Windows Product ID, confirm Time Zone, change Workgroup or Join Domain.
The wizard then provides a VERY brief overview of your settings (not enough to be useful really) with a Finish button at which point the Import/Conversion will start.
This procedure worked fine for me with several different Virtual machines I had which had run out of space in a pre-allocated disk.
There is no need to run vmware-diskmanager from command prompt, nor diskpart or another 3rd party partition manager tool at the end.
Better yet, if you have multiple snapshots, you can keep whatever state you would like for the new VM, although the new VM will not be able to USE any of the snapshots in the old machine. However, you still have the original VM machine unaltered as a backup.
Time taken seemed to be about what I would expect for a file copy of the total # GBs involved in my setup. I have not found any drawbacks at all, except for the obvious one of needing enough HDD space to store both sets of virtual disk images.
If anyone from vmware support happens across this page, please note that all the people above would probably benefit from inclusion of a GUI tool inside vmware (more obvious than the Import routine I describe) to do just this sort of function.
A tool similar to that provided by “RDPetruska” would be ideal if incorporated into vmware:
http://petruska.stardock.net/software/VMware.html#DiskFactory
@thUtmost That seems to be an interesting solution for this problem. I will try it when I have to enlarge a virtual disk the next time. Thanks a lot for your time.
I tried Utmost’s solution and it worked fine. Fairly straight-forward, low risk and most importantly, free.
It took me about 15 minutes to move a full 8GB VM into a 20GB VM. My Windows machine had to rediscover several devices which I thought was odd, but it all worked out alright in the end.
GRRR anyidea I just does not seem to work on my machine, I’ve tried putting the whole C: ect in quotes as well but that does not work
C:\Program Files\VMware\VMware Server>vmware-vdiskmanager -x 128GB C:\Virtual Ma
chines\Windows Server 2003 Standard Edition-flat.vmdk
Diskname or some other argument is missing.
@Denton Real Estate.
Yes, that will happen, since the volume ID of the virtual disk used by your Virtual Machine will be changed by the process.
This is similar to using Ghost to clone a windows installation from your original 8Gb HDD onto a 20Gb HDD. Windows knows the HDD has changed, so it will detect that change. So long as the HDD doesn’t require a different HAL driver you will be ok (eg IDE vs SATA RAID vs SCSI).
Cautionary note here:
Be aware that if you make too many changes in your hardware too quickly, and depending on your version, you may be required to re-activate Windows. The Windows activation is tied to serial numbers of several bits of hardware, one of which is the HDD.
I have not actually had a problem with this, it’s just something I mention here so you’re aware of it.
@wingnut
If you’re having trouble with the vdiskmanager commandline, have you tried the method I outlined under comment #24?
@wingnut
Even though the -flat file is the larger file, you want to point to the diskname.vmdk file.
This will tell the -flat file to expand.
It should go something like this:
Run the vmware-vdiskmanager utility:
Start>Run>type “cmd”
In the command window:
C:\Program Files\VMware\vmware-vdiskmanager –x 10Gb MyDisk.vmdk(vmware-diskmanager is normally under \Program Files\VMware)
you will see something like this:
C:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager.exe -x 10GB G:\MS_VMs\winxp_pro_sp2\MyDisk.vmdk
Using log file C:\DOCUME~1\YourMama\LOCALS~1\Temp\vmware-YourMama\vdiskmanager.log
Grow: 100% done.
The old geometry C/H/S of the disk is: 8322/16/63
The new geometry C/H/S of the disk is: 16383/16/63
Disk expansion completed successfully.
To resize the VMDK you will need unbuntu desktop 6.04 iso image - just google for it…
follow the instructions below to resize
**i recommend creating a new one from your small one you want to expand just in case**
C:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager.exe -r “PATH\yoursmalldisk.vmdk” -t 1 “PATH\yournewlargedisk.vmdk”
** you can specify the new size here **
C:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager.exe -x 12Gb “PATH\yournewlargedisk.vmdk”
in VMWARE:
mount new sized hard disk as hd1
boot up using UNBUNTU live cd 6.04 desktop - just load the iso into the cd drive using vmware settings on the virtual machine
when it boots up, you may need to specify using the cd drive as the boot device by pressing F2 first.
after unbuntu starts,
Go to SYSTEM > Administration > GNOME Partition Editor
From the Partition menu, select RESIZE/MOVE after selecting the partition you want to grow
drag it to consume the new space you want to use
click RESIZE
Click APPLY checkmark
it will ask you if you are sure, say YES
click close
shutdown
remove the unbuntu live cd from your iso
reboot, windows will run CHKDSK - this is GOOD
windows starts, your space is available!!
thats it!!
The command to expand a virtual disk looks like this:
vmware-vdiskmanager -x 10GB “Path to Disk.vmdk”
f. ex.: “C:\VMachines\Windows XP Professional.vmdk”
The double quotes are required for the system to find the path to the virtual disk!
greetz
[...] Bildiğimiz gibi Vmware üzerinde oluşturduğumuz sistemler için kullandığımız diskleri belirli oranlarda arttırabiliyoruz.Yani başlangıçta 5 gb oluşturduysak bunu ileride 10′a çıkarabiliriz.Almanya’nin en büyük okullarından birinde IT uzmanı olarak çalışan Michael Pietroforte blogunda konuyla ilgili güzel bir yazı hazırlamış.Yazıya buradan ulaşabilirsiniz. [...]
Thanks a lot very usefully tips! I had exactly the same problem…
Great tip:
“Don’t forget to enclose the path in quotation marks, if the folder names contain spaces.”
Of course I forgot about it and it did not work :-)…
Best Regards,
Djordje
Hi,
Creating a snapshot does take quite a short time because all VMWare does is to say that from now on everything written goes to a new snapshot.
Removing the previous snapshot takes some time because it has to merge the old snapshot with the state now. It’s copy-on-write.
I’d like to see this same tutorial expand the guest OS disk running linux.
1. Used the vmware-vdiskmanager -x 10GB myDisk.vmdk
2. Create a 2nd HDD the correct size you need.
3. Boot from CD, run Ghost to copy original HDD to new just created HDD, making it the correct size.
4. Ghost again back from the 2nd disk to the 1st disk making the partition the correct size.
5. remove created HDD.
6. Done, have a nice cup of tea.
Thanks for the info, I use it to expand my Ubuntu guest virtual disk.
Thanks! Worked great with WinXP as host and Vista as guest. Saved me lots of time!
Thank you, Michael! I was struggling more than a week to find the right tool for the last step of virtual disk resizing. Your hint to use partition magic saved me from desparation and is sooo easy in the end.
Used bullet point #24 posted by the theUtmost - worked like a charm! Upgraded my 10GB virtual disk to 25GB in less than 10 min. Who would have thought that Vista all by itself (with updates) could blast through 10GB???? Don’t answer that! Much thanks to theUtmost…………
Dear VMWare users,
I wanted to expand a virtual disk as well;
I had a 10GB virtual disk and I was out of diskspace. I tried to use the vmware-vdiskmanager, but I experienced a lot of problems.
But, I have the solution: Use VMWareConverter! With this tool you can choose for Convert Machine, and with the source type you choose ‘Other’. Than you browse to your virtual machine and click next. In the source data screen you choose the ‘Select volumes and resize to save or add space’ option. In the dropdown field below ‘New disk space’ you choose ”. Just follow the steps, wait till your virtual machine has completed its converting state and there you go! Your virtual disk has been expanded!
It works fine at my place without problems, but just in case I recommend you make a backup of your virtual machine first! Goodluck!
Jennifer, I did this, and although it appeared to work it didn’t really. Yes, VMware reports the disk to be the new size but Windows does not. Opening “My Computer” shows Drive C still to be the original size. Going into Disk Management is bizarre, because the bottom panel lists Disk0 as having the larger size but the top panel shows Drive C with the old capacity. There seems no way to increase Drive C to use the new space.
Peter (comment #42) — you need to use ntfsresize to enlarge the filesystem, as explained in http://weblogs.asp.net/kdente/archive/2006/01/07/434789.aspx, I think.
Not sure how you would use a Linux utility to resize a Windows VMware virtual disk.
Well it’s just an NTFS filesystem, it doesn’t matter which OS runs the tool that resizes it
Linux’s ntfsresize works fine on Windows NTFS partitions.
But I was wrong. With VMWare Converter 3.0.3 I was able to resize a VM without any trouble, the NTFS filesystem was automatically resized by the converter.
The easiest way that lets you resize is stated several times in this list.
The new 3.5 of ESX lets you increase the disk from inside the Virtual Center GUI. Or use the vmkfstools as this article suggests. Then just boot off the gparted iso and resize the disk. You need to remember to pick the right disk inside the gparted to resize and make sure you click the Apply button.
It does it’s thing and forces a chkdsk which you should let happen.
Voila…your virtual NTFS disk is bigger.
Jim
Guys,
Please follow suggestion#24. It is so easy, and it worked for me on VM Wkstn 6.5.0.
Basically what it does is it makes a copy of your virtual machine to a new one by giving you the option to change the size of the virtual disk throughout the process.
Just make sure you **DESELECT the default option “import all disks and maintain size” and select “select volumes and resize to save or add space” option.
The rest is a piece of cake just logical stuff you can’t go wrong.
Even if you did, you would have backed up your virtual machine anyway.
The wizard is available from the File menu of the VMware wkstn.
Best of luck,
Marcellin_NG
[...] The brilliant 4sysops.com blog goes into more detail on the topic, but it is something I will be using lots in the future!… well until I can be bothered to install VMware converter, but I don’t know enough about that product to install it on our corporate servers. [...]