How best to copy the entire contents of one partition to another?

Dale Farnsworth dale at farnsworth.org
Sat Jan 7 19:01:41 MST 2006


In article <200601071807.09434.joe at actionline.com> you write:
> I need to try to resintall Mandriva  2006 because the one I've 
> been screwing around with for nearly a month is apparently 
> all messed up.   It is on partition hda6. 
> 
> But in doing this, I want to make sure that my /home directory 
> (which is on a separate partition, hda7) is protected.  I do have 
> a dvd backup of /home, but as an added precaution, I would like 
> to copy the entire contents of /home (on hda7) to another unused 
> partition (hda8).  Would the following be the correct command to 
> do this.  With both hda7 and hda8 mounted, as root: 
> 
> 	cp -pr /mnt/hda7 /mnt/hda8 
> 
> Or is there another or better way to do this? 

That's essentially what I would do, though with slightly different
options.

I recommend (as superuser):
	cp -ax sourcedir/. destdir

or, in this instance: cp -ax /mnt/hda7/. /mnt/hda8

The main advantage of "cp -ax" over "cp -pr" is that is will duplicate
symbolic links rather than copying their contents.

> I've heard of but never used 'dd' ... is that something that might 
> be better to use in some way? 

dd will copy the full partition, block by block, rather than
copying individual files.  It's almost always more appropriate to do
"cp -a", unless fsck detects significant filesystem structure damage.

-Dale


More information about the PLUG-discuss mailing list