Skip to content

Managing Thin-Provisioned VM Disks in Proxmox

In our day-to-day system administration work, we often encounter challenges that are worth sharing with the broader community. One recent issue involved our servers running out of disk space. Our Admiral Platform system admins resolved the issue using the fstrim utility—a solution that may help others facing similar problems.

What Is Thin Provisioning?

Thin provisioning is a concept wherein a VM disk only takes up as much space as the guest operating system is using. So, you can present your virtual machine with 200GB of available storage, but the disk might actually be as little as 32GB.

Thin Provisioning Across Virtualization Platforms

There are many different ways to create thinly provisioned disks on many different virtualization platforms. For example, you can “sparsify” qcow2 disks, create thin VMDK disks, create thin LVM pools, etc. This blog post will focus particularly on LVM thin pools on Proxmox, but the concept applies everywhere thinly provisioned disks may be used.

It’s important to understand that you can sink your own ship by over-provisioning thin disks. If your host operating system only has 200GB but you create 5 VMs with 50GB disks, then all the disks hitting 40GB would cause the VMs to fail disk operations, leading to your VMs crashing.

Cleaning Up with fstrim

In Linux, there’s a useful utility, `fstrim` that allows you to clean up and discard unused blocks. Regardless of if you’re using qcow2 disks, VMDK disks, or any manner of thin provisioning, you can use `fstrim` to clean up unused file system blocks. On other platforms, such as Windows, there’s likely other utilities to do this.

Before “trimming” your file system, you ought to make sure that your virtualization platform can actually interpret and act upon discard requests. In Proxmox, this means ensuring that the “Discard” config option is enabled for your VM’s disk.

This can be especially useful for VMs with high IO workloads that might write a bunch of data that doesn’t end up being deleted. For example, relational databases with a bunch of block files, Log-Structured Merge tree databases with high compaction rates, or storage servers can all benefit from making sure the disk is trimmed and your virtualization platform can actually free up discarded data.

For platforms that use qcow2 disks, you can also sparsify a disk using `virt-sparsify`:

The Caveat: SSD Wear and Tear

There is a caveat to doing these trims: they can exhaust an SSD’s lifetime. However, an occasional trim should be okay to keep storage usage down.

Proactive Maintenance

Managing thin-provisioned disks in Proxmox isn’t just about saving storage—it’s about ensuring reliability and preventing unexpected downtime. By making use of tools like fstrim or virt-sparsify, you can keep your VMs running efficiently while avoiding the pitfalls of over-provisioning. With a little proactive maintenance, thin provisioning can remain a powerful tool in your virtualization toolkit without becoming a hidden risk.

Follow us on socials for more guides and MikroTik related content.

Back To Top