Extend an existing filesystem using LVM !!!

Home »  LINUX »  Extend an existing filesystem using LVM !!!

On October 2, 2016, Posted by , In LINUX, By ,, , With No Comments

In this article, we will see the steps to extend an existing filesystem using LVM i.e Logical Volume Manager.
LVM comprises of three parts,
– Physical Volumes (PVs)
– Volume Groups (VGs)
– Logical Volumes (LVs)

PVs are the actual physical disks. VGs act as a container for the physical volumes. Once the PVs are assigned to VGs, then you can create new LVs, extend/reduce existing LVs, etc.



• Check free space if available

We have a LVM file system “/u01/app” in which we will be adding space.


Below are the details of PV and VG showing that there is no free space available currently.

The above output shows the “PFree” and “VFree” values are “0” means there is no space available in current PV. Hence we will need to add a new disk in order to extend the desired LV.



• Add new disk and create LVM partition

We have added a new disk (/dev/sdc) of size 10G as shown in below output.


Using “fdisk”, create the LVM partition on new disk. For creating LVM partition, the partition type should be selected as “8e”.
Follow below steps,
– To create new partition, type “n”
– Choose primary partition, type “p”
– Choose partition number, type “1”
– To change partition, type “t”
– To change partition to LVM, type “8e”
– Print the partition info, type “p”
– Save the changes and exit, type “w”

Below is the example showing the creation of new partition and changing the partition type to LVM.



• Create Physical Volume (PV)

Using “pvcreate” command, create physical volume for the new disk.


Using “pvs” command, check whether the new disk is added or not in PV.

You can also use “pvdisplay” command for more detailed information.



• Create Volume Group (VG) or Add to an existing VG

If you are configuring LVM for the first time, then you need to create a VG using “vgcreate” command.
# vgcreate newvg /dev/sdc1


Here we already have a VG named “datavg”, hence we will add the PV into this existing VG using “vgextend” command.

Using “vgs” command, check the status of VG. It should show 10G of free space.

You can also use “vgdisplay” command for more detailed information.



• Create Logical Volume (LV) or Extend an existing LV

If you want to create a new LV, then you can create using “lvcreate” command.
# lvcreate -L 500 -n LV01 newvg
# lvcreate -L 2G -n LV02 newvg

In above example, first command will create an LV of size 500M whereas the second command will create an LV of 2GB.


Now we will add space to our existing LV i.e. “/u01/app”. We will add 5GB of space out of available 10GB space. Use “lvextend” command to increase the size of a LV.

The above command will not increase the physical size of a volume. To do that you need to use “resize2fs” command. As the name implies, it is used to resize the filesystem.

To confirm the increase in filesystem size, check using “df” command.

No down time is needed for adding space to a filesystem using LVM.



• Check available free space in PV and VG

Since we added only 5GB out of available 10GB space, if you check the status of “pvs” and “vgs” command it should show 5GB free space. You can use this free space for other LVs in future if needed.


That’s it, adding space into an existing LV filesystem is completed.


Tags : ,, ,

Leave a Reply

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