How to Extend and Reduce LVM Logical Volume in Linux

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.

  1. Create Logical volume management LVM file-system in Linux
  2. 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.

  1. Add new disks or LUN to the server.
  2. Partition the added disk with the type (8e) for LVM.
  3. Extend Volume Group with the partitioned disk and get the free physical extents (PE).
  4. Expand the size of the Logical volume by adding free PE.
  5. Grow the filesystem by running the particular command.
  6. 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
Before extending Volume group and Logical volume.
Before extending Volume Group
  1. A Volume Group can be resizeable/Extendable.
  2. Currently residing Logical volume under this VG.
  3. The logical volume underuse.
  4. Currently the number of Physical volumes used under vg01_data.
  5. The number of Physical volumes is used under this Volume Group.
  6. The total size of Volume group at the moment.
  7. The default size of PE used in this Volume Group.
  8. Sum of total PE used under this VG.
  9. Allocated PE for the VG.
  10. 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
After extending the Logical volume
After extending the Logical volume
  1. The name of the logical volume.
  2. Volume group where the LV resides.
  3. Logical Volume in reading and write mode.
  4. It’s available for ready to use.
  5. The present size of logical volume after extend.
  6. 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.

Reduce LVM | Shrink a Logical volume

As part of Extend and Reduce LVM, Now we are about to see how to reduce the logical volume. In case, if your file system is created with a number of disks also large but 150 GB is more than enough for your production. The remaining size can be reduced for another requirement then the shrink will come into the picture.

To reduce an LVM there are several steps we need to follow. First, un-mount the file-system, then need a check for errors. Let’s list out all the steps we are about to perform for an LVM shrink.

  • Un-mount the file-system.
  • Force the e2fsck to check for any errors.
  • Resize the filesystem to any desired size.
  • Reduce the logical volume size.
  • Again run resize to confirm the changes.
  • Do a force check for file-system error.

Currently, LVM which is about to reduce mounted under /data mount point with 200 GB in total size and 98 GB of free space.

