[ltp] Copying Files

James Hawtin linux-thinkpad@linux-thinkpad.org
Mon, 6 Dec 2004 16:44:12 +0000


On Mon, Dec 06, 2004 at 11:17:16AM -0500, James Knott wrote:
> If you're copying files, why not use the cp command?  That's what it's 
> there for.  dd is often used to copy entire partitions to or from a file 
> or to convert data in a file.  It is not used as a general file copy 
> program.
> 
> man dd for further info.
> -- 
> The linux-thinkpad mailing list home page is at:
> http://mailman.linux-thinkpad.org/mailman/listinfo/linux-thinkpad

using tar | tar is very effective as it can copy special devices
and links, which cp oftain fails on.

I oftain use tar | split so getting the data off compete file systems.
If you want to copy root, a statically linked tar, with chroot works well.

Say I want to copy /usr to some other partition /hog is where I have some
space.

tar -cPpSslf - /usr | split -b 2000m - /hog/usr_

next I umount /usr and mount up the new one I want.

cat /hog/usr_* | tar -xvPpSslf - 

l in tar means stay on the same filesystem, you may or may not want it....

Doing a root filesystem mount it on say /new_root copy your statically
linked tar to /new_root then....

cat /hog/root_* | chroot /new_root star -xvPpSslf -

You can do that in one go with....

tar -cPpSslf - / | chroot /new_root star -xvPpSslf -

James

PS The commands are ment as "ideas" not as funcationally correct, make sure
you double check before use.