Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Oct 2003 18:03:07 -0700
From:      Kris Kennaway <kris@obsecurity.org>
To:        Pat Lashley <patl+freebsd@volant.org>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: tar vs cp
Message-ID:  <20031002010307.GA15545@rot13.obsecurity.org>
In-Reply-To: <2156421632.1065047127@mccaffrey.phoenix.volant.org>
References:  <20031001122603.B71418-100000@floyd.gnulife.org> <3F7B0D5C.7080009@mac.com> <2156421632.1065047127@mccaffrey.phoenix.volant.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--2fHTh5uZTiUOsy+g
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Oct 01, 2003 at 03:25:27PM -0700, Pat Lashley wrote:
> --On Wednesday, October 01, 2003 13:22:36 -0400 Chuck Swiger=20
> <cswiger@mac.com> wrote:
>=20
> >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.
>=20
> Another technique is 'cd /source ; find . -print | cpio -pdmv /dest'.
>=20
> 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).

Kris


--2fHTh5uZTiUOsy+g
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQE/e3lLWry0BWjoQKURAiWTAKD2tj7NlWnSXpbPQ9+fTgXt4iKNUwCcDoBz
VebHIYt94KCXXdqBd9za6iM=
=UXjW
-----END PGP SIGNATURE-----

--2fHTh5uZTiUOsy+g--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20031002010307.GA15545>