4

I want to detect whether a disk is attached to the correct sata-port. While lsscsi gives me some useful information about the used host, I was wondering whether the SCSI host number will always stay the same:

[0:0:0:0]    disk    ATA      2.5" SATA SSD 3M P130  /dev/sda 
[1:0:0:0]    disk    ATA      2.5" SATA SSD 3M P130  /dev/sdb 
[4:0:0:0]    disk    ATA      SATADOM D150SV-L 1209  /dev/sdc 

A small test showed that neither rebooting the system nor a removal of one of the disks affects one of the other host numbers. In addition, I found the following at http://www.tldp.org/HOWTO/SCSI-2.4-HOWTO/scsiaddr.html:

The SCSI adapter number is typically an arbitrary numbering of the adapter cards on the internal IO buses (e.g. PCI, PCMCIA, ISA etc) of the computer. [...] SCSI adapter numbers are issued by the kernel in ascending order starting with 0.

Both together leads me to the assumption that the SCSI host number should always stay the same on a system as the bus is always enumerated the same way? Is this correct?

UPDATE: It seems that attaching an ATA Pass Through (ATP) device can change the host numbers of all devices.

4
  • 1
    Yes, the bus location is consistent with the slot number; within the same firmware revision at least.
    – Chris S
    Jul 1, 2014 at 15:43
  • 4
    Don't count on this. If you want to be certain you are accessing the same disk, use its UUID. Then it doesn't matter what slot it's in. Jul 1, 2014 at 16:08
  • Agreed with Michael - Always use the uuid or one of the ids in /dev/disk/
    – ben
    Jul 1, 2014 at 16:52
  • I also thought about that, but in this particular case an application shall just be able to check whether a certain disk is still present or not. Using the host number, this application could just query for disk #N, which should be more easy to use/implement because I don't need to take care about any UUID. And it will still work if a disk is replaced (which is totally fine). Jul 2, 2014 at 7:48

1 Answer 1

2

I would never rely on the HCTL numbers to be stable. The host may change by addition of a new host or detection of a new device that will expose a new host that was unused until that moment. The kernel may have slightly different timings which will cause different hosts to be detected in a different order and devices being removed and reinserted may get different target numbers with each reinsert.

The values are only meaningful as a temporary identification but should not be used for persistent reference.

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.