Find sdx device/ATAx mappings

When dealing with hardware, you often see messages in the logs about disk issues or warnings.
Messages like:

 
ata9: hard resetting link
ata9: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
ata9.00: configured for UDMA/33
ata9: EH complete
 
 
ata3: SATA max UDMA/133 abar [email protected] port 0xf7d36100 irq 28
ata4: DUMMY
ata7: SATA max UDMA/133 abar [email protected] port 0xf7d36300 irq 28
ata8: DUMMY
 
 
ata9: SATA max UDMA/133 abar [email protected] port 0xf7c10100 irq 16
ata10: SATA max UDMA/133 abar [email protected] port 0xf7c10180 irq 16
ata3: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
ata3.00: ACPI cmd f5/00:00:00:00:00:00 (SECURITY FREEZE LOCK) filtered out
ata3.00: ACPI cmd b1/c1:00:00:00:00:00 (DEVICE CONFIGURATION OVERLAY) filtered out
ata3.00: ATA-8: Corsair Force GS, 5.07, max UDMA/133
ata3.00: 250069680 sectors, multi 16: LBA48 NCQ (depth 31/32), AA
ata3.00: ACPI cmd f5/00:00:00:00:00:00 (SECURITY FREEZE LOCK) filtered out
ata3.00: ACPI cmd b1/c1:00:00:00:00:00 (DEVICE CONFIGURATION OVERLAY) filtered out
ata3.00: configured for UDMA/133
 
 
ata10: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
 

To find out to which "sdx" device the "ata" number is referring to, you can run:

 
ls -l /sys/block/sd* | sed -e 's^.*-> \.\.^/sys^' -e 's^/host^ ^' -e 's^/target.*/^ ^' | while read Path HostNum ID; do echo ${ID}: $(cat $Path/host$HostNum/scsi_host/host$HostNum/unique_id); done
 

NB: One liners are potentially destructive. Don't run anything unless you fully understand it.

Hope it helps!
Andrea

PS: I did not write this one-liner. I found it somewhere a while ago. Unfortunately I can't remember the source, but I thought it could be useful to others

Leave a Reply

Your email address will not be published.