[H-GEN] cp incantation

Jason Parker-Burlingham jasonp at panix.com
Wed Apr 20 21:57:36 EDT 2005


On Thu, Apr 21, 2005 at 11:12:13AM +1000, Greg Black wrote:
> On 2005-04-21, Doug South wrote:
> > cp -L -preserve=all -r /usr /mnt/hda6

> In normal Unix usage, cp(1) is the wrong tool to use, even
> though modern versions of it do have much of the functionality
> you're looking for.  The "correct" modern tool is pax(1):

Since Greg alludes to it, the correct argument *if* you're using GNU
tar, which isn't guaranteed, is "cp -a".  That's what I use when
correctness and efficiency aren't foremost and it hasn't failed me.

> If you don't have pax, the next tool to try is tar(1):
>     tar -cf- /usr | ( cd /mnt/hda6 ; tar -xvf- )

If you're going to do this you may also want to be aware that some
versions of GNU tar don't set permissions and ownership on the
destination files as they go, preferring instead to set them at the end.
This cost me several very stressful hours back in the day---I had an ssh
call between the two tar processes and couldn't work out why file
ownership wasn't being preserved.

> Obviously, do all the above as root.

And preferably in single-user mode, in case some random but important
file changes while you're reading it.  (Mounting /usr read-only would
normally be an option but you've only one partition.)




More information about the General mailing list