- On host, resize the disk:
# qemu-img resize /var/lib/libvirt/images/RHEL-9.4.0-20231102.19-x86_64-ovmf.qcow2 +20G
- Login vm, check there is unpartitioned capacity, create a new partition vda4 with 20G:
[root@localhost ~]# df -lh
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 847M 0 847M 0% /dev/shm
tmpfs 339M 9.2M 330M 3% /run
/dev/mapper/rhel-root 7.4G 4.3G 3.1G 58% /
/dev/vda2 960M 215M 746M 23% /boot
/dev/vda1 599M 7.0M 592M 2% /boot/efi
tmpfs 170M 0 170M 0% /run/user/0
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
vda 252:0 0 30G 0 disk
├─vda1 252:1 0 600M 0 part /boot/efi
├─vda2 252:2 0 1G 0 part /boot
└─vda3 252:3 0 8.4G 0 part
├─rhel-root 253:0 0 7.4G 0 lvm /
└─rhel-swap 253:1 0 1G 0 lvm [SWAP]
[root@localhost ~]# fdisk /dev/vda
Welcome to fdisk (util-linux 2.37.4).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
GPT PMBR size mismatch (20971519 != 62914559) will be corrected by write.
The backup GPT table is not on the end of the device. This problem will be corrected by write.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.
Command (m for help): n
Partition number (4-128, default 4):
First sector (20969472-62914526, default 20969472):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (20969472-62914526, default 62914526):
Created a new partition 4 of type 'Linux filesystem' and of size 20 GiB.
Command (m for help): w
The partition table has been altered.
Syncing disks.
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS
vda 252:0 0 30G 0 disk
├─vda1 252:1 0 600M 0 part /boot/efi
├─vda2 252:2 0 1G 0 part /boot
├─vda3 252:3 0 8.4G 0 part
│ ├─rhel-root 253:0 0 7.4G 0 lvm /
│ └─rhel-swap 253:1 0 1G 0 lvm [SWAP]
└─vda4 252:4 0 20G 0 part
- Create PV, then VG, then LV, refer to https://networklessons.com/uncategorized/extend-lvm-partition
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/vda3
VG Name rhel
PV Size 8.41 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 2153
Free PE 0
Allocated PE 2153
PV UUID tF71r2-cro2-nn16-ihfo-8HfA-EZAv-g4f4Vf
[root@localhost ~]# pvcreate /dev/vda4
Physical volume "/dev/vda4" successfully created.
Not creating system devices file due to existing VGs.
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/vda3
VG Name rhel
PV Size 8.41 GiB / not usable 2.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 2153
Free PE 0
Allocated PE 2153
PV UUID tF71r2-cro2-nn16-ihfo-8HfA-EZAv-g4f4Vf
"/dev/vda4" is a new physical volume of "20.00 GiB"
--- NEW Physical volume ---
PV Name /dev/vda4
VG Name
PV Size 20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID zVl2Uz-cY3b-75SK-XFL7-8TTL-AcLS-hbsLm5
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name rhel
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 8.41 GiB
PE Size 4.00 MiB
Total PE 2153
Alloc PE / Size 2153 / 8.41 GiB
Free PE / Size 0 / 0
VG UUID tzFcA2-Avm1-LIMr-4xVm-34lA-BY1i-baWfs7
[root@localhost ~]# vgextend rhel /dev/vda4
Volume group "rhel" successfully extended
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name rhel
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 6
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size <28.41 GiB
PE Size 4.00 MiB
Total PE 7272
Alloc PE / Size 2153 / 8.41 GiB
Free PE / Size 5119 / <20.00 GiB
VG UUID tzFcA2-Avm1-LIMr-4xVm-34lA-BY1i-baWfs7
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/rhel/swap
LV Name swap
VG Name rhel
LV UUID VpDNuo-1oLS-kAKi-ZYJS-zfHz-Ui2L-w4S63O
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2023-11-02 14:39:41 +0800
LV Status available
# open 2
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/rhel/root
LV Name root
VG Name rhel
LV UUID 89o66j-XHnR-eQpt-RPIP-F7XW-1WLS-df05Iu
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2023-11-02 14:39:41 +0800
LV Status available
# open 1
LV Size 7.41 GiB
Current LE 1897
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
[root@localhost ~]# lvextend -l +100%FREE /dev/rhel/root
Size of logical volume rhel/root changed from 7.41 GiB (1897 extents) to <27.41 GiB (7016 extents).
Logical volume rhel/root successfully resized.
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Path /dev/rhel/swap
LV Name swap
VG Name rhel
LV UUID VpDNuo-1oLS-kAKi-ZYJS-zfHz-Ui2L-w4S63O
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2023-11-02 14:39:41 +0800
LV Status available
# open 2
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
--- Logical volume ---
LV Path /dev/rhel/root
LV Name root
VG Name rhel
LV UUID 89o66j-XHnR-eQpt-RPIP-F7XW-1WLS-df05Iu
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2023-11-02 14:39:41 +0800
LV Status available
# open 1
LV Size <27.41 GiB
Current LE 7016
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
- Resize the filesystem
[root@localhost ~]# df -lh
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 847M 0 847M 0% /dev/shm
tmpfs 339M 9.2M 330M 3% /run
/dev/mapper/rhel-root 7.4G 4.3G 3.1G 58% /
/dev/vda2 960M 215M 746M 23% /boot
/dev/vda1 599M 7.0M 592M 2% /boot/efi
tmpfs 170M 0 170M 0% /run/user/0
[root@localhost ~]# xfs_growfs /dev/rhel/root
meta-data=/dev/mapper/rhel-root isize=512 agcount=4, agsize=485632 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=1942528, 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 1942528 to 7184384
[root@localhost ~]# df -lh
Filesystem Size Used Avail Use% Mounted on
devtmpfs 4.0M 0 4.0M 0% /dev
tmpfs 847M 0 847M 0% /dev/shm
tmpfs 339M 9.2M 330M 3% /run
/dev/mapper/rhel-root 28G 4.4G 23G 17% /
/dev/vda2 960M 215M 746M 23% /boot
/dev/vda1 599M 7.0M 592M 2% /boot/efi
tmpfs 170M 0 170M 0% /run/user/0
In short, here are the steps to extend the size of your logical volume:
- Create a new partition on hard disk.
- Add the partition you just created as a physical volume.
- Add the new physical volume to the volume group.
- Assign space from the volume group to the logical volume.
- Resize the filesystem.