Nimble Coder

Adventures in Nimble Coding
posts - 77, comments - 49, trackbacks - 1

Resizing Virtual Machines Guide with VMware

Lately I've been setting up a lot of virtual machines. It is time-consuming and frustrating but the end results are extremely useful. I discovered that using Windows 2003 R2 consumes a lot of hard disk space. I started with an 8 Gb virtual hard drive and before I knew it I ran out of space. Of course, depending on the VM I needed Microsoft Office, or Visual Studio, or SharePoint, or SQL Server, or BizTalk, or all of the above. I developed my base virtual machine first and then sysprep-ped it and then started installing all of the requisite software.

Once I realized there was no way the VM would survive with limited disk space, I set out to increase the virtual disk capacity. Unfortunately you can't resize the partition through Windows but you need to download a partition editor to do this.

Step 1: Resize the virtual hard disk with "vmware-vdiskmanager"

Open a command prompt (I like Console2) and change the directory to your VM image location. Use the "vmware-vdiskmanager -x" command to increase the hard disk size. I preferred to add the VMware directory to the path so I didn't have excessively long commands. For example, the command I used was:

SET PATH=%PATH%;C:\Program Files\VMware\VMware Server

vmware-vdiskmanager -x 16GB win2k3-sql.vmdk

vmware-vdiskmanager-grow

When the disk manager is finished resizing the disk, it looks like the following:

vmware-vdiskmanager-done

For reference, the help text from "vmware-vdiskmanager --help" is at the end of this post.

Step 2: Download GNU Partition Editor (GPartEd)

There were several recommendations on the VMware web site, but the GNU Partition Editor seemed to be the smallest and easiest way to edit the partition table.

Step 3: Mount the gparted ISO in VMware

Select the VM\Settings menu item

vmware-settings

vmware-console

Step 4: Reboot the VM and select the Boot Menu

You have to act fast when you reboot the VM. Click on the main window area to set the window focus and then press 'Esc' key to open the boot menu and then from the CD-ROM Drive. You need to click on the window to set focus because at this point in the boot process, the vmtools isn't loaded and can't provide the normal integration features.

gparted-boot

Step 5: Resize the partition

Select the primary partition and right-click on the partition and select "Resize".

gparted-main

Expand the partition

gparted-resize

When it is finished, it displays the results

gparted-results

Step 6: Reboot the VM

The VM will most likely check the disk since the dimensions have changed.

win2k3-chkdsk

Once it has finished, you should be done. Congratulations!


Reference

Here is the "vmware-vdiskmanager --help" output:

VMware Virtual Disk Manager - build 56528.
Usage: vmware-vdiskmanager.exe OPTIONS diskName | drive-letter:
Offline disk manipulation utility
  Options:
     -c                   : create disk; need to specify other create options
     -d                   : defragment the specified virtual disk
     -k                   : shrink the specified virtual disk
     -n <source-disk>     : rename the specified virtual disk; need to
                            specify destination disk-name
     -p                   : prepare the mounted virtual disk specified by
                            the drive-letter for shrinking
     -q                   : do not log messages
     -r <source-disk>     : convert the specified disk; need to specify
                            destination disk-type
     -x <new-capacity>    : expand the disk to the specified capacity

     Additional options for create and convert:
        -a <adapter>      : (for use with -c only) adapter type (ide, buslogic or lsilogic)
        -s <size>         : capacity of the virtual disk
        -t <disk-type>    : disk type id

     Disk types:
        0                 : single growable virtual disk
        1                 : growable virtual disk split in 2Gb files
        2                 : preallocated virtual disk
        3                 : preallocated virtual disk split in 2Gb files

     The capacity can be specified in sectors, Kb, Mb or Gb.
     The acceptable ranges:
                           ide adapter : [100.0Mb, 950.0Gb]
                           scsi adapter: [100.0Mb, 950.0Gb]
        ex 1: vmware-vdiskmanager.exe -c -s 850Mb -a ide -t 0 myIdeDisk.vmdk
        ex 2: vmware-vdiskmanager.exe -d myDisk.vmdk
        ex 3: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 0 destinationDisk.vmdk
        ex 4: vmware-vdiskmanager.exe -x 36Gb myDisk.vmdk
        ex 5: vmware-vdiskmanager.exe -n sourceName.vmdk destinationName.vmdk
        ex 6: vmware-vdiskmanager.exe -k myDisk.vmdk
        ex 7: vmware-vdiskmanager.exe -p m:
              (A virtual disk first needs to be mounted at m:
               using the VMware Diskmount Utility.)
