Professional Documents
Culture Documents
/usr/bin/ksh
#################################################
#
#
#
# Changed: 8/27/2007 - vfstab is updated when mirrors are
created.
# Reboot will mount the mirrored devices. Then final step
# is to run the script again with a '-a' to attach the
mirrors.
# Create Solaris Volumes and mirrors...
# Assumptions: Two Indentical disks
# System defined disk0 and disk1 will be used
# This script will mirror currently mounted disks.
# Modify this as needed...
# Note: The meta devices used will be:
# d1# = Primary disk
# d2# = Secondary/Mirror disk
# d3# = Mirrored Metadevice
#
# i.e. d10 = /dev/dsk/c1d0s0 = /
# d20 = /dev/dsk/c1d1s0 = / mirror
# d30 = /dev/dsk/d30 mounted as /
#
# Note: This script must run twice. Once/First time
# setup of the metadevices the second time {after a reboot}
# attaches the mirrored devices.
#
# Works on both Sparc and X86 Hardware.
#
#========================================================
#- Get boot drive
#========================================================
Slices=`grep \/dev\/dsk /etc/vfstab | awk '{print $1}' | awk -F/
'{print $4}' | awk -Fs '{print $2}'`
#========================================================
##- Get drive to mirror
#========================================================
#========================================================
##- Get boot and mirror device info for eeprom
#========================================================
bootdevice=`ls -al /dev/rdsk/$bootdrive2 | awk '{print $11}' | sed -e
's/\.//g' | sed -e 's/\/\///g' | sed -e 's/sd/disk/g' | sed -e
's/devices\///g' | sed -e 's/\:c\,raw/\//g' `
mirrordevice=`ls -al /dev/rdsk/$mirrordrive2 | awk '{print $11}' | sed
-e 's/\.//g' | sed -e 's/\/\///g' | sed -e 's/sd/disk/g' | sed -e
's/devices\///g' | sed -e 's/\:c\,raw/\//g' `
#echo $bootdevice
#echo $mirrordevice
if [ "$1" != "-a" ]
then
printf "\nAdd additional slices? y/n: "
read answer
if [ "$metadbslice" ]
then
echo "Metadb will be installed onto slice $metadbslice"
else
metadbslice=7 # Default slice for metadb.
fi
#========================================================
#- Display current disks to be used
#========================================================
printf "\nContinue... [y/n] -: "
read x
#========================================================
#- Make sure you really want run this again
#========================================================
fi
if [ -f /root/mksvm.mark ]
then
printf "\n\nAlready ran $0 once want to run it again? y/n : "
read x
if [ $x = y -o $x = Y ]
then
echo " "
else
exit
fi
else
touch /root/mksvm.mark
[ "$1" != "-a" ] && printf "Remember to run mksvm.sh -a to attach and
sync mirrors.\n"
fi
#========================================================
##- Duplicate bootdisk layout with mirror drive
##- Attach mirrors...
#========================================================
if [ "$1" = "-a" ]
then
echo "Attaching the second submirror... Please wait..."
if [ -f /etc/vfstab.new ]
then
rm /etc/vfstab.new
fi
eeprom boot-device
eeprom use-nvramrc?
eeprom nvramrc
fi
exit
else
# Verify changes
sleep 10
mirnum=`metastat | grep Mirror | wc -l`
sleep 3
metaroot d0
metainit hsp001
lockfs -fa
ls -l /dev/rdsk/${mirrordrive2}
echo " "
cp /etc/vfstab /etc/vfstab.original
cp /etc/vfstab /etc/vfstab.orig
cp /etc/vfstab /etc/vfstab.bak
echo "To auto-attach mirrors and setup rootmirror for booting run this
$0 again with -a switch."
echo "i.e. $0 -a"
sleep 15
init 6
else
clear
fi