Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    LUN device mapping

    what's up everyone. I am having an issue that I hope you can help with. I need determine which LUN (from an external fibre array) is mounted to a specific device in RHEL 3.

    /proc/scsi/scsi shows me the available luns
    fdisk -l shows me the physical volumes/devices

    but nowhere can I see the correlation between the both of the them

    if /dev/sdd1 is using LUN 4, then I want to know that

    Any help would be greatly appreciated.


  2. #2
    Linux Enthusiast scientica's Avatar
    Join Date
    Sep 2003
    South- or "Mid-" Sweden
    Maybe sg3-utils is what you look, for, the sg_scan gives nice output, look here for example:

    oh, btw, if you're compiling you'r own kernel, don't forget to make sure the Query all LUNs option under SCSI is set to 'y' - or you'll only seen the one attached to LUN=0 (I've had this problem myself - took a while to figure out)

    Quote Originally Posted by
    Use the sg3-utils package to determine the device name of your USB Mass Storage Device:
    • Install the sg3-utils package (e.g. apt-get install sg3-utils)
    • List your raw SCSI devices by running sg_scan -i. The output will look something like this:
      /dev/sg0: scsi0 channel=0 id=0 lun=0 [em] type=5
      MATSHITA CD-RW CW-7585 1.01 [wide=0 sync=1 cmdq=0 sftre=0 pq=0x0A]
      /dev/sg1: scsi1 channel=0 id=0 lun=0 [em] type=0
      SanDisk ImageMate CF-SM 0100 [wide=0 sync=0 cmdq=0 sftre=0 pq=0x0]
      /dev/sg2: scsi1 channel=0 id=0 lun=1 [em] type=0
      SanDisk ImageMate CF-SM 0100 [wide=0 sync=0 cmdq=0 sftre=0 pq=0x0]
    • This tells me that I have 3 SCSI devices on my system: My CD-RW drive, and two Sandisk ImageMate devices (it's a single hardware device, but the first slot is the CF card reader, and the second is the SM card reader)
    • Determine the real SCSI device associated with your USB Mass Storage Device with sg_map. The output looks like:
      /dev/sg0 /dev/scd0
      /dev/sg1 /dev/sda
      /dev/sg2 /dev/sdb
    • Now we can match the results of these last two steps. For example my Compact Flash reader is on the /dev/sda device.
    • In most cases, USB Mass Storage Devices will only have one partition on them, so we can safely assume that the final, mountable device is /dev/sda1 (the first partition on /dev/sda).
    Regards Scienitca (registered user #335819 - )
    A master is nothing more than a student who knows something of which he can teach to other students.

  3. #3
    Old posts are usefull... Thank you.

    Folowing this, I found the solution, with only one sg command :

    [root@pouetpouet ~]# sg_map -x
    /dev/sg0 0 0 0 0 0 /dev/sda
    /dev/sg1 0 0 1 0 0 /dev/sdb
    /dev/sg2 0 0 2 0 0 /dev/sdc

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts