LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Red Hat (http://www.linuxquestions.org/questions/red-hat-31/)
-   -   Mapping /proc/scsi/scsi entries with respective device names in /dev/ directory (http://www.linuxquestions.org/questions/red-hat-31/mapping-proc-scsi-scsi-entries-with-respective-device-names-in-dev-directory-874293/)

neo3matrix 04-11-2011 07:31 AM

Mapping /proc/scsi/scsi entries with respective device names in /dev/ directory
 
Hello friends,

In my understanding, the way /proc/scsi/scsi gets populated, /proc/paritions also gets populated in the same fashion. i.e. the description for first entry of /proc/scsi/scsi can be seen in the first entry of /proc/partitions and same for rest.

So, With this assumption, in my project, I used to relate first entry of /proc/scsi/scsi with first entry of /proc/partitions to get its total size and same for all entries.

But, I observed some differences in following scenario, where

1) The first 4 entries in /proc/scsi/scsi are SAN luns attached to my system and for which the actual device names in /dev/ are sda,sdb,sdc and sdd.

2) The last 4 entries are the internal HDDs on same system. In /dev/, their respective device names are sde,sdf,sdg & sdh.

(Output attached at end of the thread)

But in /proc/partitions, the device order is different.

You can see their respective sizes in /proc/partition output as well.

So, my question is, in this particular scenario, I can't relate the first entry of /proc/scsi/scsi with first entry of /proc/partition.
i.e. scsi0:00:00:00 is not /dev/sde, because it is actually /dev/sda.

It seems that my assumption is wrong in this scenario.

Is there any way or mechanism to figure out actual device name for an entry in /proc/scsi/scsi in /dev/ directory?

How can my application should relate /proc/scsi/scsi entries with their respective device names and sizes?

Thanks in advance.



[root@rh12 ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: DGC Model: RAID 5 Rev: 0220
Type: Direct-Access ANSI SCSI revision: 04
Host: scsi0 Channel: 00 Id: 00 Lun: 01
Vendor: DGC Model: RAID 5 Rev: 0220
Type: Direct-Access ANSI SCSI revision: 04
Host: scsi0 Channel: 00 Id: 00 Lun: 02
Vendor: DGC Model: RAID 5 Rev: 0220
Type: Direct-Access ANSI SCSI revision: 04
Host: scsi0 Channel: 00 Id: 00 Lun: 03
Vendor: DGC Model: RAID 5 Rev: 0220
Type: Direct-Access ANSI SCSI revision: 04
Host: scsi4 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: GB0160CAABV Rev: n/a
Type: Direct-Access ANSI SCSI revision: 05
Host: scsi4 Channel: 00 Id: 01 Lun: 00
Vendor: ATA Model: GB0160CAABV Rev: n/a
Type: Direct-Access ANSI SCSI revision: 05
Host: scsi5 Channel: 00 Id: 00 Lun: 00
Vendor: ATA Model: GB0160CAABV Rev: n/a
Type: Direct-Access ANSI SCSI revision: 05
Host: scsi5 Channel: 00 Id: 01 Lun: 00
Vendor: ATA Model: GB0160CAABV Rev: n/a
Type: Direct-Access ANSI SCSI revision: 05




[root@rh12 ~]# cat /proc/partitions
major minor #blocks name

8 64 156290904 sde
8 65 30720000 sde1
8 66 2048000 sde2
8 67 7168000 sde3
8 80 156290904 sdf
8 81 30720000 sdf1
8 82 6144000 sdf2
8 48 2097152 sdd
8 49 1466331 sdd1
8 0 2097152 sda
8 1 1466331 sda1
8 112 156290904 sdh
8 113 7168000 sdh1
8 96 156290904 sdg
8 97 6144000 sdg1
8 98 7168000 sdg2
8 32 2097152 sdc
8 33 1466331 sdc1
8 16 2097152 sdb
8 17 1466331 sdb1

smallpond 04-17-2011 04:17 PM

Quote:

Originally Posted by neo3matrix (Post 4320882)
Hello friends,

In my understanding, the way /proc/scsi/scsi gets populated, /proc/paritions also gets populated in the same fashion. i.e. the description for first entry of /proc/scsi/scsi can be seen in the first entry of /proc/partitions and same for rest.

This seems wrong. There is no relationship between SCSI devices and partitions. You can have SCSI devices like tape drives that have no partitions, and SCSI disks with multiple partitions.

Quote:

So, With this assumption, in my project, I used to relate first entry of /proc/scsi/scsi with first entry of /proc/partitions to get its total size and same for all entries.
snip
Quote:

Is there any way or mechanism to figure out actual device name for an entry in /proc/scsi/scsi in /dev/ directory?
Again, there is no 1:1 relationship between SCSI devices and devs. One device may result in multiple devs. Another device may have no driver on your system, so how would it have a dev?

Quote:

How can my application should relate /proc/scsi/scsi entries with their respective device names and sizes?
One thing you can do is install lsscsi, which will show you one line per dev, and the corresponding H:C:T:L which is the SCSI address of the device.

Code:

Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: DGC Model: RAID 5 Rev: 0220
Type: Direct-Access ANSI SCSI revision: 04

shoule give you a line like
Code:

[0:0:0:0]    disk    DGC    RAID 5    0220    /dev/sde

neo3matrix 04-21-2011 07:56 AM

Hi smallpond,
Thank you very much for reply.
Got many things cleared from your reply.

Will use "lsscsi" for my application.



Thanks a lot for help....
:)


All times are GMT -5. The time now is 03:31 PM.