tar vs cp
kris at obsecurity.org
Wed Oct 1 18:03:11 PDT 2003
On Wed, Oct 01, 2003 at 03:25:27PM -0700, Pat Lashley wrote:
> --On Wednesday, October 01, 2003 13:22:36 -0400 Chuck Swiger
> <cswiger at mac.com> wrote:
> >Jamie wrote:
> >[ ... ]
> >> I don't know what the actual rationale is for this. Can anyone
> >> explain why it is oftentimes better to tar something rather than
> >>using cp when copying directories and their contents?
> >tar handles symbolic links properly, whereas cp will "copy through" the
> >contents of the link.
> Another technique is 'cd /source ; find . -print | cpio -pdmv /dest'.
> But none of the built in tools seem to preserve links, flags, and
> sparseness. If you want as close to a true copy as possible, check
> out the cpdup port.
using tar | tar instead of cp -r is usually faster because it makes
more efficient use of disk I/O, because reads and writes are queued up
at the same time, from the two processes) whereas cp -r reads and
writes chunks sequentially (it's actually implemented using mmap'ed
memory, which gains some efficiency, but it's still a sequential
process because there's only one single-threaded cp running).
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20031001/144e2f3a/attachment.bin
More information about the freebsd-questions