Saturday, December 20, 2008

How to Resize a VMWare Virtual Disk

My trusty Win 2003 VMWare machine, which I use for testing server side technologies, just ran out of space. I didn’t feel like adding another virtual disk, or reinstalling stuff. So I started searching for a way to increase the size of the disk.

After several hours of reading articles and searching forum posts, each solving one piece of the puzzle, I collected enough clues to solve the issue.

There are 2 parts to resizing your virtual disk:

  1. Resize the actual disk. That can be achieved by creating a new virtual disk and copying the contents from the old one. But no one, including VMWare, promises that would work. But VMWare supplies a utility called VMWare-VDiskManager that gets the job done quite well. It comes as part of VMWare Server or Workstation.
  2. Increasing the size of the main partition to use the newly available space. All articles recommend using a 3rd party partition management software.
    I have a copy of Norton Partition Magic, but it’s limited to client operating systems – no luck with my Win 2003. Other partition management software for “servers” is quite costly (I’m using “servers” because it seems like these applications are crippled on purpose, to allow vendors to charge more for a server version. There’s absolutely no difference between NTFS of Windows XP and 2003).

    I then tried using DISKPART – the built in Microsoft tool, available in XP and higher. The problem is, DISKPART does not allow resizing the boot partition.

    After some research, I found 2 open source partition management utilities that do the work with minimal hassle.

Here it is then, the step-by-step guide to increasing my VDisk from 10GB to 15GB:

  1. Backup – I can’t stress it enough: backup you VMWare before trying anything. The following actions are irreversible, and potentially damaging.
  2. Shut down the OS in the virtual machine, stop the virtual machine and make sure all snapshots are saved.
  3. Open a CMD window, and CD to C:\Program Files\VMware\VMware Workstation.
  4. Run the following command, substitute 15GB with whatever size you want, and the path with the path to your VDisk file:
    vmware-vdiskmanager.exe -x 15GB "f:\My Virtual Machines\Win2003-R2\Win2003.vmdk".
  5. Go and drink a cup of coffee – this command may take a while to execute (it took 20-25 minutes to complete in my case).
  6. Download the freeware Partition Logic, in either floppy disk image (.img file), or CD image (.iso).
  7. In VMWare Workstation, select the floppy disk device, and select to have the device connected at startup, and pointing to the image you just downloaded.
    vmware floppy
    Similarly, you can use a CD image – just make sure your VM is configured to boot from the CD.
  8. Start up the machine, and you’ll get into the main screen of Partition Logic. Select your partition and resize it. You’ll have to manually type the size, in MB, cylinders, or sectors. just type the maximum number in either.
    Partition Logic
    Wait for the operation to finish successfully.
  9. Reboot the machine. You may be required to restart it again (Windows will “discover a new device” and ask for a restart).

Et voila! A new, larger disk, waiting for you to fill it up…

PS: the second software you can use, instead of Partition Logic, is called GParted - it looks better, but the end results are the same.

No comments: