KVM espandere file immagine qcow2 con qemu

Come aumentare lo spazio in una macchina virtuale con KVM come hipervisor

Fermare la vm

Informazioni file:

#sudo qemu-img info nomefile.qcow2

image: nomefile.qcow2
file format: qcow2
virtual size: 200G (214748364800 bytes)
disk size: 516G
cluster_size: 65536
Snapshot list:
ID TAG VM SIZE DATE VM CLOCK
5 31052019 24G 2019-05-31 23:18:31 310:28:48.471
6 080220 24G 2020-02-08 22:57:40 6383:00:38.012
Format specific information:
compat: 1.1
lazy refcounts: true
refcount bits: 16
corrupt: false

Per eseguire questa operazione non devono essere presenti snapshot

Eliminare snapshot se presenti:
#sudo qemu-img snapshot -d 5 nomefile.qcow2
#sudo qemu-img snapshot -d 6 nomefile.qcow2

Ridimensionare il file immagine come necessario, in questo caso + 50GB:
sudo qemu-img resize nomefile.qcow2 +50G

al termine verificare le dimensioni:
#sudo qemu-img info nomefile.qcow2

image: nomefile.qcow2
file format: qcow2
virtual size: 250G (268435456000 bytes)
disk size: 230G
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: true
refcount bits: 16
corrupt: false

Riavviare la vm

MenuOver