Resize LVM Ubuntu Server

LVM2 is the standard tool and preset installed on Ubuntu Server by default when we install Ubuntu Server. Although this is not strictly mandatory and can be removed.

But sometimes some people — and even I myself — get confused when using Ubuntu Server and seeing that the storage partition size is not 100% allocated.

This is normal, considering that allocating 100% of the storage has side effects and is inefficient, the details of which will probably be discussed in a different article.

But for now let’s go straight to the list of commands commonly used to resize partitions.

  1. To see the size or remaining storage that can be allocated
    sudo vgdisplay
  2. Resize disk
    sudo lvextend -l 100%FREE <path>
    sudo resize2fs <path>
  3. Reduce disk
    lvreduce -L -8G <path>
    sudo resize2fs <path>

If you are using a VM and have added storage, running lvextend directly will generally not work for allocating the extra storage. To work around this, you can grow the partition first with the tool below

sudo cfgdisk

References

  1. https://askubuntu.com/questions/124465/how-do-i-shrink-the-root-logical-volume-lv-on-lvm
  2. https://www.tecmint.com/extend-and-reduce-lvms-in-linux/
  3. https://howtovmlinux.com/articles/vmware/resize-lvm-disk-after-extending-virtual-machine-disk-vmdk/

Leave a comment

Your email address will not be published. Required fields are marked *