SUMMARY: sdA -> cXtYdZ

From: Bobby Krupczak (rdk@cc.gatech.edu)
Date: Tue Jan 24 1995 - 08:50:00 CST


Hi!

I posted a while ago asking about how one goes about converting scsi devices
'sdA' to the Solaris/V.4 naming convention -- mainly, cXtYdZ.

I got a lot of replies; few answered the questions. Perhaps thats because I
didnt clearly articulate it. I knew what the cXtYdZ format was; I was really
asking how one derives X, Y, and Z from A.

Anyway, Im including the replies below; proceeding them is the real answer I
discovered through a long and arduous process. No code though but Ill describe
the general approach.

First, the kernel keeps a tree data structure of devices and their relationships.
For example, scsi-devices (sd) are stored in the tree before their controller
(esp) devices. One can traverse the device tree and discover all the 'sd' nodes.
Each 'sd' node contains a pointer to a scsi_device structure which will give you
that device's target and address (or lun). Now, the problem is to find the
controller number for that 'sd' node's parent 'esp'. One can simply use the
instance number of the parent 'esp' node. Instead, one should cross reference
that 'esp' node with table of esp entries the kernel keeps in a different area.
That table keeps 'esp' entries in order by their controller number. Once one
does all this, one can programmatically determine cXtYdZ from sdA.

Thanks to all who sent replies!

Bobby

Date: Thu, 19 Jan 1995 15:58:21 -0500
From: Curt Freeland <curt@ecn.purdue.edu>
To: rdk@cc.gatech.edu
Subject: Re: Converting from sdX -> ctYdZsA
Newsgroups: comp.unix.solaris
References: <3fmdq4$421@gomez.cc.gatech.edu>
X-Newsreader: NN version 6.5.0 (NOV)
Status: RO

In comp.unix.solaris you write:

>Hi!

>Solaris's new disk naming facility specifies that disks are named ctYdZsA (or
>something to that affect where Y,Z, and A are significant).

>However, the underlying device info given via sysdef still reports sdX. Does
>anyone know of a systematic manner to convert from sdX to the ctYDzSa format?

>(I have tried several angles and have seen machines that dont conform to my
>theories).

>Ill summarize in a future posting any answers I receive.

>Thanks,

>Bobby

Ah, yes the secret alphabet soup to sd decoder ring.....Too bad Sun doesn't
sell one!

The C# is the controller number
The T# is the target (SCSI address/ID) of the disk(s) on that controller.
The D# is the address of the disk on that ID (for example ESDI can have 2 disks on
                                              one ID. Usually you will see d0 here)
The S# is the partition or slice of the disk.

Each controller reserves room for 7 disks.
On the on-board controller "C0 or ESP0", these will be sd0 through sd6
(targets 0 through 6).

Controller "1" has room for 7 more disks. This controller is usually C1 and ESP1
Controller "2" has room for 7 more disks. This controller is usually C2 and ESP2

You get the picture. Now comes the "screwy" part...

You would think that the "sd" numbers would correspond consecutively with the
esp/C# scheme. They don't. Apparently "on board controller" disks get assigned
first, then when all "on-board" is done, then the disks connected to Sbus add-in
cards get assigned consecutively by slot number.

On our Sparc 1000's with 4 SCSI adapters, this is how things end up:

Master CPU board on-board SCSI is ESP0 and C0
        The drives are sd0 target 0 c0t0d0s{0,1,2,3,4,5,6,7}
        The drives are sd1 target 1 c0t1d0s{0,1,2,3,4,5,6,7}
        The drives are sd2 target 2 c0t2d0s{0,1,2,3,4,5,6,7}
        The drives are sd3 target 3 c0t3d0s{0,1,2,3,4,5,6,7}
        The drives are sd4 target 4 c0t4d0s{0,1,2,3,4,5,6,7}
        The drives are sd5 target 5 c0t5d0s{0,1,2,3,4,5,6,7}
        The drives are sd6 target 6 c0t6d0s{0,1,2,3,4,5,6,7}
FSBE board in Sbus slot 1 is ESP1 and C1
        The drives are sd15 target 0 c1t0d0s{0,1,2,3,4,5,6,7}
        The drives are sd16 target 1 c1t1d0s{0,1,2,3,4,5,6,7}
        The drives are sd17 target 2 c1t2d0s{0,1,2,3,4,5,6,7}
        The drives are sd18 target 3 c1t3d0s{0,1,2,3,4,5,6,7}
        The drives are sd20 target 5 c1t5d0s{0,1,2,3,4,5,6,7}
