[Update] Someone going under the name ‘longhorn’ just posted a comment that the method described here is dangerous and has led to problems with his image. And although I have used this myself with no problems so far, I do believe that it’s better to be safe than sorry. Apparently, there is a better tool to manage vmware images, called diskTool (typically found under /Applications/VMware Fusion.app/Contents/MacOS). A quick test to grow an image failed with a malloc error, but I will look into this and update this post. And the golden rule to always make a backup before you try stuff like this, still applies of course (I *do* mention this in the post)…
I’m probably not the only VMware user who has underestimated the amount of disk space he needs, only to find out a couple of months later, that the disk is filling up faster than expected. Fortunately, this is (relatively) easy to fix. That is, if you have enough ‘real’ HD space of course!
Warning: always backup your data before doing things like changing partitions etc…!
First, download a copy of vdiskmanager-GUI (oh, I forgot to mention: I will explain how to do this on a Mac). I could only find it here (technically speaking you don’t need this, as it is just a wrapper around the VMware provided vmware-vdiskmanager command-line tool). Open this tool, and select the ‘Expand’ tab. Choose the vmdk (virtual disk image) you want to expand, and enter its desired size (6Gb in my case):
If you click ‘Go’, the vmdk file will expand to the desired size.
For those of you that don’t have a mac: you really should 🙂 No, you can easily accomplish the same thing: on the bottom of the screen you can see the command that will be executed if you click ‘Go’. So just locate vmware-vdiskmanager (it is probably somewhere in your c:\program files\vmware directory, and run it with -x <desired size> <path_to_vmdk>. This should do the trick. Or even better, just download the VMware-diskmanager GUI for PC here.
When you reboot the VM, you might be surprised to see that you hard disk in your guest OS (say, Windows XP in this case), is still at its original size! Although it might sound confusing, it is actually perfectly logical, as we haven’t changed the partition, we only changed the ‘hard disk’ the partition is residing on. One way of ‘fixing’ this is doing a complete reinstall of the system, thereby repartitioning the disk. Although it works, it’s certainly not something most of us will look forward to (as it erases all of your current apps and data).
Luckily for us, there is a much simpler way. Just download a copy of a gparted live-cd (ie a cd that is bootable). gparted is the Gnome Partition Editor, which is a linux tool to, you probably guessed it, edit partitions. Although it is linux tool, it does support ntfs, which should be the Windows filesystem you’re using (a list of the supported filesystems). And even better: since it is a live-cd, you don’t even have to install anything. Just download the iso file, and connect the CD player of your VM to this ISO:
Now the tricky part: in order to run gparted, you have to start your VM, but force it to boot from this CD instead of your HD. The traditional way of doing this, is to press F2 to enter the BIOS setup. However, under VMware, this is a trail-and-error process, as you have to be really fast to press F2 or it will just boot from the HD.
Fortunately, there is a work-around. In your .vmx file, just add
bios.forceSetupOnce = “TRUE”
This forces VMware to enter the BIOS setup on the next boot (this setting is automatically set to FALSE). In the BIOS, make sure that your CD drive is above your hard drive, exit the BIOS and restart the VM.
Now you should see linux booting, and gparted will automatically start-up (I selected the default setting on the first list, then just pick your keyboard and language settings from the list).
If the disk you want to expand, is not already selected, use the drop-down to select it. Then, click ‘Resize/Move’ and either visually resize the partition, or just enter its new size:
Close the dialog (‘Resize/Move’) and click ‘Apply’ to actually perform the partition change. After this is done, exit gparted and disconnect the iso from the CD. If necessary, change the boot order in the BIOS setup, and restart into your guest OS. In Windows, this will typically bring up the chkdsk utility. This will check your partition (which is probably a good thing). After that is done: you can start to use that newly added disk space!