Skip to contentSkip to conversation

du --bytes show different value for btrfs and e.g. ext4 with identical data

DISCUSSION Christoph Anton Mitterer 2 participants 3 messages Aug 13, 2022 Btrfs file system

lore
Share & tools
lore
#0 lore raw

Hey.

Forgive me if that has been answered before, but I couldn't find it on the list or the manpage.

I have my personal data on several backup disks, all of them except one (which is ext4) being btrfs.

The data on them is 100% identical (diff -qr --no-dereference brought no difference). On the btrfs, the whole data is always in one subvolume.

Yet, when I do:
du --bytes (which implies --apparent-size)
I get (in my case):
5035634863728 for (all the) btrfs
but
5035836693616 for the ext4

Which is some 192 MiB more on ext4.

Because of --apparent-size, this shouldn't be any refcopy or compression effects; also hardlinks shouldn't matter (and are the same on all of the filesystems anyway).

Any idea why the results are different and shouldn't they be the same? And if not, would it make sense to have this behaviour added to btrfs(5)?

Thanks,
Chris.

#1 lore raw
Quoted 23 lines · Christoph Anton Mitterer

Hey.

Forgive me if that has been answered before, but I couldn't find it on the list or the manpage.

I have my personal data on several backup disks, all of them except one (which is ext4) being btrfs.

The data on them is 100% identical (diff -qr --no-dereference brought no difference). On the btrfs, the whole data is always in one subvolume.

Yet, when I do:
du --bytes (which implies --apparent-size)
I get (in my case):
5035634863728 for (all the) btrfs
but
5035836693616 for the ext4

Which is some 192 MiB more on ext4.

Quoted 6 lines

Because of --apparent-size, this shouldn't be any refcopy or compression effects; also hardlinks shouldn't matter (and are the same on all of the filesystems anyway).

Any idea why the results are different and shouldn't they be the same?

You did not show your actual command which makes it impossible for anyone to reproduce it. But my guess is that your du invocation includes size of directories which is different between different filesystems.

Quoted 7 lines

And if not, would it make sense to have this behaviour added to btrfs(5)?

Thanks,
Chris.

#2 lore raw
Quoted 5 lines · Andrei Borzenkov

You did not show your actual command which makes it impossible for anyone to reproduce it. But my guess is that your du invocation includes
size of directories which is different between different filesystems.

Ah... yes that's the reason.
Unfortunately du has no built-in option to exclude the dirs and count only the sizes of regular files

But one can do e.g.:

$ find . -type f -print0  | du --apparent-size -l -c -s --block-size=1 --files0-from=-

Thanks,
Chris.