Combine mkfifo and cp --reflink to append files without copying data
3
votes
0
answers
329
views
I have huge files
{0..9}.bin
which I want concatenate into out.bin
. I don't need the original files afterwards. So I was wondering, if this is possible by only modifying the filesystem index without copying the file contents (see https://unix.stackexchange.com/q/80429/234981 for efficient copy solutions).
On modern file systems (e.g. btrfs) cp --reflink=always
exists. Fifos are on the file system level (at least btrfs send
also tracks fifos), so they should have information about the actual data blocks used. Therefore, cp --reflink=always
should be able to determine the extend numbers on disk and re-use them.
So I was wondering, if it is possible to use mkfifo
in combination with cp --reflink=always
?
**Update**
Currently, it is not working:
for i in {1..9}; do dd if=/dev/urandom of="in$i.bin" bs=5M count=200; done;
mkfifo fifo
cat in* >fifo &
cp --reflink=always fifo out.bin
results in
cp: failed to clone 'out.bin' from 'fifo': Invalid argument
Probably, it never will, since FIFOs have no information about the storage origin bug instead are just dumb pipes.
Asked by darkdragon
(175 rep)
May 20, 2020, 08:46 AM
Last activity: May 20, 2020, 04:19 PM
Last activity: May 20, 2020, 04:19 PM