IRIX
Hi ,everybody. It's long time sice I came here at last time, I hope following script will be useful to everyone.
-------------------------------------------------------------------------- #!/bin/sh # program to copy root & usr partitions and create a new bootable disk # Note that this script is limited to SCSI drives, and only those # on controller 0. # It makes the root & usr filesystem on partition 0 for target drive # and install sash, ide & fx in the volume header of the target drive. # usage ./clone_disk 0 1 0 2
echo '---------------------------------------------------------------------' echo 'Note: This utility will create a bootable clone of the system disk ' echo 'on target disk and will build the target disk with an XFS filesystem.' echo '---------------------------------------------------------------------'
# needed hn=`hostname` if [ "$hn" = "" ]; then hostname IRIS fi
( versions eoe\*|grep xfs ) > /dev/null 2>&1 if [ $? -ne 0 ]; then echo The source disk does not have support for XFS echo and thus cannot be cloned by this script. exit 1 fi
if [ $# -ne 4 ] then echo "Usage: $0 source_controler source_id target_controler target_id" exit 1 fi
SRC_CON=$1 SRC_NUM=$2 TGT_CON=$3 TGT_NUM=$4
echo "\nJust checking:" echo "The source (system) disk is controler "$SRC_CON" SCSI id "$SRC_NUM" " echo "The target ( new ) disk is controler "$TGT_CON" SCSI id "$TGT_NUM" " echo "\007OK? (n)\c" read answer case "$answer" { y|Y|yes|Yes|YES) ;; *) echo "\007\n\nAbort"; exit 1;; }
echo "\nChecking SCSI disk"$TGT_NUM".." hinv -c disk | grep -s "unit $TGT_NUM on SCSI controller $TGT_CON" > /dev/null 2>&1 if [ $? -ne 0 ] then echo Sorry, SCSI disk $TGT_NUM not found on controller $TGT_CON exit 1 fi
fx -x "dksc($TGT_CON,$TGT_NUM,0)" << EOF label/create/all label/sync .. exit EOF
echo "\nStart disk clone..." umount /d mkdir /d
echo making a target filesystem with an internal log 2048 blocks long and 1 KB block size mkfs -d name=/dev/rdsk/dks"$TGT_CON"d"$TGT_NUM"s0 -l internal,size=2048b -b size=1k labelit /dev/rdsk/dks"$TGT_CON"d"$TGT_NUM"s0 / sgi mount /dev/dsk/dks"$TGT_CON"d"$TGT_NUM"s0 /d df -k echo "\ncopy root partition..." if [ "$fstype" = efs ]; then cd /; dump 0f - / | (cd /d; restore rf - ) else cd /; xfsdump -L dump -M dump -l 0 -J - / | (cd /d; xfsrestore - .) fi
fsstat /dev/usr 1> /dev/null 2>&1 stat=$? if [ $stat = 2 ] then mkdir /d/usr df -k echo "\ncopy usr partition..." if [ "$fstype" = efs ]; then cd /usr; dump 0f - /usr | (cd /d/usr; restore rf - ) else cd /usr; xfsdump -L dump -M dump -l 0 -J - /usr | (cd /d/usr; xfsrestore - .) fi fi
echo "\ninstalling sash, ide & fx in volume header....."
#create sash fx ide tmp files if [ -d /stand ]; then echo " keep going......." else mkdir /stand fi # get the current header files: /etc/dvhtool -v get sash /stand/sash /dev/rdsk/dks"$SRC_CON"d"$SRC_NUM"vh /etc/dvhtool -v get fx /stand/fx /dev/rdsk/dks"$SRC_CON"d"$SRC_NUM"vh /etc/dvhtool -v get ide /stand/ide /dev/rdsk/dks"$SRC_CON"d"$SRC_NUM"vh
# put them on the target if [ -r /stand/sash ]; then /etc/dvhtool -v c /stand/sash sash /dev/rdsk/dks"$TGT_CON"d"$TGT_NUM"vh; fi if [ -r /stand/fx ]; then /etc/dvhtool -v c /stand/fx fx /dev/rdsk/dks"$TGT_CON"d"$TGT_NUM"vh; fi if [ -r /stand/ide ]; then /etc/dvhtool -v c /stand/ide ide /dev/rdsk/dks"$TGT_CON"d"$TGT_NUM"vh; fi echo "\nNew disk number "$TGT_NUM" ready to use."