Increase your Virtual machine's disk capacity

Background

The geekzilla team have been using VMWare for over a year now for desktop virtualisation . There are loads of benefits of virtualisation , but the most obvious one for me is increased stability.

For years I had a single machine with every tool under the sun installed, and stability was a real issue. Today I have a basic Windows Vista host, with e-mail, office and web browsing capability and VMWare that I use to run specific virtual machines for different tasks.

Problem

Everything has been great with my development Virtual Machine. The main hard disk was sized to 10Gb, with 2Gb free. But when I needed to install Visual Studio 2005 SP1 and SQL Server 2005 SP2 I ran out of disk space. I tried to increase the size of the disk using VMware's diskmanager but ran into a number of difficulties along the way.

Solution

Okay first thing to do is to check the VMDK (virtual machine disk) integrity. I chose to run checkdisk within my Virtual Machine. You'll need to reboot and the disk will be checked before the machine starts.

Once you're happy with the integrity of your disk its time to expand it. Using vmware-vdiskmanager. You must power the machine off first in VMWare workstation or VMWare Player.

Navigate to your VMWare folder and issue the following command from the command prompt, passing -x to increase the size followed by the new size (e.g. 20Gb), followed by the path to the vmdk file you want to resize.

C:\Program Files\VMware\VMware Workstation\vmware-vdiskmanager -x 20Gb "d:\VM Folder\vmdiskfile.vmdk"

This will take some time, and once complete the application will give you some sizing messages.

Now you need to expand the capacity of the disk to take advantage of its new size. If the disk is the system volume you will need to mount the disk in a second VM and expand it from there. If its not a system volume do it within the virtual machine it belongs to.

Once you've mounted the disk in a different VM or booted up the VM it belongs to if its not the system volume, do the following.

Go to the command line and start the diskpart utility. By issuing the following command.

diskpart

Once you've started diskpart, list the drives using the following command:

list disk

This will show you the disks assigned to your machine. Now the important command

list volume

This will show you the drives, their volume number, capacity etc. You now need to select the volume you are about to expand, using the following command. Where n is equal to the number of the volume.

select volume=n

Once selected, you can now expand it using the extend command. You can optionally specify the amount extend it by.

extend

That's it.

Once you've extended the disk, it's wise to defrag the drive. If you use the defragment tool in VMWare workstation you will find it much quicker than deframenting the drive from within the machine.

Summary

Virtualisation is great . Using an external Hard Disk, take regular snapshots of your Virtual Machine as a backup. I was fortunate to have backups prior to VS2005 SP1 and SQL 2005 SP2 trying to install on the disk when there was insufficient capacity. For some reason SQL 2005 became unusable as a result.

I hope you have discovered how useful Virtualisation, especially for developers.

If you ever run out of disk space on your Virtual machine you can use the technique above to extend the drive's capacity.

Author Paul Marshall

A self confessed Microsoft bigot, Paul loves all Microsoft products with a particular fondness for SQL Server. Paul is currently focusing on Web 2.0 patterns and practices and is always looking for better ways of doing things.

I love the .net platform, and I find it to be the most productive toolset I have used to date.

Comments

Tobei said:

Note that diskpart.exe's extend command works only with NTFS drives, and will not extend a primary partition.

03/Jul/2007 21:21 PM

ctusch said:

Sadly you forgot to mention that one MUST NOT resize a vdisk which has existing snapshots/redos or one will mess up his whole VM (happened to me). So you have to commit all your snapshots (i.e. delete them in the snapshot manager) before you resize your vdisk. Also make a backup of the whole VM before resizing. I hope this helps someone sometime.

27/Jul/2007 08:13 AM

Bl4deRunner said:

An other strategy is

1) to use [vmware-vdiskmanager -x 20Gb "d:\your_virtual_harddisk.vmdk"] as noted above.

2) Download & mount the .iso file from www.sysresccd.org (a linux bootCD with handy tools)

3) Use gParted, and resize your primary NTFS partition to the new size of your virtual harddive.

Works like a charm

17/Oct/2007 14:19 PM

Joe said:

If the disk you are extending is in a linux guest OS once you have extended the disk in vmware go to the guest OS as root and use fdisk. Do a df to see the device name, something like /dev/sda, thus fdisk /dev/sda, enter p to see current partitions, n to create a new one, accept the default size and save with w. Once done you can now see the physical disk partition in Linux. You can then use lvm gui or manual commands to initialise the partition and extend your file system. Thanks Paul for pointing me in the right direction.

23/Nov/2007 22:18 PM

Ganga said:

I want to add 300 GB external hard disk to Linux guest OS, I have windows XP host.

In this case what would be the location of VMDK file, Is this in external hard disk or internal hard disk

15/Dec/2007 21:25 PM

Travis Morien said:

Or, the easiest of all methods would just be to use VMWare Converter, which has an option for increasing the disk size during the conversion.

It is free to download from the VMWare site.

21/Aug/2008 22:10 PM

Mark E said:

What do you mean by mounting the system drive in a separate VM?

How is this done? I'd have thought that the virtual drive in every VM was totally isolated to that machine?

27/Aug/2008 13:54 PM

Mark E said:

This is the best description, inadvertently it appears correcting the omission in VMWare's own documentation about using punctuation around the drive name.

I figured out that I can mount the system drive in another VM by adding existing drives - magic. Thanks heaps for saving my bacon!

Mark

27/Aug/2008 14:36 PM

Hero said:

Worked perfectly fine for me. Thanks mate!

07/Feb/2009 19:09 PM

say full said:

There is easy way to extend disk size in vm without any tools.

I have used it in linux with vmware. You need to copy your .vmdk file

and add an entry to .vmx file with it, then you get one more disk with the same size in vm. If you have few virtual machines, you can add disk from another vm.

17/Feb/2009 16:54 PM

linus said:

when i select my virtual disk on the command its shows an error message and says "its already in use". whats the problem with me guys>? anyone can help?

24/May/2009 01:34 AM

Michael Bruce said:

This was a great post. There are some other steps that you could add for VMWare 6.5.

1 - How to add a drive to the "other VM"

2 - How to mount the drive and assign it a drive letter

Other than that, the instructions are perfect.

Thanks

27/May/2009 20:24 PM

tommy0660 said:

Thank you for your tutorial!

It worked very well with one exception: Before you can perform the "extend" command, I had to assign a disk letter to this disk (e.g.: "D:") via the utility "Disk-" or "Storagemanagement" (translated from german).

30/Jun/2009 22:53 PM

Sasi said:

Works Perfect! Saved a lot of work.. Thanks!

04/Sep/2009 15:46 PM

Dio said:

Worked nicely. Thanks mate

05/Sep/2009 02:09 AM

Doug said:

Worked like a charm when I followed the instructions to the letter. Thanks for posting this it was very helpful.

05/Oct/2009 19:08 PM

sudarshan said:

Worked perfectly fine for me. Thanks!

09/Oct/2009 07:32 AM

ricardo said:

With respect to mounting on another VM, I am using Vmware 6.5 and it just worked extending within the VM itself as system volume. No need to mount it elsewhere than running the vm itself and use cmd and dispart and extend the system volume itself, following the above directions.

28/Oct/2009 01:58 AM

Paul said:

Works great for me. I extened the primary partition of my vm.

01/Dec/2009 20:15 PM

Lucas said:

Worked Perfectely with me.

Simple and easy solution.

The only "diferent", but simple step, is to use the terminal.

Thanks man

24/Dec/2009 19:17 PM

derya said:

thank you very much

18/Jan/2010 21:14 PM

Tim said:

Actually, the -x command expands the drive "TO" that value, not "BY" that value.

20/Mar/2010 16:30 PM

srishti said:

my mouse USB ports is nt working in my Virtual machine..

01/Apr/2010 13:50 PM

pferrell said:

Travis comment above to use the vmware converter worked perfectly, thanks! Thought I would need to use partition magic or something to extend the system partition within the virtual machine once it was made larger, but the converter took care of that too.

21/Jul/2010 19:06 PM

said:

I had to do a assign command (to assign to disk letter) after select volume to actually get the extend command to work.

23/Jul/2010 08:05 AM

subtle said:

Nice tutorial. The easiest of the ones I found out there.

Thanks a bunch.

11/Aug/2011 18:48 PM

Sankar said:

I tried to extend HDD Size of Guest machine running on Windows Server 2003 from 14 GB to 80 GB using "vmware-vdiskmanager -x 80GB <Path of .vmdk file>". got and error

C:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager.exe -x 70GB "e:\VM\Test.vmdk"

  Grow: 100% done.

Failed to expand the disk 'e:\VM\Test.vmdk': The file already exist

s (0x270000000c).

Created a tmp file like "Test.vmdk.dsfghi.tmp" in same folder with same size[14 GB]

05/Jan/2012 14:23 PM

Pooja said:

Great article! works like a charm. Thanks!

07/Mar/2013 14:18 PM

Add Comment

Name
Comment
 

Your comment has been received and will be shown once it passes moderation.