Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying the content of a whole disk 1

Status
Not open for further replies.

srenshaw

IS-IT--Management
Jan 19, 2005
75
CA
If I want to copy the whole content of a disk to another one, I just need to copy what is in /mnt/x to /mnt/y ?

Will this copy everything, including hidden files if any ?
 
I don't know if it will work the same on Linux, but I use this on other Unices...
Code:
cd /mnt/x ; tar cf - . | (cd /mnt/y; tar xfBp -)
If done as [tt]root[/tt], it will copy all files, ownership, and permissions.

Hope this helps.
 
It's on Redhat 9. Wouldn't I need to put the - before the switches ?

If I got that right, this create an archive that is automatically decompressed on the target drive ?

The disk is nearly full. Does this need to create a file ?
 
Would this work ?

Code:
cp -rP /mnt/ibm/*.* /mnt/ibm2/
 
I don't think that the *cp* command will work with links (ln -s) so tar is the correct solution.

Cheers.

"Avoid virus, boil your PC 1 min. before use it
 
Tar doesn't do compression. And the command line I gave is sending the tar "file" to standard out, which is just piped to the other tar that is "opening it" in the new location. So there is no intermediate tar file created. It's just piped from one tar to the other tar. The end result is the whole directory tree is copied without needing an intermediate file.

And on most implementations of tar, the dash is optional before the switches. I just checked on one of my Linux systems and the dash is not needed.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top