Linux RAID subsystem development
 help / color / mirror / Atom feed
From: John Robinson <john.robinson@anonymous.org.uk>
To: "Mathias Burén" <mathias.buren@gmail.com>
Cc: Linux-RAID <linux-raid@vger.kernel.org>
Subject: Re: Possible HDD error, how do I find which HDD it is?
Date: Sat, 19 Feb 2011 15:37:58 +0000	[thread overview]
Message-ID: <4D5FE3D6.8070006@anonymous.org.uk> (raw)
In-Reply-To: <AANLkTimV8-mciW_9z_=U_-uYLvKp7Rbh0V1N0mr7rh8v@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 827 bytes --]

On 19/02/2011 11:52, Mathias Burén wrote:
[...]
> What I wonder is, how do I know what device is ata3? I do have 4
> devices of that model (WD20EARS). I've tried searching in /sys but
> there's nothing of value there (or I've missed it). If dmesg only
> showed the S/N...
> I posted the smartctl --all output of all devices here in case someone
> has time to take a look:
> http://stuff.dyndns.org/logs/smart-sd[a,b,c,d,e,f,g].log

Try using Phil Turmel's excellent lsdrv script; I've attached the 
version I use on EL5, but I hacked it about to work on such an old 
distro so I wouldn't swear it will work on more recent distros; Phil's 
original that does work on more recent distros can be found in the list 
archives around 6 November last year in the thread "Determining which 
spindle is out of order".

Cheers,

John.


[-- Attachment #2: lsdrv --]
[-- Type: text/plain, Size: 1890 bytes --]

#! /bin/bash
#
# Examine specific system host devices to identify the drives attached
#

function describe_controller () {
	local device driver modprefix serial slotname
	driver="`readlink -f \"$1/driver\"`"
	driver="`basename $driver`"
	modprefix="`cut -d: -f1 <\"$1/modalias\"`"
	echo "Controller device @ ${1##/sys/devices/} [$driver]"
	if [[ "$modprefix" == "pci" ]] ; then
		slotname="`basename \"$1\"`"
		echo "  `lspci -s $slotname |cut -d\  -f2-`"
		return
	fi
	if [[ "$modprefix" == "usb" ]] ; then
		if [[ -f "$1/busnum" ]] ; then
			device="`cat \"$1/busnum\"`:`cat \"$1/devnum\"`"
			serial="`cat \"$1/serial\"`"
		else
			device="`cat \"$1/../busnum\"`:`cat \"$1/../devnum\"`"
			serial="`cat \"$1/../serial\"`"
		fi
		echo "  `lsusb -s $device` {SN: $serial}"
		return
	fi
	echo -e "  `cat \"$1/modalias\"`"
}

function describe_device () {
	local empty=1
	while read device ; do
		empty=0
		if [[ "$device" =~ ^(.+)/block[/:](.+)$ ]] ; then
			targ="${BASH_REMATCH[1]}"
			bdev="${BASH_REMATCH[2]}"
			vnd="$(< $targ/vendor)"
			mdl="$(< $targ/model)"
			sn="`sginfo -s /dev/$bdev 2>/dev/null | \
				sed -rn -e \"/Serial Number/{s%^.+' *(.+) *'.*\\\$%\\\\1%;p;q}\"`" &>/dev/null
			if [[ -n "$sn" ]] ; then
				echo -e "    $1: `echo /dev/$bdev $vnd $mdl {SN: $sn}`"
			else
				echo -e "    $1: `echo /dev/$bdev $vnd $mdl`"
			fi
		else
			echo -e "    $1: Unknown $device"
		fi
	done
	[[ $empty -eq 1 ]] && echo -e "    $1: [Empty]"
}

function check_host () {
	local found=0
	local pController=
	while read shost ; do
		host=`dirname "$shost"`
		controller=`dirname "$host"`
		bhost=`basename "$host"`
		if [[ "$controller" != "$pController" ]] ; then
			pController="$controller"
			describe_controller "$controller"
		fi
		find $host -regex '.+/target[0-9:]+/[0-9:]+/block[:/][^/]+' |describe_device "$bhost"
	done
}

find /sys/devices/ -name 'scsi_host*' |check_host


  parent reply	other threads:[~2011-02-19 15:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-19 11:52 Possible HDD error, how do I find which HDD it is? Mathias Burén
2011-02-19 14:09 ` Simon McNair
2011-02-19 15:37 ` John Robinson [this message]
2011-02-19 16:44   ` Phil Turmel
2011-02-19 17:25     ` John Robinson
     [not found]     ` <4D5FFCEC.9040207@anonymous.org.uk>
2011-02-19 18:02       ` Phil Turmel
2011-02-19 18:18         ` John Robinson
2011-02-19 20:09     ` Mathias Burén
2011-02-19 22:22       ` Phil Turmel
2011-02-19 22:30         ` Mathias Burén
2011-02-19 22:40           ` Phil Turmel
2011-02-19 23:26             ` Mathias Burén
2011-02-20  3:11             ` John Robinson
2011-02-20  3:44               ` Mathias Burén
2011-02-20  9:52         ` Simon Mcnair

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D5FE3D6.8070006@anonymous.org.uk \
    --to=john.robinson@anonymous.org.uk \
    --cc=linux-raid@vger.kernel.org \
    --cc=mathias.buren@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox