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 a Logical Volume on CentOS
7.
[root@slave-dns
~]# cat /etc/redhat-release
CentOS
Linux release 7.9.2009 (Core)
[root@slave-dns
~]#
|
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@slave-dns
~]# vgs
VG
#PV #LV #SN Attr VSize VFree
centos 3
2 0 wz--n- <24.99g <8.00g
[root@slave-dns
~]#
|
8GB unallocated space
left the Volume Group centos.
Step2. Extend Logical Volume: Run the below lvextend command to extend logical
volume:
[root@slave-dns
~]# lvextend -L +5G /dev/mapper/centos-root
Size of logical volume centos/root changed
from 15.99 GiB (4094 extents) to 20.99 GiB (5374 extents).
Logical volume centos/root
successfully resized.
[root@slave-dns
~]#
|
Step 3. Resize Logical Volume: Run the below command to check the file system type
and resize file system size accordingly:
[root@slave-dns
~]# df -hT /
Filesystem Type Size
Used Avail Use% Mounted on
/dev/mapper/centos-root
xfs 16G 1.6G
15G 10% /
[root@slave-dns
~]#
|
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
7 run the below command to resize/extend the file system:
[root@slave-dns
~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root
isize=512 agcount=8, agsize=524032
blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=4192256, 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 4192256 to 5502976
[root@slave-dns
~]#
|
Step 4. Verify the Extended Logical Volume: Run the following command to validate the extended
size of logical volume:
[root@slave-dns
~]# df -hT /
Filesystem Type Size
Used Avail Use% Mounted on
/dev/mapper/centos-root
xfs 21G 1.6G
20G 8% /
[root@slave-dns
~]#
|
Done!!! Now
the / file system/logical volume space is extended from 16 GB to 21 GB.
No comments:
Post a Comment