[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: General method for copying a partition



Sjoerd Hardeman wrote:
> Stephen Powell schreef:
>> Hi, all!
>>
>> In one of my web pages, as part of a larger overall procedure, I give
>> instructions for copying an entire partition.  The basic procedure involves
>> mounting one partition on /media and the other on /mnt.  Then the files
>> are copied between partitions by means of
>>
>>    cp -a /media/* /mnt
>>

<<old context removed>>

>> Of course, special handling is necessary to avoid processing "." (the current
>> directory) and ".." (the parent directory).  Does anyone know a better way?
>>
> rsync -a /media/ /mnt/
> OR
> find /media -exec cp -a {} /mnt \;

I'm not sure this second one will work as expected, unless you remove
the '-a' on the 'cp'.

The 'find' is recursive and so is 'cp -a', so every directory found by
'find' will be recursively processed by both.  'cp' will end up copying
files multiple times, depending on the directory depth.

Though the result may be OK (copies over copies), the amount of work and
length of time to complete will both be unnecessarily large.

> 
> Sjoerd
> 

-- 
Bob McGowan


Reply to: