How to resize LVM partitions Print

  • 0

Sometimes when users install their operating systems from ISOs manually, they choose to install their operating system using LVM and volume groups. LVM's advantage is that filesystems and partitions can be finely controlled, but unfortunately this will not allow automatic storage upgrades should a cloud server ever be upgraded. Here is a rough-around-the-edges guide to increasing LVM and VGs to extend the full size of the disk.

Note, you should have at least a basic knowedge of Linux and your OS before even thinking about attempting this. One slip and you'll lose your entire data. Proceed with caution! We're not responsible for any loss, corruption or damage of data, or its proceeding effects, should you mess up.

  1. First, let's boot from ISO into your favourite live CD. SystemrescueCD is a good choice.
  2. Often times, live CDs will start the lvm/lvm2 service. Make sure we stop this. Launch a terminal window and stop those services.
    service lvm stop
    service lvm2 stop
  3. Let's launch a terminal window, and unmount all filesystems. Don't worry, the ones actually in use will not be unmounted beneath you.
    umount -a
  4. Now, let's remove those active LVM and VGs. If we do not do this, gparted will show a little padlock lock icon indicating the partitions are in use. You can use lvdisplay and vgdisplay to find these paths and names if you have not documented them.
    lvchange -an <lvpath>
    vgchange -an <vgname>
  5. Now, we can open gparted, right-click on the partitions and resize/extend them to the full size of the disk. Note that you may need to perform the above lvchange and vgchange commands after each resize.
  6. We'll go back to that terminal window now, and use lvextend to add space to our LVM. The +10G below represents the base size +10GB extra. You can change this to be whatever size you need, i.e. -L+100G to add 100GB, or -L+1M to add 1MB.
    lvextend -L+10G <lvpath>
  7. We now need to run an e2fsck on the LVM we've just extended:
    e2fsck -f <lvpath>
  8. And finally, we resize it to the maximum:
    resize2fs <lvpath>
  9. Now you can simply reboot (remember to unmount the ISO) to get back to your OS. If it doesn't boot, you've messed up and probably lost your data. But we did warn you.

Was this answer helpful?

« Back