Tuesday 8 February 2022

How to Extend Logical Volume on CentOS 8



Sometime encountered with no space left on file system error and demand opened to increase file system space. It would be easy if file system is created under LVM.
 
This article describes How to Extend Logical Volume on CentOS 8
 
[root@linuxcnf ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
[root@linuxcnf ~]#
 
Step 1. View the Free Space in Volume Group: Run the below vgs command to make sure free space is available in the Volume Group:
 
[root@linuxcnf ~]# vgs
  VG #PV #LV #SN Attr   VSize  VFree
  cl   2   2   0 wz--n- 16.99g <8.00g
[root@linuxcnf ~]#
 
8GB unallocated space left the Volume Group cl.
 
Step2. Extend Logical Volume: Run the below lvextend command to extend logical volume:
 
[root@linuxcnf ~]# lvextend -L +6G /dev/mapper/cl-root
  Size of logical volume cl/root changed from <8.00 GiB (2047 extents) to <14.00 GiB (3583 extents).
  Logical volume cl/root successfully resized.
[root@linuxcnf ~]#
 
Step 3. Resize Logical Volume: Run the below command to check the file system type and resize file system size accordingly:
 
[root@linuxcnf ~]# df -hT /
Filesystem          Type  Size  Used Avail Use% Mounted on
/dev/mapper/cl-root xfs   8.0G  1.9G  6.2G  23% /
[root@linuxcnf ~]#
 
Check the file system type as above if file system type if ext2/ext3/ext4, run resize2fs command or if it is xfs file system as it is default file system type in CentOS 8 run the below command to resize/extend the file system:
 
[root@linuxcnf ~]# xfs_growfs /dev/mapper/cl-root
meta-data=/dev/mapper/cl-root    isize=512    agcount=4, agsize=524032 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1
data     =                       bsize=4096   blocks=2096128, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           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 2096128 to 3668992
[root@linuxcnf ~]#
 
Step 4. Verify the Extended Logical Volume: Run the following command to validate the extended size of logical volume:
 
[root@linuxcnf ~]# df -h /
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/cl-root   14G  1.9G   13G  14% /
[root@linuxcnf ~]#
 
Done!!! Now the / file system/logical volume space is extended from 8 GB to 16 GB.

No comments:

Post a Comment