Sun Cluster 2.2 Software Installation Guide

B.2.7 DID Conversion Script

If you have a previously generated md.tab file to convert to use disk IDs, you can use the script in Example B-1 to help with the conversion. The script checks the md.tab file for physical device names, such as /dev/dsk/c0t0d0 or c0t0d0, and converts these names to the full DID name, such as /dev/did/rdsk/d60.


Example B-1 md.tab Conversion Script

more phys_to_did
 #! /bin/sh
 #
 # ident "@(#)phys_to_did        1.1     98/05/07 SMI"
 #
 # Copyright (c) 1997-1998 by Sun Microsystems, Inc.
 # All rights reserved.
 #
 # Usage: phys_to_did <md.tab filename>
 # Converts $1 to did-style md.tab file.
 # Writes new style file to stdout.

 MDTAB=$1
 TMPMD1=/tmp/md.tab.1.$$
 TMPMD2=/tmp/md.tab.2.$$
 TMPDID=/tmp/didout.$$

 # Determine whether we have a "physical device" md.tab or a "did" md.tab.
 # If "physical device", convert to "did".
 grep "\/dev\/did" $MDTAB > /dev/null 2>&1
 if [ $? -eq 0 ]; then
         # no conversion needed
         lmsg=`gettext "no conversion needed"`
         printf "${lmsg}\n"
         exit 0
 fi

 scdidadm -l > $TMPDID
 if [ $? -ne 0 ]; then
         lmsg=`gettext "scdidadm -l failed"`
         printf "${lmsg}\n"
         exit 1
 fi

 cp $MDTAB $TMPMD1

 ...
 ...
 # Devices can be specified in md.tab as /dev/rdsk/c?t?d? or simply c?t?d?
 # There can be multiple device names on a line.
 # We know all the possible c.t.d. names from the scdidadm -l output.

 # First strip all /dev/*dsk/ prefixes.
 sed -e 's:/dev/rdsk/::g' -e 's:/dev/dsk/::g' $TMPMD1 > $TMPMD2

 # Next replace the resulting physical disk names "c.t.d." with
 # /dev/did/rdsk/<instance>
 exec < $TMPDID
 while read instance fullpath fullname
 do
         old=`basename $fullpath`
         new=`basename $fullname`
         sed -e 's:'$old':/dev/did/rdsk/'$new':g' $TMPMD2 > $TMPMD1
         mv $TMPMD1 $TMPMD2
 done

 cat $TMPMD2
 rm -f $TMPDID $TMPMD1 $TMPMD2

 exit 0