Y
Y
youngmysteriouslight2019-12-16 13:50:39
btrfs
youngmysteriouslight, 2019-12-16 13:50:39

How to detect space overuse in btrfs?

Decided to touch BTRFS. Did according to the instructions help ubuntu :

mkdir mnt
truncate -s 5G img
mkfs.btrfs img
losetup /dev/loop0 img
mount /dev/loop0 mnt
chmod 777 mnt # далее все команда от имени обычного пользователя

Next, I copied inside mnt a collection of tags (versions) of the old project from the ext4 partition using rsync -a.
5df75ba702ea8203798667.png
$ du -hs mnt/tags/*
5,8M	v0.0.1
5,8M	v0.0.2
52M	v0.1.0
55M	v0.1.1
59M	v0.1.2a
50M	v0.1.2 dcb7656
59M	v0.1.3 grand-merge
57M	v0.1.4
135M	v0.1.5
27M	v0.2.0
5,4M	v1.0
4,0M	v1.1
5,3M	v1.2
4,1M	v1.2.2
4,9M	v1.3
5,1M	v1.3-without-tag
6,5M	v1.4
6,4M	v1.5
6,6M	v1.6
6,6M	v1.7

As you can see, du and the gui analyzer are consistent. Then I do
$ btrfs filesystem du -s mnt
     Total   Exclusive  Set shared  Filename
 483.00MiB   483.00MiB       0.00B  mnt

$ btrfs filesystem du -s mnt/tags/*
     Total   Exclusive  Set shared  Filename
   5.52MiB     5.52MiB       0.00B  mnt/tags/v0.0.1
   5.40MiB     5.40MiB       0.00B  mnt/tags/v0.0.2
  50.21MiB    50.21MiB       0.00B  mnt/tags/v0.1.0
  52.29MiB    52.29MiB       0.00B  mnt/tags/v0.1.1
  57.23MiB    57.23MiB       0.00B  mnt/tags/v0.1.2a
  47.59MiB    47.59MiB       0.00B  mnt/tags/v0.1.2 dcb7656
  55.67MiB    55.67MiB       0.00B  mnt/tags/v0.1.3 grand-merge
  53.88MiB    53.88MiB       0.00B  mnt/tags/v0.1.4
 131.61MiB   131.61MiB       0.00B  mnt/tags/v0.1.5
  23.41MiB    23.41MiB       0.00B  mnt/tags/v0.2.0
 192.00KiB   192.00KiB       0.00B  mnt/tags/v1.0
     0.00B       0.00B       0.00B  mnt/tags/v1.1
     0.00B       0.00B       0.00B  mnt/tags/v1.2
     0.00B       0.00B       0.00B  mnt/tags/v1.2.2
     0.00B       0.00B       0.00B  mnt/tags/v1.3
     0.00B       0.00B       0.00B  mnt/tags/v1.3-without-tag
     0.00B       0.00B       0.00B  mnt/tags/v1.4
     0.00B       0.00B       0.00B  mnt/tags/v1.5
     0.00B       0.00B       0.00B  mnt/tags/v1.6
     0.00B       0.00B       0.00B  mnt/tags/v1.7

Where are the zeros from? Weird.
Further:
$ btrfs filesystem df -h mnt
Data, single: total=1.01GiB, used=483.19MiB
System, DUP: total=8.00MiB, used=16.00KiB
Metadata, DUP: total=256.00MiB, used=36.53MiB
GlobalReserve, single: total=16.00MiB, used=0.0

More experience:
$ cp -r --reflink=always mnt/tags mnt/t
$ btrfs filesystem du -s mnt/*
     Total   Exclusive  Set shared  Filename
 483.00MiB       0.00B   483.00MiB  mnt/t
 483.00MiB       0.00B   483.00MiB  mnt/tags

How to find out how much space
1) files take from the point of view of the FS - du works, as we see,
2) occupies the FS, taking into account reuse and compression on the physical disk
3) is reused for a given set of files and directories (how to interpret the output in the last experiment? why exclusive zero?)
Another question: the full estimate of the copied information is 587Mb for du and 483Mb for btrfs du. Why does this difference arise? More precisely, what exactly does btrfs du measure?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question