Shrinked qcow2 disks won't boot

Elias137

Member
Jan 19, 2022
11
2
8
44
Hi!

I have qcow2 disk file which I've converted from vmdk disk file. There's Windows 2016 Server in there with UEFI partition which I made out of a live system following your howto (VMWare converter etc). It works just fine, no issues at all. But my goal is not just import the disk into my local-lvm, but to reduce its size. As far as I know, there's no way to shrink local-lvm disks, correct? So I had to shrink qcow2 disk file with 'emu-img resize --shrink file.qcow2 128G' (it was smth about 200G before). Disk shrinking went fine with no errors, but it won't boot! This one particular unshrinked disk imported in local-lvm boots just fine, but it won't boot once shrinked! Can you please shed some light on what I might be doing wrong?

UPD: The VM has finally booted up after approx 15 mins or so, but it's almost unusable. It's extremely slow, I can't even enter my credentials at user logon screen. I rebooted the VM, but it has no effect. Unshrinked disk doesn't have these issues.

UPD2: lvreduce of VM's disk has the same effect - VM won't boot after reducing its size.
 
Last edited:
Hi,
you can't just shrink a disk when the guest OS/partition table expects it to be a certain size. Also, quoting man qemu-img:
Code:
When shrinking images, the --shrink option must be given. This informs qemu-img that the user acknowledges all loss of data beyond the truncated image's end.
 
Hi,
you can't just shrink a disk when the guest OS/partition table expects it to be a certain size. Also, quoting man qemu-img:
Code:
When shrinking images, the --shrink option must be given. This informs qemu-img that the user acknowledges all loss of data beyond the truncated image's end.

Is that VM's only related? As I do can shrink disk of a physical OS (for example, using gparted of a Linux live CD), and it boots just fine!

Of course I did qemu-img --shrink as I'm absolutely sure it won't affect data. I just wanted to make disk smaller. Like, my VM's disk is something about 200G, while the data stored on it is only about 100G. So I shrinked the VM's disk to 128G and It should have been absolutely correct if it was a physical machine.

If I'm totally wrong on the whole thing, can you please tell me how to make VM's disk smaller in size?
 
Last edited:
Is that VM's only related? As I do can shrink disk of a physical OS (for example, using gparted of a Linux live CD), and it boots just fine!
With gparted you do change the partition table.

Of course I did qemu-img --shrink as I'm absolutely sure it won't affect data. I just wanted to make disk smaller. Like, my VM's disk is something about 200G, while the data stored on it is only about 100G. So I shrinked the VM's disk to 128G and It should have been absolutely correct if it was a physical machine.
With qemu-img you change the actual size of the virtual disk. What if the data is stored at towards the end of the disk?

If I'm totally wrong on the whole thing, can you please tell me how to make VM's disk smaller in size?
You need to change the partition table/resize file systems to make sure space towards the end of the disk is actually unused. Only after that, using qemu-img is fine.
 
You need to change the partition table/resize file systems to make sure space towards the end of the disk is actually unused. Only after that, using qemu-img is fine.
How do I do that on Windows guest? If I resize the partition size with, for example, gparted, will that be correct? I would resize it to 128G, so the unused space will remain. Then I'll do qemu-img --shrink on it, right?
 
Unfortunately I've never done it on Windows, so I don't know if gparted supports doing it correctly. I'm sure there are tutorials out there, but when in doubt always create a backup first ;)
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, 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 yours easily in our online shop.

Buy now!