5

How can I list scsi device ids under Linux?

  • 3
    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). – Caleb Jun 17 '11 at 11:04
  • SCSI ID is not precisely defined thing, reference this discussion yarchive.net/comp/linux/scsi_ids.html – catpnosis Jan 30 '16 at 17:55
4

cat /proc/scsi/scsi
  • This does not show which SCSI ids correspond to which system devices. – catpnosis Jan 30 '16 at 17:04
7

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]
  • 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. – Caleb Jun 17 '11 at 19:01
  • 5
    To add, modern lsblk -S can show HOST:CHANNEL:TARGET:LUN numbers too. – catpnosis Jan 30 '16 at 17:46
4

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

  • 1
    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 Jan 30 '16 at 17:35
  • Actually, lsscsi --scsi_id shows scsi-* matching id from /dev/disk/by-id (if present). – catpnosis Jan 30 '16 at 17:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.