I know that cp
has a --reflink
option to control full copies vs. copy-on-write "copies".
On btrfs, can I use ls
(or some other command) to find out whether a file shares (in a copy-on-write senses) some storage with another file?
EDIT: @StéphaneChazelas points me to filefrag
, but that fails for me:
root@void:/tmp/mount# mount | tail -1
/tmp/back on /tmp/mount type btrfs (rw,relatime,space_cache)
root@void:/tmp/mount# df -h | tail -1
/dev/loop0 32M 13M 20M 38% /tmp/mount
root@void:/tmp/mount# ls -lh
total 8.0M
-rw-r--r-- 1 root root 8.0M Jan 19 08:43 one
root@void:/tmp/mount# cp --reflink=always one two
root@void:/tmp/mount# sync
root@void:/tmp/mount# ls -lh
total 16M
-rw-r--r-- 1 root root 8.0M Jan 19 08:43 one
-rw-r--r-- 1 root root 8.0M Jan 19 08:45 two
root@void:/tmp/mount# df -h | tail -1
/dev/loop0 32M 13M 20M 38% /tmp/mount
root@void:/tmp/mount# filefrag -kvx one
Filesystem type is: 9123683e
File size of one is 8388608 (8192 blocks of 1024 bytes)
FIEMAP failed with unknown flags 2
one: FIBMAP unsupported
root@void:/tmp/mount# uname -a
Linux void 4.1.7+ #817 PREEMPT Sat Sep 19 15:25:36 BST 2015 armv6l GNU/Linux
filefrag -v
, you can check whether two files have data in common. – Stéphane Chazelas Jan 18 '16 at 15:26