It's clear, with cp --reflink foo bar I can copy a file on btrfs without wasting space? But how can I detect that the two files (foo and bar here) are using the same "space unit"?

If they were hardlinks, I would use [ foo -ef bar ] for comparing or stat -c%i foo to get a unique id (inode in this case).

Are there similar commands for btrfs reflinked files?

I want to apply this on a 300G volume which is virtually 6T in size due to deduplication, so I want to avoid checksumming...


Ok, this is probably the best so far: https://unix.stackexchange.com/a/277043/55508, by @pwaller

Further to my previous answer, I have just released fienode which computes a SHA1 hash of the physical extents of the file and can be used to find some (identical) reflink copies. Beware though, there are caveats (see the documentation). BTRFS decided to change some, but not all, of the physical extents of a refink copy I made without provocation or warning, causing the value to change.

  • The tools seems to detect files as similar which don't even have the same size. Now checking if this is only for <1 block files and why – Daniel Alder Oct 16 '18 at 15:42
  • github.com/pwaller/sharedextents by the same author is exactly what I was looking for. – Charles Duffy Nov 26 '18 at 0:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.