Extending your logical volume on an Ubuntu server is easy with the
Normally, you’d do that with the
df command, but it will not display the correct size of the logical volumes.
Instead, use the vgdisplay (Volume Group Display) command, which displays comprehensive information on volume groups and logical volumes.
There are three important parameters you must pay attention to:
VG Size: This is the volume group size and shows the total available disk size.
Alloc PE/Size: This shows the amount of space that your server is currently allocated
Free PE/Size: Shows the free space out of the total possible storage space
df command only displays the allocated space and not the entire possible space, and this can lead you to assume that you do not have much space left on your server when a lot of space is lying idle as part of the volume group.
To extend the logical volume, use the
lvextend command. But first, get the mount point of the logical volume using the
From the lvdisplay output, you can see that the disk is mounted on the path /dev/ubuntu-vg/ubuntu-lv.
Next, increase the logical volume space using the following command:
sudo lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
100% means using up the entire space, so assign the required percentage according to your needs, e.g. 50%, 60%, etc.
For the changes to take effect you also need to resize the file system comprising the logical volume. Get the file system path from the
df -h command; in this case, it is /dev/mapper/ubuntu–vg-ubuntu–lv.