Script to flash archive

Script to flash archive

Post by solari » Mon, 22 Aug 2005 17:14:28



Hi all,

I want to use the below script to automate the creation of flash
archive. I found this script in Bigadmin. I want to use this script to
do flash archive. Basically if I detach all the submirrors and update
/etc/vfstab, /etc/system and reboot (init 6), this script should remove
all the metadevices and run flash archive and create mirror.

#!/bin/sh

SOURCEDISK=c0t0d0s
DESTDISK=c0t1d0s
SLICEMIR="0 1 3 4"
NUMMETA=3
METASLICE=7
RCSCRIPT=/etc/rc3.d/S99mirrorattach

# Clear all metadevices

metadb -f -d ${SOURCEDISK}${METASLICE} ${DESTDISK}${METASLICE}

for SNUM in $SLICEMIR
do
  metaclear -r d${SNUM}
  metaclear d2${SNUM}
done

# create the flassh archive

flarcreate -n flash-archive -R / -e root-archive -x /flash -a
Administrator /flash/flash-archive

# Create $NUMMETA state database replicas on s${METASLICE}

echo "Setting DiskSuite state database replicas $NUMMETA on slice
$METASLICE"
metadb -a -f -c $NUMMETA ${SOURCEDISK}${METASLICE}
${DESTDISK}${METASLICE}

# Build metadevices and one sided mirror for $SLICEMIR
# Create rc script to attach other side of mirror after a reboot

echo "Building one side of the mirror & script to finish the other"
echo "#!/bin/sh" > $RCSCRIPT
echo "echo Completing root disk mirror" >> $RCSCRIPT
echo "echo Monitor using 'metastat -p| grep progress" >> $RCSCRIPT

for SNUM in $SLICEMIR
do
    metainit -f d1${SNUM} 1 1 ${SOURCEDISK}${SNUM}
    metainit -f d2${SNUM} 1 1 ${DESTDISK}${SNUM}
    metainit d${SNUM} -m d1${SNUM}
    echo "metattach d${SNUM} d2${SNUM}" >> $RCSCRIPT
done

echo "Mirroring root slices, use 'metastat | grep -i progress' to
monitor"
echo "rm $RCSCRIPT" >> $RCSCRIPT
chmod 755 $RCSCRIPT

# Fix /etc/vfstab & /etc/system to allow for booting from the mirror

VFSTAB=/etc/vfstab
cp $VFSTAB ${VFSTAB}.premirror
cp /etc/system /etc/system.premirror
metaroot d0
echo "set md:mirrored_root_flag=1" >> /etc/system

# Fix /etc/vfstab to allow mounting of new, partially, mirrored
metadevices

sed "s,$SOURCEDISK,d,g" $VFSTAB | sed "s,/dev/,/dev/md/,g" >
$VFSTAB.tmp
mv $VFSTAB.tmp $VFSTAB

Replacing /dev/dsk with /dev/md/dsk is not working properly. Also Can I
add the following to this scipt

locfs -fa
init 6

I want to automate everything. I dont want to login and reboot again.
Any help would be appreciated.

Thanks.