#!/bin/sh # # Clone a disk format. This can be useful when setting up # a bunch of new disks, or when setting up a disk that will # be a mirror of an existing disk. # # NOTE: This program assumes that the source and destination # disk drives are the exact same make and model. # # Andy Welter # www.the-welters.com # 1/4/2001 # SOURCE=$1 DEST=$2 echo "Copy format from $SOURCE to $DEST" echo "Are you sure that $DEST is not in use? [y|n]" read ANS if [ "$ANS" != "y" ]; then echo "Exiting." exit 1 fi if [ ! -h /dev/dsk/${SOURCE}s0 -a \ ! -h /dev/dsk/${SOURCE}s0 ]; then echo "no such disk" fi FORMATDAT="/tmp/format.dat.$$" FORMATBAK="/tmp/format.dat.$DEST.bak" if [ -f $FORMATDAT -o \ -f $FORMATBAK ]; then echo "$FORMATDAT or $FORMATBAK already exists" exit 1 fi echo "Saving source format table..." format $SOURCE << EOF > /dev/null 2>&1 save $FORMATDAT quit EOF # # Get the disk type and partition table name from the file DNAME=`grep "^disk_type" $FORMATDAT | cut -d'"' -f2` PNAME=`grep "^partition" $FORMATDAT | cut -d'"' -f2` # # Save the old format table for the destination device echo "Saving backup copy of $DEST format table in $FORMATBAK..." format $DEST << EOF > /dev/null save $FORMATBAK quit EOF # # echo "Copy new format table to $DEST ..." format -x $FORMATDAT -t $DNAME -p $PNAME $DEST << EOF > /dev/null label y quit EOF rm $FORMATDAT echo "done."