Linux file copy benchmark cp vs cpio vs tar vs rsync

There are many commands to copy a directory in Linux. The difference between them in current Linux distribution are very small. All of them support link, time, ownership and sparse.

I tested them to copy a Linux kernel source tree. Each command I tested twice and keep the lower result.
The original directory size is 639660032 bytes. All methods generate exact same size of 675446784 bytes without sparse option.

Non Sparse Sparse
rsync rsync -a src /tmp rsync -a -S src /tmp
cpio find src -depth|cpio -pdm /tmp find src -depth|cpio -pdm –sparse /tmp
cp cp -a –sparse=never src /tmp cp -a –sparse=always src /tmp
tar tar -c src|tar -x -C /tmp tar -c -S src|tar -x -C /tmp

Time used and destination size:

For non sparse copy, rsync is the fastest. For sparse copy, rsync and cpio have the best space efficiency, but slow.

  • naisanza

    This is the first comparison for rsync and cp that showed rsync to be faster than cp. In all my uses, cp has always shown to be faster than rsync, where rsync caps at perhaps ~20MB/s. I’ve read somewhere, where the researcher set the appropriate CPU cores to the rsync process, allowing it to reach higher transfer speeds, somewhere around twice the amount, much nearer to the actual transfer speeds of the disk. It’s a bit of a hassle to go through, however.