1 |
Hello, |
2 |
|
3 |
On Wed, 31 Jul 2013, Paul Hartman wrote: |
4 |
>http://serverfault.com/questions/244944/linux-ata-errors-translating-to-a-device-name |
5 |
|
6 |
All flawed IMHO. My version (works with PATA too), possibly flawed too: |
7 |
|
8 |
==== ~/bin/ataid_to_drive.sh ==== |
9 |
#!/bin/bash |
10 |
oIFS="$IFS" |
11 |
IFS=$'\n' |
12 |
CTRLS=( $(/sbin/lspci | grep 'ATA\|IDE') ) |
13 |
IFS="$oIFS" |
14 |
for arg; do |
15 |
if test -z "${arg/ata*}"; then |
16 |
arg="${arg/ata}" |
17 |
fi |
18 |
if test -z "${arg/*.*}"; then |
19 |
ata="${arg%.*}" |
20 |
subid="$(printf "%i" "${arg##*.}")" |
21 |
else |
22 |
ata="$arg" |
23 |
fi |
24 |
echo "ata${ata}${subid/*/.$(printf "%02i" $subid)} is:" |
25 |
for ctrl in ${CTRLS[@]%% *}; do |
26 |
idpath="/sys/bus/pci/devices/*${ctrl}/*/*/*/unique_id" |
27 |
grep "^${ata}$" $idpath 2>/dev/null |
28 |
host=$(grep "^${ata}$" $idpath 2>/dev/null | \ |
29 |
sed 's@.*/host\([0-9A-Fa-f]\+\)/.*@\1@') |
30 |
if test -n "$host"; then |
31 |
dmesg | grep "\] s[dr] $host:0:$subid.*Attached" |
32 |
fi |
33 |
done |
34 |
done |
35 |
==== |
36 |
|
37 |
Usage samples: |
38 |
|
39 |
$ ataid_to_drive.sh ata23.00 |
40 |
$ ataid_to_drive.sh ata23.01 |
41 |
$ ataid_to_drive.sh ata23 |
42 |
$ ataid_to_drive.sh 23.01 |
43 |
$ ataid_to_drive.sh 23.1 |
44 |
$ ataid_to_drive.sh 23 |
45 |
$ ataid_to_drive.sh $(seq 1 4) |
46 |
|
47 |
So you can use c&p from dmest/syslog or enter the number(s) yourself. |
48 |
|
49 |
HTH, |
50 |
-dnh |
51 |
|
52 |
-- |
53 |
This space intentionally left aligned. |