Introduction to Extend and Reduce LVM
Extend and Reduce LVM, In our previous guide, we gave gone through how to set up Logical Volume management in Linux servers. Now we are about to start with how to Extend and Reduce LVM by adding a new disk to existing Volume group in logical volumes management.
By extending the LVM we will get more space on the fly in our file system without impacting an ongoing production. However, to reduce the space on a logical volume we can’t perform it online, the file-system should be unmounted to reduce the logical volume size. Moreover, filesystem reduce/Shrink will support only on ext3, ext4. XFS only supports extending it won’t support shrink.
For a better understanding of how to perform the Extend and Reduce LVM, we will list out the steps.
Logical volume Series
If you are new to LVM start from our previous article.
- Create Logical volume management LVM file-system in Linux
- Extend and Reduce LVM Logical Volume Management in Linux
Extend an (LVM) Logical volume
To extend the logical volume it’s super easy and takes little time, however, we need to make sure we are about to extend the right logical volume underlying on a Volume group.
- Add new disks or LUN to the server.
- Partition the added disk with the type (8e) for LVM.
- Extend Volume Group with the partitioned disk and get the free physical extents (PE).
- Expand the size of the Logical volume by adding free PE.
- Grow the filesystem by running the particular command.
- Verify the size of the extended filesystem.
Adding New Disk to the Server
Assume we have two disks already in the server. Operating system installed on /dev/sda and /dev/sdb partitioned and used for /data mount point. Now you need to add more 100 GB under /data mount point. Let see how to go forward.
The Present partition and filesystem mount point will look as below.
[root@client1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part /boot
-sda2 8:2 0 19G 0 part
|-centos-root 253:0 0 17G 0 lvm /
-centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 100G 0 disk
-sdb1 8:17 0 100G 0 part
-vg01_data-lv_data 253:2 0 100G 0 lvm /data
sr0 11:0 1 906M 0 rom
[root@client1 ~]#
[root@client1 ~]# df -hP /data/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01_data-lv_data 99G 81G 19G 82% /data
[root@client1 ~]#
In case if you are using SAN storage follow Scanning for attached SAN LUN’s to scan SAN disks.
Prepare/Partition the New Disk for LVM
This article only focusing on Extend and Reduce LVM. However, to prepare the disks refer our existing article FDISK to partition the disks in Linux
Make sure to use the type of disk as (LVM) by choosing (8e) while creating the partition.
[root@client1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part /boot
-sda2 8:2 0 19G 0 part
|-centos-root 253:0 0 17G 0 lvm /
-centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 100G 0 disk
-sdb1 8:17 0 100G 0 part
-vg01_data-lv_data 253:2 0 100G 0 lvm /data
sdc 8:32 0 100G 0 disk
sr0 11:0 1 906M 0 rom
[root@client1 ~]#
[root@client1 ~]# df -hP /data/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01_data-lv_data 99G 81G 19G 82% /data
[root@client1 ~]#
Creating Physical Volume (PV)
Print the current available Physical volume using “pvs“. Now we have only two physical volumes, /dev/sda holding our operating system and /dev/sdb used for /data mount point.
[root@client1 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 centos lvm2 a-- <19.00g 0 /dev/sdb1 vg01_data lvm2 a-- <100.00g 0 [root@client1 ~]#
Create the new Physical Volume using /dev/sdc1 partitioned disk.
# pvcreate /dev/sdc1
Above output shows only two Physical volumes, Below output, is after creating new physical volume showing three PVs.
[root@client1 ~]# pvcreate /dev/sdc1 Physical volume "/dev/sdc1" successfully created. [root@client1 ~]# [root@client1 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 centos lvm2 a-- <19.00g 0 /dev/sdb1 vg01_data lvm2 a-- <100.00g 0 /dev/sdc1 lvm2 --- <100.00g <100.00g [root@client1 ~]#
We are done with creating a physical volume to extend the volume group.
Extend the Volume Group
Now it’s time to extend the existing Volume Group by adding the physical volume created from /dev/sdc1. Let’s list the PV, VG and get to know the size and more information before starting with extending the VG.
To print the current size of a Physical Volume, Volume Group or to know more information use
# pvs # vgs # vgdisplay vg01_data
Extend the size of Volume Group vg01_data by adding a new disk to it.
# vgextend vg01_data /dev/sdc1
We are able to see the free space 100 GB now.
[root@client1 ~]# vgextend vg01_data /dev/sdc1 Volume group "vg01_data" successfully extended [root@client1 ~]# [root@client1 ~]# vgs VG #PV #LV #SN Attr VSize VFree centos 1 2 0 wz--n- <19.00g 0 vg01_data 2 1 0 wz--n- 199.98g 99.99g [root@client1 ~]#
After adding the /dev/sdc1 disk to the volume group (vg01_data) verify by running “pvs” command and we are able to see /dev/sdc1 used under vg01_data.
[root@client1 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 centos lvm2 a-- <19.00g 0 /dev/sdb1 vg01_data lvm2 a-- 99.99g 0 /dev/sdc1 vg01_data lvm2 a-- 99.99g 99.99g [root@client1 ~]#
Verify the extended Volume Group
Run “vgdisplay <vg-name>” to get more information about the volume group.
# vgdisplay vg01_data

- A Volume Group can be resizeable/Extendable.
- Currently residing Logical volume under this VG.
- The logical volume underuse.
- Currently the number of Physical volumes used under vg01_data.
- The number of Physical volumes is used under this Volume Group.
- The total size of Volume group at the moment.
- The default size of PE used in this Volume Group.
- Sum of total PE used under this VG.
- Allocated PE for the VG.
- Number of PE available in this Volume Group after extension.
In the above output, we can notice Free PE available under vg01_data are 12799 PE and each PE size is 8 MB. If you need to extend the logical volume with 100 GB from the current size then you can extend using PE size by running “lvextend” with (-l) or using Unit size with (-L).
The default size of a physical extend is 4 MB but this Volume Group created with a physical extent of 8 MB so let’s do a small calculation to understand the clear picture for extending with PE.
8 MB X 12799 PE = 102,392 MB/1024 MB = 100 GB
Extend the Logical Volume
Extend the logical volume with PE size.
While extending don’t forget to use “+” it means adding additional space from the current capacity. And “-l” or “–extents” can be used to extend a filesystem using PE. Additionally even we can use the suffix “%FREE” to consume the remaining free space from a Volume Group or in case if you need to use 25% of free space from 100 GB you can use “+25%FREE” examples are shown below.
# lvextend -l +12799 /dev/mapper/vg01_data-lv_data # lvextend -l +25%FREE /dev/mapper/vg01_data-lv_data
Once extended the size of Logical Volume (LV) we can use any one of below command to print the information of logical volume.
# lvs /dev/mapper/vg01_data-lv_data # lvs
[root@client1 ~]# lvextend -l +12799 /dev/mapper/vg01_data-lv_data Size of logical volume vg01_data/lv_data changed from 99.99 GiB (12799 extents) to 199.98 GiB (25598 extents). Logical volume vg01_data/lv_data successfully resized. [root@client1 ~]# [root@client1 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- <17.00g swap centos -wi-ao---- 2.00g lv_data vg01_data -wi-ao---- 199.98g [root@client1 ~]#
To get detailed information about the same LV use
# lvdisplay /dev/mapper/vg01_data-lv_data

- The name of the logical volume.
- Volume group where the LV resides.
- Logical Volume in reading and write mode.
- It’s available for ready to use.
- The present size of logical volume after extend.
- The number of extends used under this logical volume.
The actual extended size will not reflect until we run the resize2fs / xfs_growfs on the filesystem.
Same thing if we need to extend the logical volume using Unit size then we need to replace small (-l) with a capital (-L) and use + GB in size, We are showing an example below.
Extend the logical volume using Unit size.
Use “-L” or “–size” options.
# lvextend -L +100G /dev/mapper/vg01_data-lv_data
The Units can be mentioned with MegaByte (MB), GigaByte (GB) and TeraByte (TB).
Resize or Grow the file-system
After completed with extending the logical volume next step is extent the file-system. To extend/grow the FS we required to run anyone of command and it depends on the filesystem type we are creating.
We have created with an EXT4 filesystem so we need to use the resize2fs command by pointing to the logical volume.
# resize2fs /dev/mapper/vg01_data-lv_data
[root@client1 ~]# resize2fs /dev/mapper/vg01_data-lv_data resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/mapper/vg01_data-lv_data is mounted on /data; on-line resizing required old_desc_blocks = 13, new_desc_blocks = 25 The filesystem on /dev/mapper/vg01_data-lv_data is now 52424704 blocks long.
Space has been increased.
[root@client1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part /boot
-sda2 8:2 0 19G 0 part
|-centos-root 253:0 0 17G 0 lvm /
-centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 100G 0 disk
-sdb1 8:17 0 100G 0 part
-vg01_data-lv_data 253:2 0 200G 0 lvm /data
sdc 8:32 0 100G 0 disk
-sdc1 8:33 0 100G 0 part
-vg01_data-lv_data 253:2 0 200G 0 lvm /data
sr0 11:0 1 906M 0 rom
[root@client1 ~]#
[root@client1 ~]# df -hP /data/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg01_data-lv_data 197G 81G 117G 41% /data
[root@client1 ~]#
If you are using XFS as your filesystem just try to extend the FS by running xfs_growfs by pointing the mount point.
# xfs_growfs /data/ # xfs_growfs /dev/mapper/vg01_data-lv_data
Verify the size of the extended filesystem
To know the extended filesystem we have multiple options. By running “lsblk” or “df -hP“.
[root@client1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part /boot
-sda2 8:2 0 19G 0 part
|-centos-root 253:0 0 17G 0 lvm /
-centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 100G 0 disk
-sdb1 8:17 0 100G 0 part
-vg01_data-lv_data 253:2 0 200G 0 lvm /data
sdc 8:32 0 100G 0 disk
-sdc1 8:33 0 100G 0 part
-vg01_data-lv_data 253:2 0 200G 0 lvm /data
sr0 11:0 1 906M 0 rom
[root@client1 ~]#
We have done with extending the filesystem. As we mentioned before extending filesystem is super easy and done on the fly without unmounting the filesystem.
Click NEXT to continue reading for How to Reduce/Shrink Logical Volume Management.