When a Linux box gets an ATA error, it syslogs it with a message identifying the disk as "ata%d.00". How do I translate that to a device name (e.g. /dev/sdb
)? I feel like this should be trivial, but I cannot figure it out.
Linux ATA errors: Translating to a device name
hard drivelinux
Best Answer
Peter inspired me to write an advanced script(let), which can even detect USB sticks (instead of outputting silly things like "ata0.00"). In contrary to Peter's script, you will also get the sub-number (as in 4.01) if you have more than one device at the same controller resp. channel. The output will be exactly as you get it in
syslog
. Tested. Working very well on my Debian box, though there is always lots of improvement (e. g. too clumsy regexps). But HOLD IT! The seemingly too high number of escaped characters you may find in my regexps is just for compatibility reasons! You can't assume GNUsed
with everyone, which is why I did without extended regexps on purpose.UPDATES
(1) Will no longer parse
ls
output. (oops!) Since you all know: Do not parse ls.(2) Now also works on read-only environments.
(3) Inspired by a suggestion from this chit-chat here I have managed to again get the sed statements way less complicated.