FSBE board in sbus slot 2 is ESP2 and C2
        The drives are sd30 target 0 c2t0d0s{0,1,2,3,4,5,6,7}
        The drives are sd31 target 1 c2t1d0s{0,1,2,3,4,5,6,7}
        The drives are sd32 target 2 c2t2d0s{0,1,2,3,4,5,6,7}
        The drives are sd33 target 3 c2t3d0s{0,1,2,3,4,5,6,7}
        The drives are sd34 target 4 c2t4d0s{0,1,2,3,4,5,6,7}
        The drives are sd35 target 5 c2t5d0s{0,1,2,3,4,5,6,7}
Slave CPU board on-board SCSI is ESP3 and C3
        The drives are sd7 target 0 c3t0d0s{0,1,2,3,4,5,6,7}
        The drives are sd8 target 1 c3t1d0s{0,1,2,3,4,5,6,7}
        The drives are sd9 target 2 c3t2d0s{0,1,2,3,4,5,6,7}
        The drives are sd10 target 3 c3t3d0s{0,1,2,3,4,5,6,7}
        The drives are sd11 target 4 c3t4d0s{0,1,2,3,4,5,6,7}
        The drives are sd12 target 5 c3t5d0s{0,1,2,3,4,5,6,7}

I am sure that *somewhere* there is a system that defies the numbering scheme that
we have observed. YMMV, lower in the land of fruits and nuts...

--curt

-- 
Curt Freeland
Manager, Systems Engineering
Purdue University Engineering Computer Network
(curt@ecn.purdue.edu) (317) 494-3715(voice) / (317) 494-6440(fax)

>From gavin@durban.vector.co.za Fri Jan 20 02:24:15 1995 Received: from burdell.cc.gatech.edu (root@burdell.cc.gatech.edu [130.207.3.207]) by morticia.cc.gatech.edu (8.6.9/8.6.9) with ESMTP id CAA24365 for <rdk@morticia.cc.gatech.edu>; Fri, 20 Jan 1995 02:24:04 -0500 Received: from durban (durban.vector.co.za [192.96.167.201]) by burdell.cc.gatech.edu (8.6.9/8.6.9) with ESMTP id CAA22419 for <rdk@cc.gatech.edu>; Fri, 20 Jan 1995 02:25:38 -0500 Received: from durban (localhost [127.0.0.1]) by durban (8.6.9/8.6.9) with SMTP id JAA03467 for <rdk@cc.gatech.edu>; Fri, 20 Jan 1995 09:25:28 +0200 Message-Id: <199501200725.JAA03467@durban> From: Gavin Maltby <gavin@durban.vector.co.za> Date: Fri, 20 Jan 95 09:25:29 200 Sender: gavin@durban.vector.co.za To: rdk@cc.gatech.edu Mime-Version: 1.0 X-Mailer: Mozilla/0.96 Beta (X11; SunOS 5.4 sun4m) Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Subject: c?t?d?s? etc X-URL: news:3fmdq4$421@gomez.cc.gatech.edu Status: RO

Hi,

there is a script in Adrian Cockcroft's new book that achieves this. It is messy!

An easier way is to look at the minor device number of the device node, divide by 8 and ignore remainder. The result gives you the x in sdx.

e.g., ls -lL /dev/dsk/c1t3d0s?

brw-r----- 1 root sys 32, 80 Sep 9 17:23 /dev/dsk/c1t3d0s0 brw-r----- 1 root sys 32, 81 Sep 9 17:23 /dev/dsk/c1t3d0s1 brw-r----- 1 root sys 32, 82 Sep 9 17:23 /dev/dsk/c1t3d0s2 brw-r----- 1 root sys 32, 83 Sep 9 17:23 /dev/dsk/c1t3d0s3 brw-r----- 1 root sys 32, 84 Sep 9 17:23 /dev/dsk/c1t3d0s4 brw-r----- 1 root sys 32, 85 Sep 9 17:23 /dev/dsk/c1t3d0s5 brw-r----- 1 root sys 32, 86 Sep 9 17:23 /dev/dsk/c1t3d0s6 brw-r----- 1 root sys 32, 87 Sep 9 17:23 /dev/dsk/c1t3d0s7

