XFS supports copy on write (CoW), so it is not entirely clear what du
will say if some of the bytes are shared across files. I'd like to find a way to check how much disk space a folder uses, not counting shared bytes multiple times, i.e. the real usage on disk.
Neither xfs_estimate
nor du
seem to do what I need:
$ mkdir testfolder
$ cd testfolder
$ dd if=/dev/zero of=testfile bs=1M count=500 status=progress
500+0 records in
500+0 records out
524288000 bytes (524 MB, 500 MiB) copied, 0,158889 s, 3,3 GB/s
$ cp --reflink=always testfile testfile2
$ xfs_estimate .
. will take about 1004,4 megabytes
$ du -hs .
1000M .
What I expect is that some tool says that this folder uses only 500MB.
df
shows that free disk spaces is reduced by 500MB when using a plain cp
, but not at all when doing a cp --reflink=always
. So reflinking seems to work, but df
is not helpful in practice, because the disk is huge and I want to check the real size of a quite small folder.
I assume this might be a valid question for BTRFS too. But in my case, I need a solution which works for XFS.