Open Source

Extending partitions on Linux VMware virtual machines

Lauren Malhoit explains how she extended her Linux partitions.

I  had a couple Zenoss VMware appliances that run Linux that needed to have more space allocated to them.  I knew just adding another hard drive wouldn't solve the issue so I set about finding the least intrusive way to do this and not break the whole VM appliance.  If you've ever used Zenoss, you know the last thing you want to do is re-configure all of your settings again!

There is some information out there on this, but I found most of it to be hard to understand and didn't really explain what the steps were.  If you're someone who isn't used to working with Linux, I imagine it would be almost impossible to change these settings confidently.  So, here are the steps I followed to extend my Linux partitions.  This only applies to ext3 disks that use the logical volume manager.  If you're running a RedHat, CentOS or other similar Linux distro, this process will work for you.

  1. Shutdown the VM
  2. Right click the VM and select Edit Settings
  3. Select the hard disk you would like to extend
  4. On the right side, make the provisioned size as large as you need it
  5. Click OK
  6. Power on the VM
  7. Connect to the command line of the Linux VM via the console or putty session
  8. Log in as root
  9. The fdisk command provides disk partitioning functions and using it with the -l switch lists information about your disk partitions.  At the command prompt type fdisk -l
  10. The response should say something like Disk /dev/sda : xxGB. (See Figure A)
  11. At the command prompt type fdisk /dev/sda. (if dev/sda is what was returned after step 10 as shown in Figure A)
  12. Type p to print the partition table and press Enter (also shown in Figure A)
  13. Type n to add a new partition
  14. Type p again to make it a primary partition
  15. Now you'll be prompted to pick the first cylinder which will most likely come at the end of your last partition (ex: /dev/sda3 ends at 2610).  So I chose 2611 for my first cylinder, which is also listed as the default.
  16. If you want it to take up the rest of the space available (as allocated in step 4), just choose the default value for the last cylinder.
  17. Type w to save these changes
  18. Restart the VM
  19. Log back in as root
  20. At the command prompt type fdisk -l. You'll notice another partition is present.  In Figure B it is listed as sda4.
  21. You need to initialize this new partition as a physical volume so you can manipulate it later using the Logical Volume Manager (LVM).
  22. Now you'll add the physical volume to the existing volume group using the vgextend command. First type df -h to find the name of the volume group.  In Figure C, the name of the volume group is vg_root. Now type vgextend [volume group] /dev/sdaX. (ex: vgextend vg_root /dev/sda4)
  23. To find the amount of free space available on the physical volume type vgdisplay [volume group] | grep "Free"
  24. Extend the logical volume by the amount of free space shown in the previous step by typing lvextend  -L+[freespace]G /dev/volgroup/volume. (ex: lvextend -L+20G /dev/vg_root/lv_root)
  25. You can finally expand the ext3 file system in the logical volume using the command resize2fs /dev/volgroup/volume (ex: resize2fs /dev/vg_root/lv_root).
  26. You can now run the df command to verify that you have more space--df -h

Figure A

Figure B

Figure C

It seems like there are a lot of steps to this process, but it's actually pretty quick and easy if you can afford to restart your server.  So far I haven't had any issues with dynamically extending the partitions and I'm getting a lot less Zenoss notifications about lack of free space.


Lauren Malhoit has been in the IT field for over 10 years and has acquired several data center certifications. She's currently a Technology Evangelist for Cisco focusing on ACI and Nexus 9000. She has been writing for a few years for TechRepublic, Te...



Thanks for the information. I followed the above steps and could resize and format the partition.

However, when I try to mount it on a folder, I get the error-

/dev/sdb2 already mounted or /mnt/new(mount point) is busy.

Any idea why?

I don't see /dev/sdb2 mounted anywhere and also /mnt/new is a new folder.


I have read and followed this article to extend my Hard disk space on CentOS 6.5 running on Hyper-V it worked perfectly


Thanks Lauren, great procedure!  I have minimal Linux experience but was able to use your write-up to extend the root file system on a CentOS 6.5 VM (ESX 5.5).

Here are a few tweaks I had to make (probably due to my lack of experience):

Step 11:  I added switches (-c -u) to fdisk to avoid deprecated modes ("DOS compatible" and "cylinders displayed as units" - as advised by fdisk when I first launched it)

Step 21:  I didn't do anything to initialize the new partition and the rest of the procedure worked

Step 22:  I used the lvs command to find the volume group name.  The df output combines the vg and lv names, which wasn't obvious to me.  lvs has column labels.  :)

Thanks again for writing this!  Like you said, it allows someone with minimal Linxux experience to extend a file system quickly and easily.


Hi, I would like to ask if the file system drive doesn't have a Volume Group and logical Volume Group .. what i shall do as it gives me error when i try to extend the file system drive with the new pv


I was using couple of Fedora 13 VMs with miserable HD size. I expanded the HD Size from VM Player and then followed the instructions here to upgrade HD of the VMs in couple of minutes without any issues. Thanks a lot.


If your first disk (/dev/sda or whatever) already has four primary partitions - this method will NOT work. You'll have to add another vdisk at the VM level (as Lauren mentioned at the top of the article), add it to the volume group at the OS level, create a logical volume, then extend the filesystem to make use of the new space (I'm going from memory so the steps may need some research, Google is your friend). However, if you have three primary partitions and an extended partition, you're still good to use Lauren's method as long as there's free space on the drive (i.e., not allocated to partitions already).

Editor's Picks