tar vs cp

Kurt Wall kwall
Mon May 17 11:55:17 PDT 2004


Quoth M.W. Chang:
> 
> It's from a how-to on converting a root partition to xfs.
> what does the following command do?
> 
> mount -t ext2 /dev/hda6 /mnt

Mount the ext2 file system on /dev/hda6 at /mnt 

> cd /

Obvious.

> tar lvcf - . | (cd /mnt ; tar xpvf -)

Invoke tar on the current directory (".") without recursing outside
of the current directory's file system ("l") and verbosely ("v") create
("c") an archive, sending the output to stdout ("f -"), which output
is  piped into the subprocess specified between the (). That subprocess 
first makes /mnt its current working directory ("cd /mnt") then invokes
tar *in /mnt* to extract ("x") the archive file read from stdin ("f -"),
saving file permissions on files in the extracted archive ("p").
 
> can I use cp -a to achieve what the tar did?

No -- cp will be considerably slower than tar.

Kurt
-- 
Condense soup, not books!


More information about the Linux-users mailing list