Expand qemu qcow2 Disk Size

  1. Resize with qemu-img in host:
1
sudo qemu-img resize /var/lib/libvirt/images/fedora-kernel.qcow2 +15G
  1. Check the new size in host:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
[ecomaikgolf@laptop ~/]$ sudo qemu-img info /var/lib/libvirt/images/fedora-kernel.qcow2
image: /var/lib/libvirt/images/fedora-kernel.qcow2
file format: qcow2
virtual size: 35 GiB (37580963840 bytes)
disk size: 15.1 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: true
    refcount bits: 16
    corrupt: false
    extended l2: false
Child node '/file':
    filename: /var/lib/libvirt/images/fedora-kernel.qcow2
    protocol type: file
    file length: 20 GiB (21478506496 bytes)
    disk size: 15.1 GiB
  1. (LVM) Resize from guest:

  1. (LVM) Resize LVM partition:
1
sudo pvresize /dev/vda3
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
[6.7.4-200.fc39.x86_64 ~/]$ sudo pvdisplay         
  --- Physical volume ---
  PV Name               /dev/vda3
  VG Name               fedora
  PV Size               <34.00 GiB / not usable 16.50 KiB <-- NEW SIZE
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              8703
  Free PE               3840
  Allocated PE          4863
  PV UUID               Njz9OK-9e0P-Owt3-hEB6-bSNc-S4gz-OhaErD
1
sudo lvextend -l +100%FREE /dev/fedora/root
1
2
3
[6.7.4-200.fc39.x86_64 ~/]$ sudo lvs
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root fedora -wi-ao---- <34.00g <-- NEW SIZE
1
2
3
4
5
6
7
8
[6.7.4-200.fc39.x86_64 ~/]$ sudo lsblk
NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
zram0           251:0    0  1.9G  0 disk [SWAP]
vda             252:0    0   35G  0 disk 
|-vda1          252:1    0    1M  0 part 
|-vda2          252:2    0    1G  0 part /boot
`-vda3          252:3    0   34G  0 part 
  `-fedora-root 253:0    0   34G  0 lvm  / <-- NEW SIZE
  1. “Enlarge FS size”
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
[6.7.4-200.fc39.x86_64 ~/]$ sudo xfs_growfs /dev/fedora/root 
meta-data=/dev/mapper/fedora-root isize=512    agcount=4, agsize=983040 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=3932160, 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 3932160 to 8911872