How do you duplicate a drive?

Jerry McAllister jerrymc at clunix.cl.msu.edu
Sat Oct 2 09:13:22 PDT 2004


> 
> 
> I have a RAID mirror (2x 160GB) which I would like to back up onto a spare 
> 160GB drive.
> 
> I do not have a hot-swap caddy so I was planning on powering down the 
> system to get the backup drive in and out.
> 
> But once I have the new blank drive in, what is the best way to duplicate 
> the RAID? Ideally I would like to create a disk that could boot the system 
> (and rebuild the RAID) in case disaster strikes.
> 
> Can dd do this?
> 
> I am new to Unix disk operations... Many thanks in advance for the help.

I am just a bit unsure of what you are asking.   Do you mean to try
and duplicate the raid mirror set on the single 160GB spare disk?  

Or do you mean that you just want to make a backup copy of the files
on the raid mirror set to the spare drive?

I don't think you can do the first.   But the second would be
easily accomplished using dump(8) (and restore(8) if you wish).

Depending on whether you want to access the files in place while they 
are on the spare disk or you want to just have a convenient backup
of the raid mirrot set in case something happened you would either:

 - dump the file system[s] on the raid mirror set to [a] file[s] on
   the spare disk.   
   example:  if you had a file systems named /usr and /home on the mirror
     dump 0af /spare/usr.dump /usr
     dump 0af /spare/home.dump /home
   would give you an easily accessible dump files of /usr and /home
   You would have to  'restore -if'  any files that you want to use
   from the dump files.  But if the mirror crashed, it would be easy
   to (first repair or replace it) and then do a standard restore of
   the whole dump files in to the rebuilt mirror file systems.
or

 - pipe the dump[s] of file system[s] on the raid mirror to restore[s]
   on the spare disk.   You need to premake at least directories on the
   spare to receive the dumps.  Better to make file systems on the spare
   for each file system on the mirror set.  In case you ever need to do
   a complete restore of the mirror set then you can just do a reverse
   of this  dump | restore
   So, assuming you have done the slicing, partitioning and newfsing of
   the needed size file systems on the spare disk and mounted them
   as something like   /spareusr and /sparehome  then:
     cd /spareusr
     dump 0af - /usr | restore -rf -
     cd /sparehome
     dump 0af - /home | restore -rf -
   would duplicate the file systems and make the files all usable in place.
   To rebuild the mirror set if it crashed and after you repaired it
   and rebuilt the filesystems and mounted them in their original places
   you would have to reverse the dump-restore as is
     cd /usr
     dump 0af - /spareusr | restore rf -
   Or you could just remount the spares as /usr and /home and use them
   just like that without reviving the raid.


Anyway, using dd to copy the device would not work I don't think because 
it would try a byte for byte copy and the spare disk is definitely not
an identical device to the raid mirror set.

Hope that is all clear.

////jerry 
 
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"


More information about the freebsd-questions mailing list