0

This is what my guest looked like enter image description here

i shrinked the C partion in the guest in the windows 10 guest , made sure that the unallocated space is on the right most side.

then, i did this sudo qemu-img resize --shrink ../kvm_storage/win10.qcow2 62G and it made the kvm guest unbootable.

Fortunately i had an old snapshot and i was able to restore it. Please let me know how can i reduce the size of kvm disk from 100GB to a smaller size 62 GB safely.

munish
  • 151
  • 1
  • 11

1 Answers1

0

You have to delete (or move, which is a whole new rabbithole) the recovery partition (its not necessary in a VM where you have snapshots anyways) or else booting becomes impossible, because the partition table would no longer match the disk layout (since you'll cut off space from the right side).

You should shrink the windows partition to quite a bit less than 62G (maybe even 50G), then shrink the qcow2 disk to 62G, then increase the windows partition again to fill the disk.

As long as you don't have anything fancy like encryption on the disk, you should be able to do this safely.

Edit: actually one more thing: that "System Reserved" Partition. I cannot deduce from the screenshot where it resides. If it resides at the right end of the disk you are trying to shrink, you're out of luck. I think a reinstall would be the simplest option then...

John Smith
  • 111
  • 2
  • yes, it was at the end but i move it to the left with aomei partition manager after that there was only unallocated space of around 38 GB on the right most side – munish Jul 05 '22 at 15:03
  • If after moving around the partitions, the system could still boot, resizing should not be a problem. I have my doubts, that it can still boot though (even before shrinking the qcow), since system reserved is usually the EFI boot partition. And moving that one around is quite tricky... In fact moving partitions around is quite tricky period... Maybe you should make a new qcow, reinstall windows with the partition layout you want, and then simply restore the the contents of only the C partition. – John Smith Jul 12 '22 at 09:53