Thanks to an answer on "unix.stackexchange.com" for the question "How to map ataX.0 identifiers in kern.log error messages to actual /dev/sdY devices?", I've found ways of getting this mapping.
Option 1: Grepping the kern.log
If "$date" is set the the date-string that the lines in the kernel log start with, on the day your system booted, you will get a listing which "ataX" should match which "/dev/sdX":
Code: Select all
zgrep "$date" /var/log/kern.log* | \
grep 'ata[0-9]\+.[0-9][0-9]: ATA' | \
sed 's/^.*\] ata//' | \
sort -n | sed 's/:.*//' | \
awk ' { a="ata" $1; printf("%10s is /dev/sd%c\n", a, 96+NR); }'
1) You need to know/set the string when your system booted. In the original script posted on stackexchange.com, it tries to "guess" the right date string. That failed on my setup, so the version I post here, requires you to set "$date" manually. For example: "date="Apr 8"
NOTE: It must exactly match the string as written in the kernel logs.
2) It only works for <= 26 disks, because of the way the final "printf()" translates the drives' numeric index to a character - which only works for a single character (a-z), but fails for additional drives which start at "/dev/sdaa" and so on.
Option 2: Using the "lsscsi" command
This is also mentioned on the stackexchange answer, but there it's not clarified how to read lsscsi's output in order to map it to "ataX", but I think I've figured it out.
For example, the output of "lsscsi" on Debian 7 on a backblaze pod v3, looks like this:
If I'm not mistaken, the first digit of the [x:y:0:0] string at the beginning of each line, "x" represents the ATA index, and "y" the drive. Both starting at "0".[0:0:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sda
[0:1:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdb
[0:2:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdc
[0:3:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdd
[0:4:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sde
[2:0:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdf
[2:1:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdg
[2:2:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdh
[2:3:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdi
[2:4:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdj
[3:0:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdk
[3:1:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdl
[3:2:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdm
[3:3:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdn
[3:4:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdo
[4:0:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdp
[4:1:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdq
[4:2:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdr
[4:3:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sds
[4:4:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdt
[6:0:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdu
[6:1:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdv
[6:2:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdw
[6:3:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdx
[6:4:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdy
[7:0:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdz
[7:1:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdaa
[7:2:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdab
[7:3:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdac
[7:4:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdad
[8:0:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdae
[8:1:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdaf
[8:2:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdag
[8:3:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdah
[8:4:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdai
[10:0:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdaj
[10:1:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdak
[10:2:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdal
[10:3:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdam
[10:4:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdan
[11:0:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdao
[11:1:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdap
[11:2:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdaq
[11:3:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdar
[11:4:0:0] disk ATA WDC WD30EFRX-68E 80.0 /dev/sdas
[12:0:0:0] disk ATA SanDisk SD6SB1M1 X211 /dev/sdat
[13:0:0:0] disk ATA SanDisk SD6SB1M0 X230 /dev/sdau
Therefore, "ata1.00" = [0:0:0:0], "ata1.01" = [0:1:0:0], "ata2.01" = [1:1:0:0], etc.
For example:
So, if you're looking for "ata4.01" for example, that would be: [3:1:0:0].
I think this approach is better than grepping the kernel log, which seems a bit fragile to me.