02.27.08

Resizing a Windows VMware Workstation image in Linux

Posted in Intermediate, Linux at 12:01 pm by Techie

While I tend to like running Ubuntu on the desktop, I sometimes find myself needing to run Windows programs for various things. For that, I actually got VMware Workstation for Linux, and set up a Windows XP Professional image, with a partition size of 8 GB. I rarely use the image, so imagine my surprise when I actually ran out of disk space in the partition. I was further confounded to find that you couldn’t dynamically resize the partition. The problem is twofold: needing to resize the VMware disk image, and then needing to resize the partition on which Windows is installed to fill the VMware disk image.

Resize the VMware Disk Image

To resize the VMware disk image, we can use the program vmware-vdiskmanager. Make backups before proceeding. I had an 8 GB partition now, so let’s make it a 40 GB partition instead:


$ vmware-vdiskmanager -x 40GB /path/to/my/image/mywindowsimage.vmdk
Using log file /tmp/vmware-jlee/vdiskmanager.log
The old geometry C/H/S of the disk is: 16383/16/63
The new geometry C/H/S of the disk is: 16383/16/63
Disk expansion completed successfully.

WARNING: If the virtual disk is partitioned, you must use a third-party
utility in the virtual machine to expand the size of the
partitions. For more information, see:

http://www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=1647

Good so far. Now, the disk image is 40 GB, but the partition on the disk is still set to 8 GB. What we want to do is grow the partition to fill the newly allocated space.

Boot an Ubuntu Live CD

To resize the partition, I can use a Linux live CD. Rather conveniently, I can use the same Ubuntu live CD that I used to install Linux on my desktop.

It took me a while to figure out how to boot a CD in VMware, mostly because the BIOS screen for VMware disappears so quickly. When starting up the VMware image, I hit F2 quickly before Windows started loading to enter the VMware BIOS. Then I could go to the Boot menu, and set the CD-ROM drive to boot before the hard disk. Otherwise, it would start directly into Windows.

Once that was done, I made sure that a Gutsy Gibbon live CD was in the CD-ROM drive, and restarted the VMware image.

Resize the Partition

Now I had the Ubuntu live CD running in my VMware image. I went to System -> Administration -> Partition Editor. I clicked on the partition, clicked “Resize/Move”, and dragged the right slider all the way to the right, to fill the disk. I clicked the “Resize/Move” button, then “Apply”. After it completed, I restarted the VMware image, which prompted Windows chkdisk to run, and then reboot again. Once Windows booted up, Windows noted that it had detected new hardware and needed a reboot. I let it do so, and just like that, I had grown my 8 GB drive to 40 GB.

Conclusion

So there you have it — if you have half an hour and a current Ubuntu live CD, you can resize your VMware image. As with any disk editing operations, you should always make backups before making changes. It’s kind of annoying that the image doesn’t dynamically grow, but it’s nice to know that it can be handled. What’s also cool is to be able to use Linux live CDs to edit properties of VMware instances.

2 Comments »

  1. Joel said,

    May 8, 2008 at 9:13 pm

    Thanks. That was to the point. Also, if you don’t have a live CD about you can use GPartEd (search sourceforge, don’t have link handy).
    You don’t need to burn to a cd you can just mount the ISO to the VM by editing the CD’s properties and choosing “mount ISO”.

  2. Nicholas said,

    August 28, 2008 at 1:26 pm

    Hey !
    I just tried this on my Heron laptop and Workstation 6.0.
    Worked like a charm ! Thanks for this super helpful post.

Leave a Comment

Bad Behavior has blocked 2087 access attempts in the last 7 days.