Scenario: You have a VM and you’ve increased the disk size in the hypervisor and want to extend the LVM and partition in the guest.
LVM is the last partition so we can grow it versus creating a new partition and adding it to the VolGroup:
(parted) p
Model: Xen Virtual Block Device (xvd)
Disk /dev/xvda: 335544320s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 2048s 2099199s 2097152s primary xfs boot
2 2099200s 167772159s 165672960s primary lvm
The easiest way to extend this is via the growpart tool, found in the cloud-utils-growpart
package in AppStream
dnf install cloud-utils-growpart
Last metadata expiration check: 3:13:02 ago on Fri 25 Oct 2024 04:47:25 AM MST.
Dependencies resolved.
==============================================================================
Package Architecture Version Repository Size
==============================================================================
Installing:
cloud-utils-growpart noarch 0.33-0.el8 appstream 35 k
Transaction Summary
==============================================================================
Install 1 Package
Total download size: 35 k
Installed size: 75 k
Is this ok [y/N]: y
Downloading Packages:
cloud-utils-growpart-0.33-0.el8.noarch.rpm 78 kB/s | 35 kB 00:00
------------------------------------------------------------------------------
Total 47 kB/s | 35 kB 00:00
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Installing : cloud-utils-growpart-0.33-0.el8.noarch 1/1
Running scriptlet: cloud-utils-growpart-0.33-0.el8.noarch 1/1
Verifying : cloud-utils-growpart-0.33-0.el8.noarch 1/1
Installed:
cloud-utils-growpart-0.33-0.el8.noarch
Complete!
Now extend partition #2 with the tool:
growpart /dev/xvda 2
CHANGED: partition=2 start=2099200 old: size=165672960 end=167772159 new: size=333445087 end=335544286
That’s it, the partition is now extended, next up, extend the LV:
lvextend -l +100%FREE /dev/mapper/rl-root
Size of logical volume rl/root changed from <71.12 GiB (18206 extents) to <151.12 GiB (38686 extents).
Logical volume rl/root successfully resized.
Finally grow the XFS file system via xfs_growfs
xfs_growfs /
meta-data=/dev/mapper/rl-root isize=512 agcount=4, agsize=4660736 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=18642944, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=9103, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 18642944 to 39614464