Find scsi device ids under Linux?

86,511

Solution 1

cat /proc/scsi/scsi

Solution 2

I don't have /proc/scsi/scsi on my system with 2.6.39.1 kernel. I would use 'lsscsi' command:

~> lsscsi -v
[0:0:0:0]    disk    ATA      ST3500418AS      CC38  /dev/sda
  dir: /sys/bus/scsi/devices/0:0:0:0  [/sys/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0]
[1:0:0:0]    disk    ATA      WDC WD2500KS-00M 02.0  /dev/sdb
  dir: /sys/bus/scsi/devices/1:0:0:0  [/sys/devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0]

Solution 3

You can use the links in /dev/disk/by-id:

[root@krxl02cn05 by-id]# pwd
/dev/disk/by-id

[root@krxl02cn05 by-id]# ls -rtl
total 0
lrwxrwxrwx 1 root root  9 Feb 12 01:40 scsi-3600605b005d8655019aa31faf0812bae -> ../../sda
lrwxrwxrwx 1 root root 10 Feb 12 01:40 scsi-3600605b005d8655019aa31faf0812bae-part2 -> ../../sda2
lrwxrwxrwx 1 root root 10 Feb 12 01:40 scsi-3600605b005d8655019aa31faf0812bae-part1 -> ../../sda1
lrwxrwxrwx 1 root root  9 Feb 12 01:50 scsi-3600144f09a214698000054db88550008 -> ../../sdd
lrwxrwxrwx 1 root root  9 Feb 12 01:50 scsi-3600144f09a214698000054db88460007 -> ../../sdc
lrwxrwxrwx 1 root root  9 Feb 12 01:50 scsi-3600144f09a214698000054db88260006 -> ../../sdb
lrwxrwxrwx 1 root root 10 Feb 12 01:54 scsi-3600144f09a214698000054db88260006-part1 -> ../../sdb1
lrwxrwxrwx 1 root root 15 Feb 12 04:56 scsi-3600144f09a214698000054db88460007-part1 -> ../../asm-disk1
lrwxrwxrwx 1 root root 15 Feb 12 04:59 scsi-3600144f09a214698000054db88550008-part1 -> ../../asm-disk2

So, the scsi id of /dev/sdc is 3600144f09a214698000054db88460007

Share:
86,511
LanceBaynes
Author by

LanceBaynes

Updated on September 18, 2022

Comments

  • LanceBaynes
    LanceBaynes over 1 year

    How can I list scsi device ids under Linux?

    • tcoolspy
      tcoolspy almost 13 years
      Please take my previous comment about how to ask good questions seriously! Drop the "hi" and "thanks", make sure the first few lines or the question introduce the question instead of being meta data so that the home page summaries are useful, and always show what attempts you have made to solve problems yourself. I answered this question by copy and pasting a bit of it into google and copy and pasting a bit from the result summaries back to you (after checking it in my terminal).
    • catpnosis
      catpnosis over 8 years
      SCSI ID is not precisely defined thing, reference this discussion yarchive.net/comp/linux/scsi_ids.html
  • tcoolspy
    tcoolspy almost 13 years
    2.6.38.6 here and I do have it. I wonder if there is a kernel config option for providing that interface. The reference I found to using that proc entry was as old as the hills. Also my distro doesn't have lsscsi by default although I see there is an optional package for it.
  • catpnosis
    catpnosis over 8 years
    This does not show which SCSI ids correspond to which system devices.
  • catpnosis
    catpnosis over 8 years
    Incorrectly downvoted answer. by-id shows WWID which is valid SCSI identificator, even though by-id not necessarily shows all disks. Sometimes, /dev/disk/by-path can show SCSI Ids too. Example ls -l /dev/disk/by-path outputs pci-0000:00:07.1-scsi-1:0:0:0 -> ../../sr0. So, sr0 have SCSI Host:BUS:Target_ID:LUN 1:0:0:0. This is not SCSI disk, though.
  • catpnosis
    catpnosis over 8 years
    To add, modern lsblk -S can show HOST:CHANNEL:TARGET:LUN numbers too.