kick it on DotNetKicks.com

Print | posted on Tuesday, February 19, 2008 12:05 PM | Filed Under [ Tools ]

Feedback

Gravatar

# re: Resizing Virtual Machines Guide with VMware

Thanks,

That was by far the best of all of the How To documents I have read. I've used GPART in unix before so I was familiar with it and by adding the small screen shots you simply made the process almost 100% full proof.

I'd give this a 9.8/10!

Thanks for the simply DIY How To for this. I'll be doing it this week.
7/21/2008 2:18 PM | Ray
Gravatar

# re: Resizing Virtual Machines Guide with VMware

Good article but a word of warning. I expanded a Windows Server 2008 guest and it did not want to reboot. The error reported was "unable to find winload.exe". The fix was to boot from the Windows install DVD, choose System Repair, Command Prompt, and then run bootrec /RebuildBcd to rebuild the boot record. I then restarted the guest VM with the newly re-sized drive. Windows required another reboot and all was well.
8/2/2008 11:45 PM | J
Gravatar

# re: Resizing Virtual Machines Guide with VMware

Great stuff :)
2/10/2009 6:59 AM | Anonymous
Gravatar

# re: Resizing Virtual Machines Guide with VMware

Thanks for the detailed walkthrough!

If you put this line in your .vmx file before step 4, it makes getting to the boot menu much easier:

bios.bootdelay="5000"

The value is just the amount of milliseconds to wait.

Thanks
6/12/2009 7:03 AM | Mark
Gravatar

# re: Resizing Virtual Machines Guide with VMware

it cant find the file give the error failed to open "such and such" file not found followed by a memory location. help? my email is listed could really use it.
8/31/2009 2:37 AM | Charlie
Gravatar

# re: Resizing Virtual Machines Guide with VMware

Very nice...I have a windows VM in a VMware setup and the C:\ partition was too small. I used this software and your guide to expand it to 20GB with no issues. After expanding, I rebooted and VMware detected the change, did a quick check and then when windows came up, I had to reboot again. That's it! Thank you.
7/27/2010 6:37 PM | mike
Gravatar

# re: Resizing Virtual Machines Guide with VMware


It´s really works!
11/8/2010 8:41 PM | Leo
Gravatar

# re: Resizing Virtual Machines Guide with VMware

...does not work with OpenSolaris ZFS file systems.
GParted does not recognize and allow resize of ZFS formatted partitions.
5/17/2011 2:37 AM | Peter
Gravatar

# re: Resizing Virtual Machines Guide with VMware

Thanks, I'm sure this article will help me later. But now if only 1 of the hundreds of google results or VMware's site itself would give the slightest hint how to acquire "vmware-vdiskmanager"... One hour looking. . .
10/2/2011 10:33 AM | justin
Gravatar

# re: Resizing Virtual Machines Guide with VMware

@justin - You shouldn't have to download vmware-vdiskmanager. vmware-vdiskmanager is normally in %ProgramFiles%\VMware\VMware Server or %ProgramFiles(x86)%\VMware\VMware Server (typically C:\Program Files (x86)\VMware\VMware Server or VMware Workstation). This is why I added VMware to the PATH in Step 1. I don't know if VMware Player has this utility though.
10/3/2011 6:17 PM | ryanvs

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 7 and 7 and type the answer here:

Powered by: