Best way to duplicate a drive?

Best way to duplicate a drive?

Post by William D. Ward J » Sat, 04 Nov 1995 04:00:00



I have two identical hard drives and I was wanting to make one the exact
duplicate of the other.

I thought of doing something simple like catting one and redirecting the
output to the other like this:

# cat /dev/rsd0c > /dev/rsd2c

But when I compared the two drives, they did not match.

# cmp -l /dev/rsd0c /dev/rsd2c
  8227 243 234
  8228 163  57
  8392  50  70
...

I even tried comparing some of the partitions toward the end of the
disk (/dev/rsd[02]h) that I am sure did not change on the origional drive.
I got simular results.

I am curious where this fowled up, if indeed it did.  But more importantly,
what is the best way to make an exact copy of a drive?

 
 
 

Best way to duplicate a drive?

Post by Joel Masl » Sun, 05 Nov 1995 04:00:00


This should be added to the FAQ!!!  :)


: # cat /dev/rsd0c > /dev/rsd2c

Are they the same size?

I use the following script for my backups, where / is the drive I want to
back up and /backup is the backup drive.  I'll explain in comments:
Note that /backup already has an empty filesystem.
Also, special procedures will need to be done to make this bootable.  
Read your OS's manual.

--- Start of File: backup ---
#! /bin/sh
# why use anything else?

cp /etc/nologin.backup /etc/nologin
# To prevent users from getting on!  Note that it may be a better idea to
# throw users off prior to this!

umount /dev/hda3
umount /dev/hdc1
umount /dev/sbpcd
# /dev/hda3 is /dos, while /dev/hdc1 is /backup.  Obviously, I don't want
# to backup backup, nor do I care about /dos, so...  It's also not good
# to backup CD-ROMs.  You'll have to change this to reflect your system.

cd /
find ./ > /tmp/files
# My version of 'find' will cause this to create a list of all
# files/directories/devices/links on my drive.  The '.' *IS* important.
# The dot will also reference /backup/etc when the current directory
# is /backup.  This is important.

mount -a
# Remount everything, including /backup (how else could I copy these files?

cpio -p -d -m --b=16 /backup < /tmp/files
# Using the list of files on the primary drive, piped through cpio.  cpio
# copies the files.  cpio is special in that it copys links as links, devices
# as devices, etc.  This prevents problems later!  Also, file dates are
# correct when using these options.  Note --b=16 specifies that 16 block
# chunks will be copied.  You'll probably want a different value, but this
# will work - just a little slower.  The -p causes it to run in copy pass-
# through mode -- Copies from one directory tree to another.  This is
# the part that needs the './whatever file'.
# The -d creates the needed directories, and -m preserves the modification
# times.

rm /tmp/files
rm /backup/tmp/files
rm /etc/nologin
# some cleanup.

echo Backup Complete!
--- End of File ---

Joel Maslak

I am Pentium of Borg.
Division is futile.
You will be approximated.

 
 
 

Best way to duplicate a drive?

Post by Frank Friedm » Tue, 07 Nov 1995 04:00:00




Quote:>I have two identical hard drives and I was wanting to make one the exact
>duplicate of the other.

>I thought of doing something simple like catting one and redirecting the
>output to the other like this:

># cat /dev/rsd0c > /dev/rsd2c

>But when I compared the two drives, they did not match.

># cmp -l /dev/rsd0c /dev/rsd2c
>  8227 243 234
>  8228 163  57
>  8392  50  70
>...

>I even tried comparing some of the partitions toward the end of the
>disk (/dev/rsd[02]h) that I am sure did not change on the origional drive.
>I got simular results.

>I am curious where this fowled up, if indeed it did.  But more importantly,
>what is the best way to make an exact copy of a drive?

Mirror the drive (if you have the technology).  Otherwise try "cp -r"
command.  The "-r" should recursively copy all of the subdirectories.

********************************************************************

I'm not wierd... I'm unique!!  There's a difference!
********************************************************************

 
 
 

Best way to duplicate a drive?

Post by Birger Wathn » Tue, 07 Nov 1995 04:00:00


If the disks are identical (same number of heads/cylinders/etc)
then you can duplicate them with something like
# dd if=/dev/rsd0c of=/dev/rsd2c bs=16k

If this is your system disk, then at least the swap partition will
have differences, but I know that this method works. It will
bring over the whole disk label, partition table, etc. No need
to run installboot for system disks or anything.

This will result in very inefficient file systems if the
target disk has a different physical geometry. So if you want to
copy to a different disk, you should go the long route. First
partition and newfs the new partitions, then
# mount /dev/sd2a /mnt
# cd /mnt
# dump 0f - / | restore -rf -
# rm restoresymtable
# cd ..
# umount /mnt
And repeat for each file system.

Birger

 
 
 

Best way to duplicate a drive?

Post by Paul Teagu » Thu, 09 Nov 1995 04:00:00


First  'man dump'  then 'man restore'

Then use a modification of the command
         dump  -0f  -  /usr  |  (cd /mnt;  restore  -xf  -)

This should exactly duplicate your file system.
I have successfully used this method to move filesystems all over the place.
Good luck.

Paul Teague    Systems Engineer/Unix Admin/Oracle DBA

#include <Standard disclaimer>  "All opinions voiced are my own, etc..."

 
 
 

1. Best ways to increase the security of my linux box

        Can anyone tell me how I should go about securing my linuyx box
from hackers or other potential threats?  What things are out there that
come with the standard slackware bvuild that should be secured?  Programs
that may test weaknesses of my box?  Any and all advice is needed.  Im
trying to keep away from making my box a firewall, but advice in that sort
and recommendations are greatly appreciated.  Thanks in advance.

2. Printing with HPLJ4MP

3. Best ways to handle function keys?

4. Stoppin MacOS from asking if disk should be formatted

5. Q: The Best Ways to Have 4GB Linux Box

6. aic7xxx driver on Linux2.4.6

7. Best ways to optimise Linux

8. Ether Express PRO 100 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

9. Best ways of searching web pages - wais, swish etc

10. The best ways to connect a Win95 box to a Linux box ???????

11. What's the best way to monitor (and log) duplicate ip address in a network?

12. What is the best method to duplicate an HD to another

13. Eliminating duplicate emails (duplicate message ID) in MS Outlook/Exchange