{80-87} / 8 = 10, so this is sd10

Cheers

Gavin

>From plocher@attaboy.Eng.Sun.COM Fri Jan 20 01:53:40 1995 Received: from burdell.cc.gatech.edu (root@burdell.cc.gatech.edu [130.207.3.207]) by morticia.cc.gatech.edu (8.6.9/8.6.9) with ESMTP id BAA24211 for <rdk@morticia.cc.gatech.edu>; Fri, 20 Jan 1995 01:53:33 -0500 Received: from Sun.COM (koriel.Sun.COM [192.9.9.64]) by burdell.cc.gatech.edu (8.6.9/8.6.9) with SMTP id BAA21845 for <rdk@cc.gatech.edu>; Fri, 20 Jan 1995 01:55:04 -0500 Received: from Eng.Sun.COM (zigzag.Eng.Sun.COM) by Sun.COM (sun-barr.Sun.COM) id AA26048; Thu, 19 Jan 95 22:54:56 PST Received: from attaboy.eng.sun.com by Eng.Sun.COM (4.1(1/24/94)/SMI-4.1) id AA17676; Thu, 19 Jan 95 22:54:55 PST Received: by attaboy.eng.sun.com (5.x/SMI-SVR4) id AA26796; Thu, 19 Jan 1995 22:51:01 -0800 Date: Thu, 19 Jan 1995 22:51:01 -0800 From: plocher@attaboy.Eng.Sun.COM (John Plocher (PADI AI-85274)) Message-Id: <9501200651.AA26796@attaboy.eng.sun.com> To: rdk@cc.gatech.edu (Bobby Krupczak) Subject: Re: Converting from sdX -> ctYdZsA Newsgroups: comp.unix.solaris X-Newsreader: TIN [version 1.2 PL2] Status: RO

This is not an "easy" solution, but the following should work:

Look in /etc/path_to_inst to find the instance number for a specific device.

Look at the output of prtconf (&& -v) to find the device's base name (esp, le, sd...) and the "/devices" path.

Match the two up and combine the device name ("sd") and the instance number ("2") to get something like

/iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@2,0 => sd2

-John

In article <3fmdq4$421@gomez.cc.gatech.edu> you wrote:

: Hi!

: Solaris's new disk naming facility specifies that disks are named ctYdZsA (or : something to that affect where Y,Z, and A are significant).

: However, the underlying device info given via sysdef still reports sdX. Does : anyone know of a systematic manner to convert from sdX to the ctYDzSa format?

: (I have tried several angles and have seen machines that dont conform to my : theories).

: Ill summarize in a future posting any answers I receive.

: Thanks,

: Bobby

-- John Plocher | PADI | "I've heard that television adds 10 pounds to @ Scuba.Net | DM/AI | your usual body weight. Why and where?

>From jworache@uns-dv1.jcpenney.com Fri Jan 20 08:58:57 1995 Received: from burdell.cc.gatech.edu (root@burdell.cc.gatech.edu [130.207.3.207]) by morticia.cc.gatech.edu (8.6.9/8.6.9) with ESMTP id IAA25208 for <rdk@morticia.cc.gatech.edu>; Fri, 20 Jan 1995 08:58:53 -0500 Received: from jcpenney.com (hermes.jcpenney.com [146.235.0.65]) by burdell.cc.gatech.edu (8.6.9/8.6.9) with SMTP id JAA08807 for <rdk@cc.gatech.edu>; Fri, 20 Jan 1995 09:00:29 -0500 Received: from uns-dv1.jcpenney.com by jcpenney.com (5.0/SMI-SVR4) id AA04243; Fri, 20 Jan 1995 07:57:05 -0600 Received: by uns-dv1.jcpenney.com (5.0/SMI-SVR4) id AA21194; Fri, 20 Jan 1995 07:59:59 +0600 Date: Fri, 20 Jan 1995 07:59:59 +0600 From: jworache@uns-dv1.jcpenney.com (John R Worachek) Message-Id: <9501201359.AA21194@uns-dv1.jcpenney.com> To: rdk@cc.gatech.edu Subject: Re: Converting from sdX -> ctYdZsA Content-Length: 763 Status: RO

drives:

#!/bin/csh foreach file ( /dev/dsk/*0 ) echo -n $file " "; whatdrive $file end

whatdrive:

