Thursday, August 7, 2008

Map device names in Solaris

Sometimes you want to know what devices are being mapped to instance names. To do that I use this script:

#!/usr/bin/ksh

DISKS=$(/usr/bin/ls /dev/dsk/*s2)

for D in ${DISKS}
do
INST=$(/usr/bin/ls -l ${D} | /usr/bin/awk -F" " '{print $NF}' |\
/usr/bin/sed -e 's/\.\.\/\.\.\/devices//g' -e 's/:[a-z]//g')

DEV=$(/usr/bin/grep ${INST} /etc/path_to_inst | /usr/bin/sed 's/\"//g'|\
/usr/bin/awk '{print $3$2}')

echo "${DEV} ${D}"
done
You'll get something like:

sd0 /dev/dsk/c0t0d0s2
sd9 /dev/dsk/c0t10d0s2
sd10 /dev/dsk/c0t11d0s2
sd11 /dev/dsk/c0t12d0s2
sd6 /dev/dsk/c0t6d0s2
sd7 /dev/dsk/c0t8d0s2
sd8 /dev/dsk/c0t9d0s2


Also noted that SarCheck provide a similar tool called dmap, only available for SPARC. This is a script, therefore can be used on x86 and SPARC, as well as machines which are not allowed to have non supported binaries installed on them :)

But if you can install binaries on your systems, then you might want to compile your own from here .

No comments: