Bootstrap FreeKB - LVM (Logical Volume Manager) - Increase size of an LVM Logical Volume using the lvextend command
LVM (Logical Volume Manager) - Increase size of an LVM Logical Volume using the lvextend command


This assumes you are familiar with LVM (Logical Volume Manager). If not, check out my article Getting Started with LVM (Logical Volume Manager).

Let's say the /var directory is associated with the LVM Logical Volume named lv_var and you want to increase /var by 1 GB.

[root@server1 ~]# df -h
Filesystem                                 Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-lv_var                  8.0G  4.4G  3.7G  55% /var

 

In this example, the lvdisplay command is used to show that /dev/rootvg/lv_var is 8.00 GiB.

~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/rootvg/lv_var
  LV Name                lv_var
  VG Name                rootvg
  LV UUID                kI5KSn-KGz8-ttcU-LwSS-MO4Q-gJiS-cY55aO
  LV Write Access        read/write
  LV Creation host, time server1, 2020-09-15 13:55:08 -0500
  LV Status              available
  # open                 1
  LV Size                8.00 GiB
  Current LE             5120
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:6

 

In order to add 1 GB to the Logical Volume, the Volume Group must have 1 GB or more free. Notice in this example that the Logical Volume is associated with the Volume Group named rootvg. The vgdisplay command can be used to show how much free space is available in the Volume Group. In this example, the rootvg Volume Group has plenty of Free PE / Size.

[root@server1 ~]# vgdisplay rootvg
  --- Volume group ---
  VG Name               rootvg
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  16
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                7
  Open LV               7
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               54.99 GiB
  PE Size               4.00 MiB
  Total PE              14078
  Alloc PE / Size       10493 / <40.99 GiB
  Free  PE / Size       3585 / 14.00 GiB
  VG UUID               lXTHOm-BAff-igYk-5H3m-HL0J-77vt-ecphq0

 

The lvextend command can be used to increase the size of the Logical Volume.

[root@DLOCPLJ-1-0001 ~]# lvextend --size +1G /dev/rootvg/lv_var
  Size of logical volume rootvg/lv_var changed from 8.00 GiB (2048 extents) to 9.00 GiB (2304 extents).
  Logical volume rootvg/lv_var successfully resized.

 

But, this does not increase the size of the /var partition. 

[root@server1 ~]# df -h
Filesystem                                 Size  Used Avail Use% Mounted on
/dev/mapper/rootvg-lv_var                  8.0G  4.4G  3.7G  55% /var

 

If the Logical Volume is using the XFS file system.

[root@server1 ~]# cat /etc/fstab
/dev/mapper/rootvg-lv_var /var                    xfs     defaults        0 0

 

You can then use the xfs_growfs command to increase the size of the file system.

[root@server1 ~]# xfs_growfs /dev/rootvg/lv_var
meta-data=/dev/mapper/rootvg-lv_var isize=512    agcount=6, agsize=393216 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=2097152, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2097152 to 2359296

 

Which in this example should get /var increased from 8 GB to 9 GB.

[root@server1 ~]# df -h
/dev/mapper/rootvg-lv_var                  9.0G  4.4G  4.7G  49% /var

 




Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee



Comments


Add a Comment


Please enter c248d6 in the box below so that we can be sure you are a human.