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:
fdisk -l - Then we’ll partition and format the new portion of the disk. First select the disk:
fdisk /dev/sda - 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:
pvcreate /dev/sda3 - 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:
resize2fs /dev/VolGroup00/LogVol00
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 ;)
Comments 9
thanks.
Posted 09 Jan 2010 at 6:38 pm ¶it’s works
hey, you’re welcome andrei
Posted 13 Jan 2010 at 2:23 pm ¶glad to see it’s worked for others too!
elran, thanks
Posted 26 Feb 2010 at 2:51 pm ¶the only part was diff for fedora12 is VolGroup00
vgdisplay to find display attributes of your local volume groups
otherwise pretty straight forward steps.
agm
thanks agm, that’s true!
Posted 04 Mar 2010 at 10:41 am ¶it looks like the default name for your volume groups in FC12 is your hostname with a prefix of “vg_” – so if your hostname for your machine is linuxbox, the name of your volume group would be vg_linuxbox (by default).
It works like a charm (winXP, fedora 8). Thanks a lot.
Posted 25 Apr 2010 at 6:28 pm ¶@tuan – glad it worked for you!
Posted 27 Apr 2010 at 11:59 am ¶Great!!!
Posted 18 Dec 2010 at 4:34 am ¶I have searched for the solution for a whole afternoon. Thanks a lot~
I recently found this website that I want to share with everyopne as they were a huge help when I was
working on a recent project. I needed to know how to do some stuff in PHP and they were able to provide
a tutorial sepcifically tailored to my needs. It was fantastic.
TeamTutorials
I recommend you hit them up and check them out if you need assistance.
Posted 20 Feb 2011 at 11:23 am ¶I think this is among the most vital information for me. And i’m glad reading your article. But should remark on some general things, The website style is wonderful, the articles is really great : D. Good job, cheers
Posted 27 Oct 2011 at 7:27 am ¶Post a Comment