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.

link|improve this question
feedback

2 Answers

Look at /proc/scsi/scsi, which will look something like this:

$ cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: ST3250823AS      Rev: 3.03
  Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: ST3750528AS      Rev: CC44
  Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: ATA      Model: ST3750330AS      Rev: SD1A
  Type:   Direct-Access                    ANSI SCSI revision: 05
Host: scsi10 Channel: 00 Id: 00 Lun: 00
  Vendor: WDC WD20 Model: EARS-00MVWB0     Rev:     
  Type:   Direct-Access                    ANSI SCSI revision: 02

scsi0 id 0 is sda and ata1.00, scsi1 id 0 is sdb and ata2.00, etc.

Also look at /var/log/dmesg, which shows the ata driver loading info and will make things a little clearer. Look for the line starting "libata".

link|improve this answer
You might also need to use 'lsscsi' - which gives a slightly more human friendly output - e.g. [0:0:0:0] cd/dvd TSSTcorp CDDVDW SH-S202H SB00 /dev/sr0 [2:0:0:0] disk ATA ST3500630AS 3.AA /dev/sda [3:0:0:0] disk ATA WDC WD5000AAKS-0 01.0 /dev/sdb (On this server, running a 3.2.x kernel, there is no /proc/scsi*) (Sorry, I Can't seem to figure out how to get any formatting into the above, to make it readable) – GingerDog May 21 at 11:12
feedback

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 ls -l /sys/dev/block reveals that 8:0 (major:minor from /dev entry) points to /sys/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda Likewise, ls -l /sys/class/ata_port reveals that ata1 points to /sys/devices/pci0000:00/0000:00:1f.2/ata1/ata_port/ata1 which is on the same PCI sub-device.

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 /sys/dev/block/ listing. If you have multiple ataX/ and hostY/ folders in the same PCI device folder, then I suspect that the lowest numbered ataX folder matches the lowest numbered hostY folder.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.