[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   91G   98G  48% /data
[root@client1 ~]# 

Un-mount the file-system.

# umount -v /data/

Check File-System for errors

Before starting with shrinking a volume we need to make sure whether the file-system is clean without any errors. While the file-system already in the clean state the “e2fsck” won’t work so we need to force it for a check.

# e2fsck -ff /dev/mapper/vg01_data-lv_data 
  • -ff option to force the file system check even though it’s clean.

While running the check it should pass all the 5 checks. In case any check failed it’s strongly advised to fix it before performing with LV Shrink.

Output from Shell

[root@client1 ~]# e2fsck -ff /dev/mapper/vg01_data-lv_data 
 e2fsck 1.42.9 (28-Dec-2013)
 Pass 1: Checking inodes, blocks, and sizes
 Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
 /dev/mapper/vg01_data-lv_data: 13/13107200 files (0.0% non-contiguous), 24463708/52424704 blocks
[root@client1 ~]#

Verify the logical volume and underlying volume group to make sure you are reducing the right LVM.

# pvs
# vgs
# lvs

Try to check all information before reducing.

[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    0 
[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    0 
[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-a----- 199.98g                                                    
[root@client1 ~]#
[root@client1 ~]# ls -lthr /dev/mapper/vg01_data-lv_data 
 lrwxrwxrwx. 1 root root 7 Jul 17 19:27 /dev/mapper/vg01_data-lv_data -> ../dm-2
[root@client1 ~]# 

Resize the fileSystem

Now it’s time to reduce the file system by running “resize2fs” to our desired size. Currently consumed size under /data is 91 GB but the logical volume size is 200 GB for some other requirement we need to reduce 50 GB from the total volume size. So, after reducing it should be 150 GB.

# resize2fs /dev/mapper/vg01_data-lv_data 150G

We are able to see the filesystem reduce.

[root@client1 ~]# resize2fs /dev/mapper/vg01_data-lv_data 150G
 resize2fs 1.42.9 (28-Dec-2013)
 Resizing the filesystem on /dev/mapper/vg01_data-lv_data to 39321600 (4k) blocks.
 The filesystem on /dev/mapper/vg01_data-lv_data is now 39321600 blocks long.
[root@client1 ~]#

Shrink the Logical Volume

Once resize to the desired size by following run “lvreduce” to make the actual logical volume shrink. We are about to use Unit size (-L) to reduce the logical volume.

Method 1: Reduce with unit Size

# lvreduce -L -50G /dev/mapper/vg01_data-lv_data
  • lvreduce – command to reduce the Logical volume.
  • -L to reduce using Unit size.
  • -50G reducing 50 GB from the current capacity.
  • /dev/mapper/vg01_data-lv_data the LV we need to shrink.
Extend and Reduce LVM - Reducing Logical Volume
Reducing Logical Volume
  1. The shrink to our desired size.
  2. Confirm by entering “y” to proceed with reducing LVM
  3. We have successfully completed

Resize the filesystem after LV Reduce

Once completed with LV reduce next we should run resize command to finalize the filesystem.

# resize2fs /dev/mapper/vg01_data-lv_data
[root@client1 ~]# resize2fs /dev/mapper/vg01_data-lv_data 
 resize2fs 1.42.9 (28-Dec-2013)
 Resizing the filesystem on /dev/mapper/vg01_data-lv_data to 39317504 (4k) blocks.
The filesystem on /dev/mapper/vg01_data-lv_data is now 39317504 blocks long.

Check for FS error after LV Reduce

Finally, Once again check for any file system error by running a force check.

# e2fsck -ff /dev/mapper/vg01_data-lv_data 

All the 5 checks should pass without fail.

[root@client1 ~]# e2fsck -ff /dev/mapper/vg01_data-lv_data 
 e2fsck 1.42.9 (28-Dec-2013)
 Pass 1: Checking inodes, blocks, and sizes
 Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
 /dev/mapper/vg01_data-lv_data: 12/9830400 files (0.0% non-contiguous), 21636667/39317504 blocks
[root@client1 ~]# 

Mount the filesystem back

Mount the file system back to mount point and print the FS utilization to verify the same.

# mount /dev/mapper/vg01_data-lv_data /data/
# df -hP /data/
# lsblk

Now we can see the reduced volume size to 150 GB.

[root@client1 ~]# mount /dev/mapper/vg01_data-lv_data /data/
 [root@client1 ~]# 
 [root@client1 ~]# df -hP /data/
 Filesystem                     Size  Used Avail Use% Mounted on
 /dev/mapper/vg01_data-lv_data  148G   81G   68G  55% /data
[root@client1 ~]# 
[root@client1 ~]# 
[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  150G  0 lvm  /data
 sdc                     8:32   0  100G  0 disk 
  -sdc1                  8:33   0  100G  0 part  
    -vg01_data-lv_data 253:2    0  150G  0 lvm  /data
 sr0                    11:0    1  906M  0 rom  
[root@client1 ~]# 

Shrinking a Logical volume using (PE) Extends

Method 2: Reduce with extend Size

In the above steps, we saw reducing logical volume using Unit size (-L) but now let’s walk through reducing a logical volume using extend size with (-l) option.

Let me try to reduce 50 GB from the current size 150GB. A small calculation from Linux native calculator “bc” will help us to do this.

1024 MB (1GB) x 50 GB = 51,200 MB

Now we got the total size in MB, divide it using our PE size 8MB so we will get the physical extend of 50 GB.

51,200 MB / 8 PE = 6,400 PE = 50 GB

So, the total physical extend we are going to reduce is 6,400 PE which is equal to 50 GB. Follow all the steps but resizing FS required only after shrinking the LV.

Unmount the filesystem and force check for file system error

# umount -v /data/
# e2fsck -ff /dev/mapper/vg01_data-lv_data
[root@client1 ~]# e2fsck -ff /dev/mapper/vg01_data-lv_data 
 e2fsck 1.42.9 (28-Dec-2013)
 Pass 1: Checking inodes, blocks, and sizes
 Pass 2: Checking directory structure
 Pass 3: Checking directory connectivity
 Pass 4: Checking reference counts
 Pass 5: Checking group summary information
 /dev/mapper/vg01_data-lv_data: 12/5357568 files (0.0% non-contiguous), 21354958/21405215 blocks
[root@client1 ~]#

Reduce the filesystem using PE

# lvreduce -l -6400 /dev/mapper/vg01_data-lv_data
  • lvreduce – To reduce the logical volume
  • -l reducing lv using physical extend’s
  • -6400 use (-) to reduce the PE
  • /dev/mapper/vg01_data-lv_data logical volume to reduce
# lvreduce -l -6400 /dev/mapper/vg01_data-lv_data
 WARNING: Reducing active logical volume to 99.98 GiB.
   THIS MAY DESTROY YOUR DATA (filesystem etc.)
   Do you really want to reduce vg01_data/lv_data? [y/n]: y
   Size of logical volume vg01_data/lv_data changed from 149.98 GiB (19198 extents) to 99.98 GiB (12798 extents).
   Logical volume vg01_data/lv_data successfully resized.
[root@client1 ~]#

Run the resize command to finalize the reduce.

# resize2fs /dev/mapper/vg01_data-lv_data
[root@client1 ~]# resize2fs /dev/mapper/vg01_data-lv_data 
 resize2fs 1.42.9 (28-Dec-2013)
 Resizing the filesystem on /dev/mapper/vg01_data-lv_data to 26210304 (4k) blocks.
 The filesystem on /dev/mapper/vg01_data-lv_data is now 26210304 blocks long.

Check the size after LV reduce

# lvdisplay /dev/mapper/vg01_data-lv_data
[root@client1 ~]# lvdisplay /dev/mapper/vg01_data-lv_data
   --- Logical volume ---
   LV Path                /dev/vg01_data/lv_data
   LV Name                lv_data
   VG Name                vg01_data
   LV UUID                9Tx1mP-sJTd-TtGu-y0ke-uzDQ-ECKD-CvS6J0
   LV Write Access        read/write
   LV Creation host, time client1.linuxsysadmins.local, 2019-07-17 22:16:06 +0530
   LV Status              available
   # open                 0
   LV Size                99.98 GiB
   Current LE             12798
   Segments               1
   Allocation             inherit
   Read ahead sectors     auto
 currently set to     8192
 Block device           253:2 
[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-a-----  99.98g                                                    
[root@client1 ~]# 

Finally, mount the filesystem and list the same.

# mount /dev/mapper/vg01_data-lv_data /data/
# df -hP
[root@client1 ~]# mount /dev/mapper/vg01_data-lv_data /data/
 [root@client1 ~]# df -hP
 Filesystem                     Size  Used Avail Use% Mounted on
 /dev/mapper/centos-root         17G  1.7G   16G  10% /
 devtmpfs                       412M     0  412M   0% /dev
 tmpfs                          424M     0  424M   0% /dev/shm
 tmpfs                          424M  6.8M  417M   2% /run
 tmpfs                          424M     0  424M   0% /sys/fs/cgroup
 /dev/sda1                     1014M  142M  873M  14% /boot
 tmpfs                           85M     0   85M   0% /run/user/0
 /dev/mapper/vg01_data-lv_data   99G   81G   19G  82% /data
[root@client1 ~]#

That’s it we have completed with reducing a file system using physical Extends (PE). By completing this guide we are good with how to perform an Extend and Reduce of LVM.

Continue reading LVM Series: Shrink a Volume Group in Logical Volume Management (LVM)

Conclusion:

Managing logical volume is a very important topic and required in our day to day sysadmin tasks. Understanding LVM is much required for a good sysadmin. Hope this guide provides you with a brief understanding of Extend and Reduce Logical volume management. Subscribe to our newsletter for more interesting upcoming topics about LVM. Your feedback and questions are most welcome and we are happy to assist you.

8 thoughts on “How to Extend and Reduce LVM Logical Volume in Linux

  1. Hi Babin Sir,

    Thank you for explanation.

    —- 16777216 as shown in MB right ?
    —- How you calculating this, any study link for this you have? If yes. Please share.

    Thank you.

    1. @Mahalakshmi,
      No, we are talking here about Physical Extents (PE). The physical extent in LVM is the blocksize that physical volumes are using. The default physical extent is 4MB but can range from 8kB up to 16GB (using powers of 2). Logical volumes are made up from logical extents having the same size as the physical extents. Moreover, the limit of 65k physical extents applies to LVM1 but not LVM2. There are no such limits in LVM2. In order to know more, please read the man page of ‘vgcreate’, especially the section which talks about the switch ‘–physicalextentsize’.

  2. Nice Article Sir.

    Can you please clear below points.

    what is use of increasing extents. by default its 4mb, sometimes we can increase like 8MB etc.

    Could you please help me to understand this query?

Comments are closed.