qcow2 sizing issue

ver

New Member
Jun 14, 2023
4
0
1
Hello all,

I have a few questions regarding qcow2 images sizes because right now I am really confuzed... Let me describe a bit about a situation I deal with.

I have 1.4 TB array with contains just one single VM with 3 separated qcow2 images:

# ls -lah
-rw-r----- 1 root root 17G jun 14 10:44 vm-100-disk-0.qcow2
-rw-r----- 1 root root 1,4T jun 14 10:44 vm-100-disk-2.qcow2
-rw-r----- 1 root root 199G jun 14 10:44 vm-100-disk-3.qcow2

All looks fine, but the actuall size of the storage on that host is 1.4 TB, so how the hell I can have almost 1.6 TB?
You might say "there is a difference between actual size of image and the reserved size" - OK, I agree, but - how to explain info below?

qemu-img info vm-100-disk-0.qcow2
image: vm-100-disk-0.qcow2
file format: qcow2
virtual size: 10 GiB (10737418240 bytes)
disk size: 10 GiB
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false

qemu-img info vm-100-disk-2.qcow2
image: vm-100-disk-2.qcow2
file format: qcow2
virtual size: 1.17 TiB (1288490188800 bytes)
disk size: 1.15 TiB
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false

qemu-img info vm-100-disk-3.qcow2
image: vm-100-disk-3.qcow2
file format: qcow2
virtual size: 185 GiB (198642237440 bytes)
disk size: 184 GiB
cluster_size: 65536
Format specific information:
compat: 1.1
lazy refcounts: false
refcount bits: 16
corrupt: false

Those sizes (disk or virtual) are really different than values displayed by ls command. Partitions created on those images are pretty much the same as the virtual sizes, so they cant be oversized. How is it possible they weight more?

Whats more - when I moved the 3rd image (185 GB, actually used 133GB, but ls shows it as 200GB) to different server I gained 167 GB of space on that storage. I was a bit worry when I tried to move it back - but it actually moved without problem. What kind of math calculated actually 167 GB?

And last thing - proxmox storage info in GUI shows 96,7% storage usage... Even if df command shows 100% usage and 0 free space.

So my questions are:
  1. How to determine the real size of the images
  2. The moment sum of sizes of images are 200GB over actually storage size - storage has 0 free space. The sum of partitions sizes on images are about 1.35 TB (about 80% filled) - do I need to worry about lack of free space.. somewhere? somehow?
  3. How to shring the image so it fit the size it actually has reserved?

Best regards!
 
1. The allocated (first value) and the actual size (second) can be displayed with:
Code:
ls -slh

2. How much data you can really store inside a qcow2 image depends also on things like compression, copy-on-write or the used filesystem inside. Regarding the lack of free space you can also read about discard and check if it's enabled / will get applied. As a side note, using discard on full disk encryption like LUKS will affect the protection negatively.

3. The size of an qcow(2) file can be reduced with
Code:
qemu-img convert
But you need to have enough free space left during the process for creating the new (size reduced) file. Stopping the VM is required and having a backup (...). See:
https://manpages.debian.org/bookworm/qemu-utils/qemu-img.1.en.html#convert~2
 
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!