From: Jose Manuel dos Santos Calhariz <jose.spam@netvisao.pt>
To: linux-raid@vger.kernel.org
Subject: Re: Script to save array info
Date: Thu, 21 Jun 2012 15:26:13 +0100 [thread overview]
Message-ID: <20120621142613.GA28130@calhariz.com> (raw)
In-Reply-To: <20120620232149.GA7767@animx.eu.org>
[-- Attachment #1: Type: text/plain, Size: 2042 bytes --]
On Wed, Jun 20, 2012 at 07:21:49PM -0400, Wakko Warner wrote:
> After reading some of the stories about lost metadata, I was wondering if
> anyone had a script that would output the member info for each device with
> the device's physical serial number.
>
> For a crude one I did this while in /sys/block:
> for x in sd*;do
> echo /dev/$x
> /lib/udev/scsi_id --export --page=0x80 --whitelisted /dev/$x
> mdadm -E /dev/$x
> done
>
> And saved the output. It works for me because all but 3 of my raid members
> are full disks.
>
I made a script for myself, that collects the information by
inspecting /sys instead of doing mdadm -E. The script see all mdraid
devices and all devices that belong to a mdraid. I would like to know
if the script works or not. It works for me.
#!/bin/bash
# $1 - procfile
# $2 - File to log
function cat-file () {
echo $1 >> $2
if [ -e $1 ] ; then
${CAT} $1 >> $2
else
echo "$1 don't exist" >> $2
fi
echo >> $2
}
FILEMD=md-list
echo "Get slot positions of the devices in mdraid" >> ${FILEMD}
for file in /sys/block/md* ; do
echo $file >> ${FILEMD}
for dev in $file/md/rd* ; do
echo $dev >> ${FILEMD}
ls -alF $dev >> ${FILEMD}
done
echo >> ${FILEMD}
done
echo "Get more info about devices in mdraid" >> ${FILEMD}
# get info about all devices that are in a mdraid.
# similar to mdadm --examine ?
for file in /sys/block/md* ; do
echo $file >> ${FILEMD}
for dev in $file/md/rd* ; do
echo $dev >> ${FILEMD}
ls -alF $dev >> ${FILEMD}
for fi in $dev/* ; do
if test `basename $fi` = "block"; then
ls -alF $fi >> ${FILEMD}
else
cat-file $fi ${FILEMD}
fi
done
echo >> ${FILEMD}
done
echo >> ${FILEMD}
done
--
--
Jose Calhariz
A coisa mais difícil de entender no mundo é o imposto de renda
--Albert Einstein
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2012-06-21 14:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-20 23:21 Script to save array info Wakko Warner
2012-06-21 7:20 ` Phil Turmel
2012-06-21 14:26 ` Jose Manuel dos Santos Calhariz [this message]
2012-06-21 21:37 ` Wakko Warner
2012-06-22 11:50 ` Jose Manuel dos Santos Calhariz
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=20120621142613.GA28130@calhariz.com \
--to=jose.spam@netvisao.pt \
--cc=linux-raid@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).