#!/bin/csh # print out the drive name - st0 or sd0 - given the /dev entry # first get something like "/iommu/.../.../sd@0,0" set dev = `/bin/ls -l $1 | nawk '{ n = split($11, a, "/"); split(a[n],b,":"); for(i = 4; i < n; i++) printf("/%s",a[i]); printf("/%s\n", b[1]) }'` if ($dev == "") exit # echo $dev # then get the instance number and concatenate with the "sd" nawk -v dev=$dev '$1 ~ dev { n = split(dev, a, "/"); split(a[n], b, "@"); printf("%s%s\n", b[1], $2) }' /etc/path_to_inst

These are in Adrian Cockroft's Sun Performance and Tuning for Sparc and Solaris. Definitely a recommended book to any Sun System Administrator.

-John Worachek JCPenney

>From mayhew@knoxdist.East.Sun.COM Thu Jan 19 19:20:26 1995 Received: from burdell.cc.gatech.edu (root@burdell.cc.gatech.edu [130.207.3.207]) by morticia.cc.gatech.edu (8.6.9/8.6.9) with ESMTP id TAA23181 for <rdk@morticia.cc.gatech.edu>; Thu, 19 Jan 1995 19:20:22 -0500 Received: from Sun.COM (Sun.COM [192.9.9.1]) by burdell.cc.gatech.edu (8.6.9/8.6.9) with SMTP id TAA29225 for <rdk@cc.gatech.edu>; Thu, 19 Jan 1995 19:22:00 -0500 Received: from East.Sun.COM (east.East.Sun.COM) by Sun.COM (sun-barr.Sun.COM) id AA26928; Thu, 19 Jan 95 16:21:58 PST Received: from knoxdist.East.Sun.COM by East.Sun.COM (4.1/SMI-4.1) id AA25742; Thu, 19 Jan 95 19:21:57 EST Received: from mountaineer.East.Sun.COM by knoxdist.East.Sun.COM (5.0/SMI-5.3-900117) id AA02921; Thu, 19 Jan 1995 19:24:25 +0500 Received: by mountaineer.East.Sun.COM (SMI-8.6.9/SMI-SVR4) id TAA00345; Thu, 19 Jan 1995 19:21:52 -0500 Date: Thu, 19 Jan 1995 19:21:52 -0500 From: mayhew@knoxdist.East.Sun.COM (Randy.Mayhew@East) Message-Id: <199501200021.TAA00345@mountaineer.East.Sun.COM> To: rdk@cc.gatech.edu Subject: Re: Hi, question X-Sun-Charset: US-ASCII Content-Length: 253 Status: RO

take a look at /etc/path_to_inst ... "/iommu@f,e0000000/sbus@f,e0001000/espdma@f,400000/esp@f,800000/sd@2,0" 2 ...

the sd@2,0 => is target 2 on controller 0, for example

do a man on path_to_inst. That might be what you're lookin' for.

HTH, -randy

>From phess@dawn.Corp.Sun.COM Thu Jan 19 18:10:04 1995 Received: from burdell.cc.gatech.edu (root@burdell.cc.gatech.edu [130.207.3.207]) by morticia.cc.gatech.edu (8.6.9/8.6.9) with ESMTP id SAA23004 for <rdk@morticia.cc.gatech.edu>; Thu, 19 Jan 1995 18:09:58 -0500 Received: from Sun.COM (Sun.COM [192.9.9.1]) by burdell.cc.gatech.edu (8.6.9/8.6.9) with SMTP id SAA23821 for <rdk@cc.gatech.edu>; Thu, 19 Jan 1995 18:11:35 -0500 Received: from Corp.Sun.COM ([129.145.35.78]) by Sun.COM (sun-barr.Sun.COM) id AA12770; Thu, 19 Jan 95 15:11:17 PST Received: from dawn.Corp.Sun.COM (dawn-bb) by Corp.Sun.COM (4.1(1/24/94)/elliemay (corpmail1 inbound)) id AA02441; Thu, 19 Jan 95 15:11:05 PST Received: from loknar.Corp.Sun.COM by dawn.Corp.Sun.COM (5.0/SMI-SVR4) id AA18930; Thu, 19 Jan 1995 15:11:03 +0800 Received: by loknar.Corp.Sun.COM (5.0/SMI-SVR4) id AA02319; Thu, 19 Jan 1995 15:10:31 -0800 Date: Thu, 19 Jan 1995 15:10:31 -0800 From: phess@dawn.Corp.Sun.COM (Patrick Hess) Message-Id: <9501192310.AA02319@loknar.Corp.Sun.COM> To: rdk@cc.gatech.edu Subject: Re: Converting from sdX -> ctYdZsA Newsgroups: comp.unix.solaris In-Reply-To: <3fmdq4$421@gomez.cc.gatech.edu> Content-Length: 457 Status: RO

