Sun Cluster 2.2 ソフトウェアのインストール

DID 変換スクリプト

ディスク ID を使用するために変換する md.tab ファイルをすでに作成している場合は、例 B-1 のスクリプトを変換に役立てることができます。このスクリプトは、/dev/dsk/c0t0d0 または c0t0d0 などの物理デバイス名が md.tab ファイルに含まれているかどうかを調べて、物理デバイス名を、/dev/did/rdsk/d60 などの完全な DID 名に変換します。


例 B-1 md.tab 変換スクリプト

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