VMware can run many cool operating systems on a single host computer. But, having run the software for an extended amount of time, i eventually always run out of space on my guest OSes. This happened a few times before, but it wasn’t until my VM really froze up on me that i figured it was time to look into extending or expanding the current virtual disk i had in use.
Have you ever tried increasing the size of a vmdk file / virtual hard disk ?
It’s not that easy.. and it’s kind of confusing.
So, once i finally figured out how to do it, i thought it would be useful to write it down so that i wouldn’t forget next time this happened. Here goes..
In my example i have:
- a Windows Vista host OS running a Fedora Core guest OS
- an 8GB vmdk file (formatted as Linux LVM – fedora fs) on the guest OS which i have backed up before attempting anything here !!!
I want to:
- increase the 8GB vmdk file to 16GB
- not lose any data saved on the vmdk file
- not move any data off/on the vmdk file
Follow these Steps:
- Download and Install: VMware Workstation for Windows (trial)
- Note the location of the VMware Workstation folder (after install) – in my case it’s “C:\Program Files\VMware\VMware Workstation”
- Open a Windows Command Prompt and navigate to the folder where your vmdk file resides and execute the following command:
"C:\Program Files\VMware\VMware Workstation\vmware-vdiskmanager.exe" -x 16GB "Name of Your Virtual Disk File.vmdk"
Ok, now you just made the disk twice as big but you can’t use the space yet because it’s inactive, unpartitioned, unformatted, and still utterly useless to us. (but not for long)
- Next, boot up the guest OS and log in as root. Verify that there is in fact a large amount of unallocated space/sectors by typing the command:
- Then we’ll partition and format the new portion of the disk. First select the disk:
- Type “n” at the fdisk menu to create a new partition
- Type “p” for primary partition, and then select the appropriate partition number, as well as first and last cylinders to set how large to make the new partition (defaults – ie: use all the free space – worked well for me here)
- Type “t” to change the partition’s system id, then type “8e” to switch it to Linux LVM
- Type “w” to write the table to disk and exit fdisk. You might get a warning about needing to reboot for changes to take effect – either way, reboot your guest OS just to be safe.
- Once rebooted, log in as root again and verify the new partition exists. Type “fdisk -l” to see a list of partitions. In my case, the new partition is: /dev/sda3
- Now comes the confusing part. We’re going to merge the new partition into the current Volume Group (which is just what fedora calls it’s own virtual disks that are made up of a bunch of virtual LVM partitions). So, first, to “create” the necessary “physical volume” from our newly created disk partition (/dev/sda3) first type:
- You need to find out the name of the Volume Group before you can extend it to include the newly created physical volume. Type:
vgdisplayand look for the first line, “VG Name” – in this case it was VolGroup00 [thanks agm]
- Next, you need to extend the Volume Group to include the newly created physical volume. Type:
vgextend VolGroup00 /dev/sda3
- Then, type:
pvscanYou should see the new partition (/1dev/sda3) in the list of partitions and the total should read approximately 16GB (the amount we set earlier). In my example, it said 15.75GB
- Now type:
lvextend -L+8GB /dev/VolGroup00/LogVol00to increase / extend the Logical Volume by 8GB (to a total of 16GB).
- Finally, to resize the filing system type:
Now your fedora guest OS should have twice the amount of space and your VM should be running smoothly.
Repeat this process if / when the vmdk file gets filled up again and runs out of space ;)