Container storage size strange behavior

Hi,

I have an arch linux container with storage quota applied(btrfs as backend storage):

  • lxc config device add container_name root disk pool=default path=/

  • lxc config device set container_name root size 25GB

lxc info container_name gives output:
Disk usage:
root: 20.00MB(it was not exactly 20MB)

Later i added a 5GB file in the container:
fallocate -l 5G bar

Then the root size of the container was something more than 5GB.

2 days later when i checked again the root size of the container is:
Disk usage:
root: 22.46MB

The 5GB file is still there in the container
ls -all:
-rw-r–r-- 1 root root 5368709120 Jun 27 16:00 bar

Is it the btrfs compression thats causing this behavior?

Extra info:
sudo btrfs qgroup show -pcref of the container
qgroupid rfer excl max_rfer max_excl parent child


0/469 5.43GiB 21.42MiB 23.28GiB none — —

Any extra thoughts about this?
Thanks!

Best Regards,

Lennert

fallocate -l creates a sparse file, so until you actually make use of the file, it will only count as a few bytes.

You can run du -h bar to see how much space that file actually consumes.

1 Like

I inserted 2 mp4 files into the container(4.5GB each, but tesame mp4 file, other name).

After putting the files into the container it was 9GB+
Now a day later:
Disk usage:
root: 41.89MB

I found an interesting topic on github about this issue: BTRFS reporting incorrect disk usage · Issue #8468 · lxc/lxd · GitHub