LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices

Reply
 
LinkBack Search this Thread
Old 04-11-2011, 06:31 AM   #1
neo3matrix
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Rep: Reputation: 0
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
 
Old 04-17-2011, 03:17 PM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: Fedora
Posts: 1,160

Rep: Reputation: 258Reputation: 258Reputation: 258
Quote:
Originally Posted by neo3matrix View Post
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
 
Old 04-21-2011, 06:56 AM   #3
neo3matrix
LQ Newbie
 
Registered: Nov 2009
Posts: 8

Original Poster
Rep: Reputation: 0
Smile

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....
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQUEEZE: cat: /proc/scsi/scsi: No such file or directory alexneil Debian 5 05-04-2010 01:53 PM
CDROM found in /proc/scsi/scsi but no /dev entry. Trying to make livecd. simonb Linux - Hardware 1 11-29-2008 04:05 AM
Hotplug SCSI scanner or How to write to /proc/scsi/scsi from within a shell script. samac Linux - Hardware 1 08-30-2004 02:28 PM
Some info about '/proc/scsi/scsi' and '/dev' C.Loko Slackware 4 11-27-2003 12:30 PM
physical scsi channel mapping to scsiX device node mapping, how to configure manually drthornt Linux - Hardware 3 02-09-2003 11:50 AM


All times are GMT -5. The time now is 07:41 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration