Resizing a VM HDD

Mar 10, 2017
31
1
28
Ohio
primeserversinc.com
Hello,

I accidentally over-Resized a VMs HDD to 1250G, when I only wanted to make it 750G. The VM hasn't been powered on since the resize, and when I run the resize command I've come across, I am getting an error:
root@vm2:/dev# qm resize 107 ide0 750G
unable to shrink disk size

Any Suggestions on the proper way to do this? This is a customer's VM, so the data Must survive.
 
Make a new disk with 750g, transfer the disk/data, remove old disk.I would recommend to do a block copy not avoid touching anything in your customers vm. This involve some downtime.
 
You can only shrink raw files.

Backup by copying the disk (if you have space...)
Make sure your OS partition is not any larger than the size you're shrinking to. In your case it shouldn't be.

If you use qcow2, first you have to convert:

qemu-img convert vm-100.qcow2 vm-100.raw

Then shrink:

qemu-img resize -f raw vm-100.raw 10G

Then convert back:

qemu-img convert -p -O qcow2 vm-100.raw vm-100.qcow2

Then edit the vm config file at /etc/pve/qemu-server/100.conf to change the size to what you set it to, so it shows up on the GUI properly.

LINKS:
See also this method for a shrinking command.
Wiki article, but does not mention shrinking, unfortunately.
This post shows what needs to be done if you're completely changing the hard disk format. Maybe it also updates the size automatically? I never got a change to test it.