Solaris instance number to device name conversion

From Brandonhutchinson.com

Jump to: navigation, search

When providing statistics on block devices in Solaris, utilities like sar and kstat return instance numbers instead of device names. Converting these to device names can be difficult, especially for NFS file systems. Example:

$ sar -d
...
          nfs1              0     0.0       0       0     0.0     0.0
          nfs2              0     0.0       0       0     0.0     0.0
          nfs3              0     0.0       0       0     0.0     0.0
          nfs4              0     0.0       0       0     0.7    19.2
          nfs5              0     0.0       0       0     2.5    15.3
...

In the above output, which file system corresponds to nfs1? To find out, we have to look at the dev= value in /etc/mnttab and perform a hexadecimal conversion. Fortunately, there is a Perl script named mapdev that performs this conversion.

Step-by-step instructions for running mapdev

In this example, I run mapdev out of my current directory. You may instead put MapDev.pm in @INC and modify the instructions accordingly.

  • Download mapdev.
  • Extract mapdev.
$ gzip -cd Solaris-0.05a.tar.gz | tar xvf -
  • Move MapDev.pm and mapdev to the current directory.
$ mv Solaris-0.05/MapDev/MapDev.pm .
$ mv Solaris-0.05/scripts/mapdev .
  • Modify mapdev. In this example, my version of perl is located in /usr/bin, not /usr/local/bin.
$ sed -e 's@#!/usr/local/bin/perl -w@#!/usr/bin/perl -w@' \
-e 's@use Solaris::MapDev qw(:ALL);@use MapDev qw(:ALL);@' mapdev > mapdev.new
$ mv mapdev.new mapdev
  • Modify MapDev.pm.
$ sed 's@package Solaris::MapDev;@package MapDev;@' MapDev.pm > MapDev.pm.new
$ mv MapDev.pm.new MapDev.pm
  • Run mapdev.
$ ./mapdev
nfs11 is an alias for fas:/vol/oradata1_pp01
nfs12 is an alias for fas:/vol/oradata2_pp01
nfs13 is an alias for fas:/vol/oradata1_sp01
nfs14 is an alias for fas:/vol/oradata2_sp01
nfs15 is an alias for fas:/vol/oradata3_pp01
nfs16 is an alias for fas:/vol/oradata3_sp01
nfs17 is an alias for fas:/vol/oradata4_pp01
nfs18 is an alias for fas:/vol/oradata4_sp01
nfs2 is an alias for hostname:vold(pid1742)
nfs21 is an alias for fass:/vol/dba_misc
sd0 is an alias for c0t0d0
sd1 is an alias for c0t1d0
sd19 is an alias for c1t4d0
  • If you would rather see local mount points instead of remote NFS resources, change line 71 in MapDev.pm from:
my ($special, $fstyp, $opt) = (split(" ", $line))[0,2,3];

To:

my ($special, $fstyp, $opt) = (split(" ", $line))[1,2,3];
$ ./mapdev
nfs11 is an alias for /oradata1/PP01
nfs12 is an alias for /oradata2/PP01
nfs13 is an alias for /oradata1/SP01
nfs14 is an alias for /oradata2/SP01
nfs15 is an alias for /oradata3/PP01
nfs16 is an alias for /oradata3/SP01
nfs17 is an alias for /oradata4/PP01
nfs18 is an alias for /oradata4/SP01
nfs2 is an alias for /vol
nfs21 is an alias for /files/files0/DBA/misc
sd0 is an alias for c0t0d0
sd1 is an alias for c0t1d0
sd19 is an alias for c1t4d0
Personal tools