Solaris 移行ガイドで次のことを見つけました。
"インスタンス名
インスタンス名は、システム内の n 番目のデバイスを参照します (たとえば、sd20)。
インスタンス名は、ドライバーのエラー メッセージで報告されることがあります。dmesg(1M)
次の例のように、出力を確認することで、インスタンス名と物理名のバインディングを判断できます。
sd9 at esp2: target 1 lun 1
sd9 is /sbus@1,f8000000/esp@0,800000/sd@1,0
<SUN0424 cyl 1151 alt 2 hd 9 sec 80>
インスタンス名がデバイスに割り当てられると、そのデバイスにバインドされたままになります。
インスタンス番号は、デバイスのマイナー番号でエンコードされます。再起動後もインスタンス番号の一貫性を維持するために、システムはそれらを /etc/path_to_inst ファイルに記録します。このファイルは起動時に読み取り専用で、現在は更新されておりadd_drv(1M)
、drvconf
"
それを踏まえて、以下のスクリプトを書きました。
/dev/dsk/*s2 のデバイス用
行う
dpath="$(ls -l $device | nawk '{print $11}')"
dpath="${dpath#*devices/}"
dpath="${dpath%:*}"
iname="$(nawk -v dpath=$dpath '{
if ($0 ~ dpath) {
gsub("\"", "", $3)
print $3 $2
}
}' /etc/path_to_inst)"
echo "$(basename ${device}) = ${iname}"
終わり
By reading the information directly out of the path_to_inst file, we are allowing for adding and deleting devices, which will skew the instance numbers if you simply count the instances in the /devices directory tree.