Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Getting stuff like this in the logs:

Oct  2 22:11:21 jupiter kernel: [439646.093111] ata4.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x6
Oct  2 22:11:21 jupiter kernel: [439646.093144] ata4.00: BMDMA stat 0x6
Oct  2 22:11:21 jupiter kernel: [439646.093176] ata4.00: failed command: WRITE DMA EXT
Oct  2 22:11:21 jupiter kernel: [439646.093206] ata4.00: cmd 35/00:98:00:0d:ff/00:02:42:00:00/e0 tag 0 dma 339968 out
Oct  2 22:11:21 jupiter kernel: [439646.093282] ata4.00: status: { DRDY ERR }
Oct  2 22:11:21 jupiter kernel: [439646.093306] ata4.00: error: { ICRC ABRT }
Oct  2 22:11:21 jupiter kernel: [439646.093353] ata4: soft resetting link
Oct  2 22:11:21 jupiter kernel: [439646.265242] ata4.00: configured for UDMA/133
Oct  2 22:11:21 jupiter kernel: [439646.265268] ata4: EH complete

Now I wonder which disk to replace. But I can't find any clear mapping between "ataX.YZ" and /dev/disk/ entries.

share|improve this question

3 Answers 3

up vote 3 down vote accepted
  • You should get more information from dmesg:

    dmesg | grep ata
    

    Something like:

    [    2.345126] ata2.00: ATA-8: WDC WD20EARX-00PASB0, 51.0AB51, max UDMA/133
    

    That would be my Wester Digital hard drive.


  • Here's a way if you have multiple drives of one model (when above won't help):

    1. Find a mapping from SCSI host to the ata* ID:

      $ egrep "^[0-9]{1,}" /sys/class/scsi_host/host*/unique_id
      /sys/class/scsi_host/host0/unique_id:1
      /sys/class/scsi_host/host1/unique_id:2
      /sys/class/scsi_host/host2/unique_id:3
      /sys/class/scsi_host/host3/unique_id:4
      
    2. Find a mapping from the SCSI host to the sd* ID:

      $ ls -l /sys/block/sd*
      ... /sys/block/sda -> ../devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda
      ... /sys/block/sdb -> ../devices/pci0000:00/0000:00:1f.2/host1/target1:0:0/1:0:0:0/block/sdb
      

    Now you can link those two results via the host* identifier. So if in that case I'm getting problems with ata2, I'd look for the unique_id 2 → host1, and then which sd* is host1 → sdb.


  • I also tried to come up with a one-liner. No idea if that's robust. You first have to set the ata* as a variable:

    FAIL=ata1
    

    then run:

    echo "$FAIL -> $(ls -l /sys/block/ | grep $(grep "^$(echo $FAIL | cut -c 4-)" /sys/class/scsi_host/host*/unique_id | sed "s/.*\(host[0-9]\{1,\}\).*/\1/") | awk '{print $8}')"
    

    which should return something like:

    ata1 -> sda
    
share|improve this answer
    
Based on your post, I created a script github.com/hydrogen18/ata2dev –  Eric Urban Dec 11 '13 at 2:05

In some of my servers I've two or more devices on one scsi_host. I don't know if it is correct but I assumed that it can be distingushed by target and it works for me:

ls -l /sys/block/sd*
lrwxrwxrwx 1 root root 0 2012-02-08 08:15 /sys/block/sda -> ../devices/pci0000:00/0000:00:01.0/0000:01:00.0/host3/target3:0:0/3:0:0:0/block/sda
lrwxrwxrwx 1 root root 0 2012-02-08 08:15 /sys/block/sdb -> ../devices/pci0000:00/0000:00:1f.2/host6/target6:0:0/6:0:0:0/block/sdb
lrwxrwxrwx 1 root root 0 2012-02-08 08:15 /sys/block/sdc -> ../devices/pci0000:00/0000:00:1f.2/host7/target7:0:0/7:0:0:0/block/sdc
lrwxrwxrwx 1 root root 0 2012-02-08 08:15 /sys/block/sdd -> ../devices/pci0000:00/0000:00:1f.2/host8/target8:0:0/8:0:0:0/block/sdd
lrwxrwxrwx 1 root root 0 2012-02-08 08:15 /sys/block/sde -> ../devices/pci0000:00/0000:00:1f.2/host9/target9:0:0/9:0:0:0/block/sde
lrwxrwxrwx 1 root root 0 2012-02-08 08:15 /sys/block/sdf -> ../devices/pci0000:00/0000:00:1f.2/host10/target10:0:0/10:0:0:0/block/sdf
lrwxrwxrwx 1 root root 0 2012-02-08 08:15 /sys/block/sdg -> ../devices/pci0000:00/0000:00:1f.2/host11/target11:0:0/11:0:0:0/block/sdg
lrwxrwxrwx 1 root root 0 2012-02-08 08:15 /sys/block/sdh -> ../devices/pci0000:00/0000:00:1c.4/0000:04:00.0/host13/target13:0:0/13:0:0:0/block/sdh
lrwxrwxrwx 1 root root 0 2012-02-08 08:15 /sys/block/sdi -> ../devices/pci0000:00/0000:00:1c.4/0000:04:00.0/host13/target13:0:1/13:0:1:0/block/sdi

Simple bash script:

#!/bin/bash

#inspired by http://askubuntu.com/questions/64351/how-to-match-ata4-00-to-the-apropriate-dev-sdx-or-actual-physical-disk

for d in /sys/block/sd*
do
  s=`basename $d`
  h=`ls -l $d | egrep -o "host[0-9]+"`
  t=`ls -l $d | egrep -o "target[0-9:]*"`
  a2=`echo $t | egrep -o "[0-9]:[0-9]$" | sed 's/://'`
  a=`cat /sys/class/scsi_host/$h/unique_id`
  echo "$s -> ata$a.$a2"
done

and it's output:

sda -> ata4.00
sdb -> ata7.00
sdc -> ata8.00
sdd -> ata9.00
sde -> ata10.00
sdf -> ata11.00
sdg -> ata12.00
sdh -> ata14.00
sdi -> ata14.01
share|improve this answer

Far too late now, but for the sake of other readers... I had to respond to your other question "Now I wonder which disk to replace."

The ICRC error flag is almost always associated with a bad SATA cable, this is easy to replace/test. It is slightly possible to raise the ICRC flag if power to the drive is faulty.

What is certain though, is that there is NO evidence of anything wrong with the drive! Replace its SATA cable.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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