There are two schools of thought for how to clone drives under unix. The quick and dirty method is via the unix command dd. This is a bit for bit copy tool So it can even copy master boot records and partition tables. But it also copys empty space and kinda requires the drives be identical. Since it’s rare to actually have identical drives I’m going to show you how to use other system tools available under IRIX and Solaris to accomplish this task ask well as even make the new cloned drives better.
We start with Solaris. Not much has changed in this OS over the years. Most of the following was stolen from http://timesync.gmu.edu/wordpress/?p=30 It was customized to account for increasing the partition sizes.
Note that in order to garuntee the best results use the
Say the original drive is c1t0d0 and the new drive is c1t4d0
Note that in order to guarantee the best results use the prtvtoc & df commands to look at what the old partition table is. This Will let you know what partitions you need to create and the minimum sizes for each one. When formatting the partitions can be bigger but must be at least the same size.
prtvtoc /dev/rdsk/c1t0d0s2 > /root/OldPartitionTable
df -k >> /root/OldPartitionTable
Once you know the current partition sizes use the format command to setup your new drive.
Now, this script will build new file systems on the partitions of the new disk…matching those on the original. Then it will run ufsdump, copying data from the original to the new drive…then unmount the new “clone†drive. Finally it makes the new clone bootable. Note that this jazzy blog format wraps lines on the installboot line of the script…a “man installboot†will give you a clean copy of the syntax.
#! /bin/ksh
# script assumes:
# c1t0d0 is original
# c1t4d0 is drive we’ll turn into a clone
partlist=$(prtvtoc /dev/rdsk/c1t4d0s2 | awk ‘!/\*/ {print $1}’)
for p in $partlist
do
if [ "$p" != "1" -a "$p" != "2" ]
then
newfs /dev/rdsk/c1t4d0s$p < /dev/null
mount /dev/dsk/c1t4d0s$p /mnt
cd /mnt
ufsdump 0uf - /dev/dsk/c1t0d0s$p | ufsrestore rf -
cd /
umount /mnt
fi
done
mount /dev/dsk/c1t4d0s0 /mnt
installboot /usr/platform/`uname -i`/lib/fs/ufs/bootblk \
/dev/rdsk/c1t4d0s0
umount /mnt
exit 0
How to CLONE AN IRIX SYSTEM DISK. I use IRIX-disk cloning as a backup strategy. It is a bit expensive perhaps because I have to keep 2 SCSI disks (cloned copies of my combined user/root disk) in the closet as backups. In the list below I assume you are running your IRIX system on (i.e. booted from) disk #1 and you want to clone it to spare disk #3. The first time (with an uninitialised disk) cloning takes about 10 steps. A second time (when the disk is already prepared), one may start at step 7 to make a backup-clone.
1) BECOME SUPERUSER:
su
2) FIRST THOROUGHLY TEST THE DRIVE THAT HAS TO BECOME THE CLONE:
fx -x
fx: "device-name" = (dksc)
fx: ctlr# = (0)
fx: drive# = (1) 3
fx: lun# = (0)
fx> exercise
fx/exercise> butterfly
modifier = (rd-only) wr-cmp
starting block# = (0)
nblocks = (143374744)
nscans = (1)
about to destroy data on disk dksc(0,3,0)! ok? yes
..
..
label info has changed for disk dksc(0,3,0).
write out changes? yes
exit
3) ADD SGI LABEL:
fx -x
fx: "device-name" = (dksc)
fx: ctlr# = (0)
fx: drive# = (1) 3
fx: lun# = (0)
auto
about to destroy data on disk dksc(0,3,0)! ok? yes
(Several tests... may take a long long time, you can
abort them.)
exit
It is perhaps easier to do this via the Disk Manager desktop-interface: just initialise the disk. This only takes a few seconds and also puts a SGI label on the disk.
4) MAKE ROOTDRIVE PARTITIONING: List the disk partitioning of the system (root) disk:
prtvtoc
List the disk partitioning of the option disk that is to be the clone:
prtvtoc /dev/rdsk/dks0d3vh
Compare the disk partitioning of the two disks. They must have the same layout for the root and (if used) the usr partition. If they are not the same, repartition the option disk to match the system disk. In the easiest case:
fx "dksc(0,3)"
repartition
rootdrive
type of data partition = (xfs)
..
exit
Then compare the prtvtoc outputs again. 5) ADD STAND-ALONE SHELL (AND OTHER PROGRAMS) TO VOLUME HEADER: If necessary, first copy the appropriate sash (on your systemdisk, SCSI ID=1) to the /stand directory:
dvhtool /dev/rdsk/dks0d1vh (CAREFUL!)
vd (volume directory)
l (list)
g sash /stand/sash_Octane
g ide /stand/ide_Octane
g IP30prom /stand/IP30prom_Octane
quit
Then add the required programs to a volume header:
dvhtool /dev/rdsk/dks0d3vh (SCSI ID=3)
vd (volume directory)
l (list)
a /stand/sash_Octane sash (add to volume header)
a /stand/ide_Octane ide
a /stand/IP30prom_Octane IP30prom
l
quit
write
quit
6) MAKE FILESYSTEM: To make an XFS root filesystem with a 4 KB block size and a 1000 block internal log (the default values), give this command:
mkfs /dev/dsk/dks0d3s0
7) SWITCH TO SINGLE USER MODE AND MOUNT:
single
mkdir /clone
mount /dev/dsk/dks0d3s0 /clone
cd /clone
8) XFSDUMP:
xfsdump -l 0 - / | xfsrestore - .
Notice the 0, it is a NULL character, not an O!
9) UNMOUNT AND SHUTDOWN:
cd ..
umount /clone
rmdir /clone
shutdown
10) TEST Swap drives (in an Octane) and try if your clone is really bootable.
