[SOLVED] Configuring Thin Provision - DIR/QCOW2

HeyRob

Member
Mar 21, 2018
9
0
6
44
Hello,

I am interested in enabling thin-provisioning for a drive that is mounted using a directory-backend. I understand that snapshots/thin-provisioning are supported because of QCOW2, but do not see how to set the option for either the drive or while provisioning a drive to a VM. This is what I have in my storage.cfg now for the relevant drive:

dir: SSD1TBSANDISK
path /mnt/pve/SSD1TBSANDISK
content backup,images,rootdir,snippets,iso,vztmpl
is_mountpoint 1
nodes zeus1

I do see guidance on setting up thin-provioning for ZFS drives by adding 'sparse' to storage.cfg, but nothing below on how to do this for DIR storage.

https://pve.proxmox.com/pve-docs/pvesm.1.html

Any help would be greatly appreciated!
 
Hi,
you don't have to do anything if you use qcow2. Even though a qcow2 image looks bigger with ls for example, it doesn't really use the space:
Code:
root@pve /mnt/myfs/images/162 # ls -lh
total 1.7G
-r--r--r-- 1 root root 4.1G Nov  3 08:41 base-162-disk-0.qcow2
root@pve /mnt/myfs/images/162 # du -h
1.7G    .
root@pve /mnt/myfs/images/162 # qemu-img info base-162-disk-0.qcow2
image: base-162-disk-0.qcow2
file format: qcow2
virtual size: 4 GiB (4294967296 bytes)
disk size: 1.67 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    compression type: zlib
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
 
Thank you for the response! Unfortunately, that is not the case for my qcow2 disks:


Code:
root@zeus1:/mnt/pve/SSD1TBSANDISK/images/102# qemu-img info  vm-102-disk-0.qcow2
image: vm-102-disk-0.qcow2
file format: qcow2
virtual size: 40 GiB (42949672960 bytes)
disk size: 40 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
root@zeus1:/mnt/pve/SSD1TBSANDISK/images/102#

Any thoughts as to why that’s happening?
 
Last edited:
Well, how much space was/is your VM using? To reclaim space it was using in the past (and also space being freed up in the future), you need to enable the discard option on the drive (can be done in the Hardware view in the GUI) and trim the filesystem(s) within the VM. See here for more information.
 
Last edited:
  • Like
Reactions: HeyRob
That was it! Not sure how I missed that. Thank you so much!

Code:
virtual size: 40 GiB (42949672960 bytes)
disk size: 30 GiB
cluster_size: 65536
Format specific information:
    compat: 1.1
    lazy refcounts: false
    refcount bits: 16
    corrupt: false
 

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!