How to shrink/decrease qcow2 size of VM in PVE 4.1?

fintnovo

New Member
Jan 4, 2014
23
0
1
Good day, everyone. I have VM under PVE 4.1 with 100Gb virtual disk qcow2. Real data usage of guest machine - 10 Gb. I'd like to shrink/decrease size of virtual drive from 100Gb to 20Gb. With Resize Disk command I can only increase virtual drive size. Is any simple way to shrink/decrease virtual drive?
 

fintnovo

New Member
Jan 4, 2014
23
0
1
I did following:
stop virtual machine:
qm stop 100
convert the image from qcow2 to raw:
qemu-img convert vm-100-disk-1.qcow2 vm-100-disk-1.raw
then shrink the image the 20G are the new total size:
qemu-img resize -f raw vm-100-disk-1.raw 20G
then convert it back:
qemu-img convert vm-100-disk-1.raw vm-100-disk-1.qcow2
then erase the old .raw image
rm vm-100-disk-1.raw
then edit the "/etc/pve/qemu-server/100.conf" file and change
the the size of the disk to 20G

But when I try to start VM it didn't:
Image is not in qcow2 format.
 

fintnovo

New Member
Jan 4, 2014
23
0
1
Convert again from raw to qcow2 (with -O option):
qemu-img convert -O qcow2 vm-100-disk-1.raw vm-100-disk-1.qcow2
and VM start :) !
But, guest machine under Linux Ubuntu 14.04 didn't start normally:
111.png
something wrong with file system after converting?
 

fintnovo

New Member
Jan 4, 2014
23
0
1
Before using this command to shrink a disk image, you must use file system and partitioning tools inside the VM itself to reduce allocated file systems and partition sizes accordingly. Failure to do so will result in data loss.
After using this command to grow a disk image, you must use file system and partitioning tools inside the VM to actually begin using the new space on the device.

Any ideas how to solve?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE and Proxmox Mail Gateway. We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get your own in 60 seconds.

Buy now!