Remove unallocated space

bulletforyou11

New Member
Aug 5, 2020
2
0
1
29
There is a proxmox node that has storage /media/storage2 which used by two virtual machines. Images VM101 and VM103. Too much space was accidentally expanded on vm 101. How now to delete this unallocated space on the virtual machine with the OS Windows and free up space in the storage of nodes without losing data.
Is it possible to use the command:
Code:
qemu-img resize /media/storage2/images/101/vm-101-disk-0.raw -299G
and will it make it worse?

proxmox 6.1-5
 

Attachments

  • photoeditorsdk-export (1).png
    photoeditorsdk-export (1).png
    119.1 KB · Views: 64
qemu-img resize --shrink /media/storage2/images/101/vm-101-disk-0.raw -299G would be the command to do so. Yes, that should be safe, as Windows will not store any data in the unallocated regions. If you want to be really sure you could waste a gigabyte and only shrink by 298, but if you simply increased by 299 and want to go back, that should not pose any issue.

*Really* make sure there is no data in the last 299 GB of space in that image though, after that command it will be irreversibly truncated.
 
qemu-img resize --shrink /media/storage2/images/101/vm-101-disk-0.raw -299G would be the command to do so. Yes, that should be safe, as Windows will not store any data in the unallocated regions. If you want to be really sure you could waste a gigabyte and only shrink by 298, but if you simply increased by 299 and want to go back, that should not pose any issue.

*Really* make sure there is no data in the last 299 GB of space in that image though, after that command it will be irreversibly truncated.
Should the VM be turned off before doing this? Is the command line a standard? or should I check my disk path. I can't seem to set the right path.
local-lvm:vm-102-disk-0. this is listed in my hardware summary.
 
Should the VM be turned off before doing this? Is the command line a standard? or should I check my disk path. I can't seem to set the right path.
local-lvm:vm-102-disk-0. this is listed in my hardware summary.
Yes, it has to be turned off, otherwise there's a very high risk of data loss or corruption.

The 'qemu-img' method I noted only works for qcow2 images, you seem to be working with an LVM-thin storage. You have to use LVM commands to shrink the allocation then, check your LV with 'lvs -a' and go from there. Again, make sure nothing is allocated at the end of the disk within the VM, otherwise it will be lost upon shrinking.