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.
|
|
|||||
|
|
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 UPDATES
|
|||||||||||||||||
|
|
Look at
scsi0 id 0 is sda and ata1.00, scsi1 id 0 is sdb and ata2.00, etc. Also look at |
|||||||||
|
|
I prefer scriptlets instead of lenghty explanations. This works on my Ubuntu box. Add comments to your liking:
|
||||
|
This is actually quite tricky. While it's safe to assume that "the scsi ID" is "the SATA ID minus one", I prefer to be really safe and inspect the My error was:
So my procedure to find out what
And you're done! |
|||
|
|
|
I had the same problem and was able to identify drives by checking dmesg. There you can see the controller identifier (correct term??) and the model of the disk. Then use ls -l /dev/disk/by-id to match the model number to /dev/sda (or whatever). Alternatively, I like Disk Utility for this information. Note: this only works if your disks have different model numbers, otherwise you can't distinguish between the two.
|
|||
|
|
|
The easiest way is to review the kernel log from boot, since the drive device names are mixed in from various sources (eg USB drives), or are assigned based on type of device (ie cdrom may be scdX instead, and everything has a sgX). In practice, unless you have mixed different kinds of buses (eg SATA+USB) the lowest numbered ata device is going to be sda unless it's a cdrom device. Depending on your system, it might be divined by wandering around sysfs. On my system Since I use SATA, and only one drive is on each port I can deduce that ata1.00 = sda. All of my drives are .00, I suspect that if I used a port multiplier, my drives would be given .01, .02, .03 etc. Looking at other people's logs PATA controllers use .00 and .01 for master and slave, and based on their logs if you have ataX.01, the .01 should be mapped to the "ID" in the host:channel:ID:LUN folder from the |
|||
|
|
|
Try this:
I never understood the dmesg - some rows are about "ata4" some others about "scsi" or sdc, but no one assigns "ata4 . . . sdc" the command shown finds the /sys/bus/ path, where both ata4 and sdc are specified. J. |
|||
|
|
|
The script below will give you a nice summary like this:
So in one line per drive you have sdX device name, size, model, s/n and the pci and ata numbers. The sdc above coresponds to a USB SD card reader with no card inserted. Hence the ---- in place of real information.
(only tested on ubuntu 12.04/14.04 and CentOS 6) |
|||||||||
|
|
In
The
|
|||
|
|
|
A script to find this information, and more, can be found at https://www.av8n.com/computer/disk-hw-host-bus-id It is similar to the script provided by Mr. Syntaxerror, but fancier. - It works for USB drives as well as ATA drives. - It provides the drive make and model and serial number, - and of course the attachment point. - It is more straightforward, readable, and maintainable. |
|||
|
|