Learn, Solve & Master Python, Linux, SQL, ML & DevOps
Extend an LV Using Free Space from the Volume Group (Without Downtime)
Problem Overview
-
A filesystem is running out of space, but the volume group already has unallocated free space.
-
Instead of attaching a new disk or resizing partitions, the goal is to extend the logical volume and grow the filesystem using the available VG space while the system remains online.
Prerequisites
Before starting, make sure the following conditions are met:
-
The system is already using LVM for storage management
-
The volume group contains unused free space
- Backup of the LV for which the storage is increased
Solution
- Identify the logical volume that needs more space and confirm its mount point to ensure the correct LV is being modified.
-
[root@pythonlinuxhub ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 19G 0 part ├─rhel_10-root 253:0 0 17G 0 lvm / └─rhel_10-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 6G 0 disk ├─sdb1 8:17 0 1G 0 part │ └─rhel_10-home 253:2 0 1020M 0 lvm /home └─sdb2 8:18 0 2G 0 part └─rhel_10-data 253:3 0 1G 0 lvm /data sr0 11:0 1 1024M 0 rom [root@pythonlinuxhub ~]# df -h /data Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel_10-data 960M 39M 922M 5% /data
-
- Verify that the volume group has sufficient unused free space available for allocation.
-
[root@pythonlinuxhub ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel_10 lvm2 a-- <19.00g 0 /dev/sdb1 rhel_10 lvm2 a-- 1020.00m 0 /dev/sdb2 rhel_10 lvm2 a-- <2.00g 1020.00m [root@pythonlinuxhub ~]# vgs VG #PV #LV #SN Attr VSize VFree rhel_10 3 4 0 wz--n- <21.99g 1020.00m [root@pythonlinuxhub ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert data rhel_10 -wi-ao---- 1.00g home rhel_10 -wi-ao---- 1020.00m root rhel_10 -wi-ao---- <17.00g swap rhel_10 -wi-ao---- 2.00g
-
- Extend the logical volume using the selected portion of free space from the volume group.
-
[root@pythonlinuxhub ~]# lvextend -l +50%FREE /dev/rhel_10/data Size of logical volume rhel_10/data changed from 1.00 GiB (256 extents) to 1.50 GiB (384 extents). Logical volume rhel_10/data successfully resized.
-
- Grow the filesystem, so it can utilize the newly extended logical volume without downtime.
-
[root@pythonlinuxhub ~]# xfs_growfs /data meta-data=/dev/mapper/rhel_10-data isize=512 agcount=4, agsize=65536 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 bigtime=1 inobtcount=1 nrext64=0 data = bsize=4096 blocks=262144, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=16384, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 262144 to 393216
-
- Validate the change by confirming that the logical volume and filesystem now reflect the increased capacity.
-
[root@pythonlinuxhub ~]# df -h /data Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel_10-data 1.5G 43M 1.4G 3% /data[root@pythonlinuxhub ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel_10 lvm2 a-- <19.00g 0 /dev/sdb1 rhel_10 lvm2 a-- 1020.00m 0 /dev/sdb2 rhel_10 lvm2 a-- <2.00g 508.00m [root@pythonlinuxhub ~]# vgs VG #PV #LV #SN Attr VSize VFree rhel_10 3 4 0 wz--n- <21.99g 508.00m [root@pythonlinuxhub ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert data rhel_10 -wi-ao---- 1.50g home rhel_10 -wi-ao---- 1020.00m root rhel_10 -wi-ao---- <17.00g swap rhel_10 -wi-ao---- 2.00g
-
lvextend -L 1.5G /dev/rhel_10/data # Resizes the logical volume to an exact size of 1.5 GBlvextend -L +500M /dev/rhel_10/data # Adds 500 MB to the current size of the logical volumelvextend -l +50%FREE /dev/rhel_10/data # Extends the logical volume using 50% of the free space available in the volume group
Shaik Mohammed Faruk
Software Engineer sharing practical tutorials and insights on Linux, Python, SQL, and modern technologies.
Read more About Me
0
0
votes
Article Rating
0 Comments
Oldest
Newest
Most Voted
Inline Feedbacks
View all comments
