[CentOS] Mirroring Hard Drive

John R Pierce pierce at hogranch.com
Sun Dec 7 20:36:22 UTC 2008


Matt wrote:
>>> I have a 500GB Sata drive about 15% used I would like to make an exact
>>> copy of too another Sata 500GB drive as a spare.  That way if
>>> something happens to the one in service I can plug in the spare
>>> quickly and restore one of the weekly backups without reinstalling the
>>> entire OS and all the little tweaks of setup on this mail/web server.
>>>
>>> How do I do this?  That is make an exact bootable copy of a linux
>>> drive.  Its running Centos 4.6 if that matters.
>>>
>>>       
>> brute force approach...
>>
>>   dd if=/dev/sda of=/dev/sdb bs=16384
>>
>> that will copy the whole physical drive.   I would do this in single user
>> mode (init 1) for best results, as any changes to the file system while a
>> copy is in progress will be inconsistent
>>     
>
> Can I use this to copy from a single 500GB SATA drive with only 54GB
> in use to a hardware RAID 1 drive of 300GB?  The RAID will be two
> 300GB SATA drives.
>
>   

no, as dd is a raw block copy of the storage device.   i dont actually 
recommend usinig DD on file systems at all

instead, assuming the raid is freshly formatted, and temporarily mounted 
as /mnt I would use something like...

    dump 0vf - /dev/sda1 | (cd /mnt; restore -rf - )

if there's more than one file system on the source, repeat this for each 
one.   note that the source file systems must be unmounted when you do 
this, hence you would need to do this from a CD boot if its the system 
drive.


More information about the CentOS mailing list