How do I get sparse VM disks with NFS?

Jago

Member
May 9, 2019
9
1
23
41
I've recently finished migrating my VMs from an old Proxmox 6 host to a new one running fully updated Proxmox 7. I got myself a NAS serving NFS that I used to create the backups with the idea to later also use it for some VM disks that do not require high responsiveness of local nvme drives.

I restored some of my VMs from NFS to the new server's local storage and everything worked great. I restored one of the VMs placing its disk to NFS storage and immediately noticed it took the entire 128gb worth of space instead of the 25gb or so worth of data the disk is holding. I looked around and noticed the restored VM was using a raw disk on NFS and remembered reading that sparse disks sometimes requires qcow, so I did a disk move from NFS to NFS changing the disk format in the process. Nope, still full 128gb in use.

Did more testing: creating new VMs to local ZFS NVME storage creates sparse disks. Creating new VMs to NFS storage creates thick provisioned drives that immediately utilise their max potential size.

What gives and how do I get sparse to work over NFS?
 
Last edited:
Managed to solve this due to a helpful answer on Reddit:

Had top open Storage settings, double click the NFS hosting VM disks and change Pre-allocation from Default to Off. Now migrating a pre-existing VM disk to RAW and back to QCOW2 resulted in a 28gb of space use on NFS instead of 128GB and creating a brand new VM with a 32gb disk results in a 192kb disk file upon finishing the creation of a VM.

Curious side-details:
  1. I have 2 NFS shares enabled in Proxmox - one purely for backups and another for disk image + iso image. I can change the preallocation setting on my disk+iso share, but on the backup share the option is greyed out.

  2. Setting Preallocation=Metadata seems to have same effect as Default, meaning the disk is FULLY pre-allocated for some reason and not just actual data + full disk metadata which should be way less than the full disk worth of space use. Possible bug?

  3. Moving a pre-existing VM disk from local ZFS storage to NFS (with Preallocation=Off) still results in full disk space being consumed on NFS target, even if you chose QCOW disk format. But once the disk is on NFS, if you go through a QCOW-›RAW-›QCOW conversion, the end result will be a sparse disk that saves you space.
 
Last edited:

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!