Bobby,

Here goes... The "new" disk naming scheme is actually the old way that flat SysV AT&T did it. This kinda makes sense since Solaris 2.X is SysV based and SunOS was BSD based. Here is how you look at it:

c0t3d0s0 /\/\/\/\ | | | ---- slice 0 (same as BSD partition "a") | | ------ disk 0 (same as the LUN from SunOS) |--------- target 3 (this is the SCSI ID) ---------- controller 0 (SCSI controller)

I hope that helps.

Pat

>From jworache@uns-dv1.jcpenney.com Fri Jan 20 09:22:09 1995 Received: from burdell.cc.gatech.edu (root@burdell.cc.gatech.edu [130.207.3.207]) by morticia.cc.gatech.edu (8.6.9/8.6.9) with ESMTP id JAA25286 for <rdk@morticia.cc.gatech.edu>; Fri, 20 Jan 1995 09:22:05 -0500 Received: from jcpenney.com (hermes.jcpenney.com [146.235.0.65]) by burdell.cc.gatech.edu (8.6.9/8.6.9) with SMTP id JAA10453 for <rdk@cc.gatech.edu>; Fri, 20 Jan 1995 09:22:35 -0500 Received: from uns-dv1.jcpenney.com by jcpenney.com (5.0/SMI-SVR4) id AA08509; Fri, 20 Jan 1995 08:19:08 -0600 Received: from prolog.uns.jcpenney.com by uns-dv1.jcpenney.com (5.0/SMI-SVR4) id AA22384; Fri, 20 Jan 1995 08:22:02 +0600 Received: by prolog.uns.jcpenney.com (5.0/SMI-SVR4) id AA02558; Fri, 20 Jan 1995 08:22:01 +0600 Date: Fri, 20 Jan 1995 08:22:01 +0600 From: jworache@uns-dv1.jcpenney.com (John R Worachek) Message-Id: <9501201422.AA02558@prolog.uns.jcpenney.com> To: rdk@cc.gatech.edu Subject: Re: Converting from sdX -> ctYdZsA X-Sun-Charset: US-ASCII Content-Length: 1495 Status: RO

Your right

----- Begin Included Message -----

>From rdk@cc.gatech.edu Fri Jan 20 08:16 CST 1995 From: rdk@cc.gatech.edu (Bobby Krupczak) Subject: Re: Converting from sdX -> ctYdZsA To: jworache@uns-dv1.jcpenney.com (John R Worachek) Date: Fri, 20 Jan 1995 09:17:05 -0500 (EST)

Hi!

Thanks for the reply.

My solaris machine is at home so Ill give this a whirl later today. I think Ill go out and buy that book as well.

It appears, though, that the scheme below does the reverse? It converts /dev/dsk/cXtYdZ to /iommu/blah and then /dev/sdA? I guess I can work backwards if I must. I want to encode this in a C program.

Am I totally off base?

Thanks,

Bobby

>drives: > >#!/bin/csh >foreach file ( /dev/dsk/*0 ) >echo -n $file " "; whatdrive $file >end > > >whatdrive: > >#!/bin/csh ># print out the drive name - st0 or sd0 - given the /dev entry ># first get something like "/iommu/.../.../sd@0,0" >set dev = `/bin/ls -l $1 | nawk '{ n = split($11, a, "/"); split(a[n],b,":"); for(i = 4; i < n; i++) printf("/%s",a[i]); printf("/%s\n", b[1]) }'` >if ($dev == "") exit ># echo $dev ># then get the instance number and concatenate with the "sd" >nawk -v dev=$dev '$1 ~ dev { n = split(dev, a, "/"); split(a[n], b, "@"); printf("%s%s\n", b[1], $2) }' /etc/path_to_inst > > >These are in Adrian Cockroft's Sun Performance and Tuning for Sparc and Solaris. >Definitely a recommended book to any Sun System Administrator. > >-John Worachek >JCPenney > >

----- End Included Message -----



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:14 CDT