Mapping ATA to Device Name


First Get the ata # (maybe its from some error message that you see in dmesg)

The ata # is the unique_id with scsi_host

So ata # 5 is unique_id 5

Now we have to find out how ata # (or unique_id) maps to a scsi_host host number.

NOTE: the above command reads every unique_id file in all /sys/class/scsi_host/host* files and outputs it, for nice output.

Here is the ouput which shows the mapping between host number and unique_id:

So ata # 5 which is unique_id 5 is host # 4.

Mapping SCSI HOST to Device Name

So now to find out what host # 4 drive device name we run this:

NOTE: /sys/block has all of the block devices you have symlinks to their final path.

So for me host #4 is sdc.

So to summarize ata #5 is unique_id # 5 is host # 4 which is /dev/sdc.

OR ata #5 is /dev/sdc

COOL COMMAND: ata=3; ls -l /sys/block/sd* | grep $(grep ^$ata$ /sys/class/scsi_host/host*/unique_id | awk -F'/' '{print $5}')

REVERSE: device name to ata name

We can now go in reverse (using above output):

so /dev/sdb is host # 1

host # 1 is unique_id # 2

And unique_id #2 is ata 2

So /dev/sdb is ata #2

BONUS – 12 drives example – ATA to DEVICE &HOST to DEVICE maps

Here is a unit with 12 drives. It appears some drives dont need to have “ata” they can be just attached to the “scsi” drives. So some drives go from “ata”->”scsi” and some just go straight thru “scsi”.

The top command here is useful and shows how each ata device is attached to what drives.

The end

One thought on “Mapping ATA or SCSI HOST to Device Name

  1. UPDATE: ata# and host# can both map to more than 1 drive. especially if port multipliers or SAS controllers are used in the system

Leave a Reply

Your email address will not be published. Required fields are marked *