#!/sbin/sh # # This is pre-profile script that can automatically configure LSI raid volumes # see http://docs.sun.com/app/docs/doc/817-5506/6mkv6ki8l?a=view for more details # probe_lsi() { echo "Setting up the LOG_FILE variable to /tmp/custom_probles.log..."|tee -a /tmp/custom_probes.log LOG_FILE="/tmp/custom_probes.log" echo "Initializing SI_LSI with the value no..."|tee -a ${LOG_FILE} SI_LSI=no # # check if there are any existing raid volumes # # enumerate scsi controller numbers first # echo "Getting the list of scsi controllers..."|tee -a ${LOG_FILE} RC=`cfgadm -la -s "select=type(scsi-bus),cols=ap_id"|awk '/^c.?/ {print $1}'|cut -c2` echo "Scsi controller numbers are: $RC"|tee -a ${LOG_FILE} # # get raid volumes if any # if [ "X${RC}" != "X" ]; then echo "Checking to see if there are any existing raid volumes..."|tee -a ${LOG_FILE} RV=`raidctl|awk -F":" '/c.?t.?d.?/ {print $2}'` if [ "X${RV}" = "X" ]; then echo "No existing raid volumes found"|tee -a ${LOG_FILE} else echo "Found the following volumes: ${RV}"|tee -a ${LOG_FILE} # # delete any existing raid volumes # for m in $RV; do echo "Deleting raid volume $m..."|tee -a ${LOG_FILE} raidctl -f -d $m 2>&1 |tee -a ${LOG_FILE} sleep 5 done # # verify that all volumes are deleted # echo "Checking that all raid volumes have been deleted..."|tee -a ${LOG_FILE} RV=`raidctl|awk -F":" '/c.?t.?d.?/ {print $2}'` if [ "X${RV}" = "X" ]; then echo "All raid volumes have been successfully deleted"|tee -a ${LOG_FILE} devfsadm -C 2>&1 |tee -a ${LOG_FILE} else echo "An error occured while deleting raid volumes"|tee -a ${LOG_FILE} return 1 # something went wrong! fi fi fi # # let's get the number of disks N we have # echo "Looking how may disks we have..."|tee -a ${LOG_FILE} DD=`cfgadm -la -s "select=type(disk),cols=ap_id"|awk '/^c.?::dsk/ {FS="/"; print $2}'` echo "Found disks: $DD"|tee -a ${LOG_FILE} N=`echo $DD|wc -w` echo "Total $N disks"|tee -a ${LOG_FILE} # # depending on the number of available disks, create raid stripes # if [ $N -eq 4 ]; then SA=`echo $DD|awk '{print $1, $3}'` SB=`echo $DD|awk '{print $2, $4}'` fi if [ $N -eq 6 ]; then SA=`echo $DD|awk '{print $1, $3, $5}'` SB=`echo $DD|awk '{print $2, $4, $6}'` fi if [ $N -eq 8 ]; then SA=`echo $DD|awk '{print $1, $3, $5, $7}'` SB=`echo $DD|awk '{print $2, $4, $6, $8}'` fi if [ "X${SA}" != "X" ] && [ "X${SB}" != "X" ]; then echo "Creating the first stripe with disks ${SA}..."|tee -a ${LOG_FILE} raidctl -c -f -r 0 ${SA} 2>&1|tee -a ${LOG_FILE} sleep 5 echo "Creating the second stripe with disks ${SB}..."|tee -a ${LOG_FILE} raidctl -c -f -r 0 ${SB} 2>&1|tee -a ${LOG_FILE} sleep 5 # # list our raid volumes if any # RVS=`raidctl|awk -F":" '/c.?t.?d.?/ {print $2}'` # # remove stale cX::sdY devices # echo "Refreshing the device tree..."|tee -a ${LOG_FILE} devfsadm -C echo "Getting the list of stale scsi disks..."|tee -a ${LOG_FILE} RD=`cfgadm -la -s "select=type(disk),cols=ap_id"|awk '/^c.?::sd.?/ {print $1}'` echo "Scsi disks are: $RD"|tee -a ${LOG_FILE} if [ "X${RD}" != "X" ]; then for i in $RD; do cfgadm -y -x remove_device $i done fi # # now let's label our raid volumes if they exist # if [ "X${RVS}" != "X" ]; then echo "The following raid-0 logical volumes have been created: ${RVS}"|tee -a ${LOG_FILE} for i in $RVS; do echo "Labeling the volume $i..."|tee -a ${LOG_FILE} format -d $i -f /tmp/install_config/format_commands 2>&1|tee -a ${LOG_FILE} done echo "Setting environment variable SI_LSI to yes..."|tee -a ${LOG_FILE} SI_LSI=yes echo "Exporting SI_LSI..."|tee -a ${LOG_FILE} export SI_LSI fi fi } cmp_lsi() { # probe_lsi # this call is probably not needed # because of the probe lsi line in rules file if [ "X${SI_LSI}" = "X${1}" ]; then return 0 else return 1 fi }