How to compress a virtual machine disk?

B@ktery

New Member
Feb 16, 2019
18
0
1
35
I need to reduce the size of the virtual disk VM. Turned off VM, booted from GParted, and changed the size of the volume. But when booted VM, in disk management saw (unallocated area).
I do on this documentation
http://c-nergy.be/blog/?p=1323
But in my directory /var/lib/vz/images is empty
How do i remove it ? i'm using version Proxmox 5.3-8
 
Storage lvm

In that case, you can follow the guide and use fstrim assuming you have a scsi controller selected and have discard turned on. That will trim the thin volume.

However, if you want to shrink how much is allocated and the actual size of the partition.

Then you will want to do a command such as the following

lvreduce -L -<X>G /dev/vg/<X>

However, this assumes you have already resized the file system inside and the host is good. As always, please don't take my word for this, make sure you understand the commands and have a valid backup in case things go wrong.

Thanks,
Derek
 
Keep in mind that thin-LVM has very large extends in comparison to the normal blocksize of a guest of 4K, so that just trimming is not enough. You should also use defrag to compact the space between deleted blocks.

Compression of virtual disks is only technically possible by virtualized storage like QCOW2 (probably also vhd, vmware etc.) and ZFS.
 
That is, it turns out that I can not compress the virtual disk on the LVM section? I will actually cut it, it will be visible from the virtual machine, but the volume of the disk will not change on the LVM?
 

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!