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 SparseSparse
rsyncrsync -a src /tmprsync -a -S src /tmp
cpiofind src -depth|cpio -pdm /tmpfind src -depth|cpio -pdm –sparse /tmp
cpcp -a –sparse=never src /tmpcp -a –sparse=always src /tmp
tartar -c src|tar -x -C /tmptar -c -S src|tar -x -C /tmp

Time used and destination size:

Concolusion:
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.

Buffer