qcow2 using zstd compression

damo2929

Member
Mar 15, 2022
106
15
23
44
Hi all

how can I alter the configuration so that the qcow2 format disk images use zstd format rather than zlib?
 
Hi,

currently we don't expose the qcow2 compression options at all in the PVE storage system, but you could always create the image yourself:

qemu-img create -f qcow2 -o compression_type=zstd /path/to/new/disk.qcow2 10G

And then, depending on the use case use either
Bash:
# import qcow2 disk to an existing VM on a storage
qm importdisk VMID /path/to/new/disk.qcow2 STORAGEID

# create new VM through CLI:
qm create VMID --scsi0 "STORAGEID:0,import-from=/path/to/new/disk.qcow2" # remaining options

# add the disk to an existing VM as unused if its already on the correct place on a storage
# can then be attached as used disk via GUI
qm set VMID --unused0 "STORAGEID:VMID/disk.qcow2"

After initial import/set/create you can use the web interface again to change options.
 
  • Like
Reactions: Moayad
Hi,
would it get converted automatically to raw format by default in the quoted part?
No, but you can pass a target format. The command name also changed a bit, albeit there's an alias for backward compatibility.

So what you seek could be nowadays done like:

Bash:
# import qcow2 disk to an existing VM on a storage as raw
qm disk import VMID /path/to/new/disk.qcow2 STORAGEID --format raw
 
  • Like
Reactions: senkis
Hi,
Hi @t.lamprecht , would it get converted automatically to raw format by default in the quoted part?
yes, import will default to raw format (or more specifically the storage's default format, which is raw for directory storages).
And then, depending on the use case use either
Bash:
# import qcow2 disk to an existing VM on a storage
qm importdisk VMID /path/to/new/disk.qcow2 STORAGEID

# create new VM through CLI:
qm create VMID --scsi0 "STORAGEID:0,import-from=/path/to/new/disk.qcow2" # remaining options
You would need to explicitly specify format=qcow2 for the above two. However, that still won't help, because those commands will allocate a new qcow2 image which doesn't have the zstd compression anymore and then copy/import the data from the old one.

So the below is the only option to keep the zstd compressed qcow2 image.
Code:
# add the disk to an existing VM as unused if its already on the correct place on a storage
# can then be attached as used disk via GUI
qm set VMID --unused0 "STORAGEID:VMID/disk.qcow2"

After initial import/set/create you can use the web interface again to change options.
 
  • Like
Reactions: senkis
Hi @fiona and @t.lamprecht , I was looking for qcow2 import disk without any reformat, because of interest in zstd (not the default zlib) compression option of qcow2. I created a zstd qcow2 and renamed it to existing qcow2 file, without using qm importdisk.
 
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!