You are not Logged in
Would you like to Login or Register

Today is: 05 February 2012
Check this months hot topics

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.

kick it on DotNetKicks.com del.icio.us digg Mister Wong YahooMyWeb Reddit Furl Spurl blogmarks
Paul Marshall Skype
Author : Paul Marshall
Published : 05 June 2007

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.

July 03, 2007 - 9: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.

July 27, 2007 - 8: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

October 17, 2007 - 2: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.

November 23, 2007 - 10: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

December 15, 2007 - 9: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.

August 21, 2008 - 10: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?

August 27, 2008 - 1: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

August 27, 2008 - 2:36 PM

Hero said:

Worked perfectly fine for me. Thanks mate!

February 07, 2009 - 7: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.

February 17, 2009 - 4: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?

May 24, 2009 - 1: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

May 27, 2009 - 8: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).

June 30, 2009 - 10:53 PM

Sasi said:

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

September 04, 2009 - 3:46 PM

Dio said:

Worked nicely. Thanks mate

September 05, 2009 - 2:09 AM

Doug said:

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

October 05, 2009 - 7:08 PM

sudarshan said:

Worked perfectly fine for me. Thanks! :)

October 09, 2009 - 7: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.

October 28, 2009 - 1:58 AM

Paul said:

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

December 01, 2009 - 8: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

December 24, 2009 - 7:17 PM

derya said:

thank you very much

January 18, 2010 - 9:14 PM

Tim said:

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

March 20, 2010 - 4:30 PM

srishti said:

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

April 01, 2010 - 1: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.

July 21, 2010 - 7: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.

July 23, 2010 - 8:05 AM

Add Comment

Enter your comment below and it will be submitted for moderation.

Your Name

Add Tag

Please enter tags for this article, seperated by semi-colon ;

View Tag's by : # articles | # views

More Publications

Increase your Virtual machine's disk size
Paul Marshall - 05/06/2007
How To Create A Virtual Machine from a Physical Disk
Mark Page - 15/06/2006
How to convert a physical computer to Virtual Machine
Greg Duffield - 14/07/2006
Resize VMware virtual disk
Barrington Haynes - 16/07/2007
Unsupported resolutions
Barrington Haynes - 20/06/2006