Does CoW work for files that have the same content but were not created by `cp --reflink`?

119 Views Asked by At

I think CoW works for this.

echo 'stackoverflow' > foo

cp --reflink foo bar

So what about this one?

echo 'stackoverflow' > foo
echo 'stackoverflow' > bar

In this case, do they use the disk space of two files?


In my use case, there are not many copied files on my disk. However, there are many files of the same content generated by programs.

I hope that CoW is effective for such files, but if not, isn't compression more effective? This is why I asked this question.

1

There are 1 best solutions below

1
On BEST ANSWER

In this case, do they use the disk space of two files?

Yes: the files are created independently and use individual disk space.

If you already have many files with duplicate contents and want to take advantage of BTRFS' CoW features, you are looking for (offline) deduplication using tools like duperemove.