* Script to save array info
@ 2012-06-20 23:21 Wakko Warner
2012-06-21 7:20 ` Phil Turmel
2012-06-21 14:26 ` Jose Manuel dos Santos Calhariz
0 siblings, 2 replies; 5+ messages in thread
From: Wakko Warner @ 2012-06-20 23:21 UTC (permalink / raw)
To: linux-raid
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.
--
Microsoft has beaten Volkswagen's world record. Volkswagen only created 21
million bugs.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Script to save array info
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
1 sibling, 0 replies; 5+ messages in thread
From: Phil Turmel @ 2012-06-21 7:20 UTC (permalink / raw)
To: linux-raid
On 06/21/2012 01:21 AM, 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.
You might try "lsdrv"[1]. It reports the entire block storage tree
starting from real devices with serial numbers. I tuck away a copy any
time I change a server's drive setup.
Phil
[1] http://github.com/pturmel/lsdrv
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Script to save array info
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
2012-06-21 21:37 ` Wakko Warner
1 sibling, 1 reply; 5+ messages in thread
From: Jose Manuel dos Santos Calhariz @ 2012-06-21 14:26 UTC (permalink / raw)
To: linux-raid
[-- 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 --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Script to save array info
2012-06-21 14:26 ` Jose Manuel dos Santos Calhariz
@ 2012-06-21 21:37 ` Wakko Warner
2012-06-22 11:50 ` Jose Manuel dos Santos Calhariz
0 siblings, 1 reply; 5+ messages in thread
From: Wakko Warner @ 2012-06-21 21:37 UTC (permalink / raw)
To: Jose Manuel dos Santos Calhariz; +Cc: linux-raid
Jose Manuel dos Santos Calhariz wrote:
> 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.
I've looked into /sys/block/md*/md before. I've noticed there is
information not present in the output.
I just checked. About the only thing important to me would be the "name"
that mdadm -E lists. I don't know how important UUIDs would be but it could
be.
Looks like your script does essentially this one liner:
find /sys/block/md*/md -type f | xargs grep .
I didn't run it though. I think yours added the ls -l of the rdX/block/
link.
I looked through everything in the block for some of my devices and none had
the serial number. I had to use scsi_id from udev to get it.
One thing you might want to do to yours is "exec >> ${FILEMD}" instead of all
the >> ${FILEMD} that you had in your file.
--
Microsoft has beaten Volkswagen's world record. Volkswagen only created 22
million bugs.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Script to save array info
2012-06-21 21:37 ` Wakko Warner
@ 2012-06-22 11:50 ` Jose Manuel dos Santos Calhariz
0 siblings, 0 replies; 5+ messages in thread
From: Jose Manuel dos Santos Calhariz @ 2012-06-22 11:50 UTC (permalink / raw)
To: linux-raid
[-- Attachment #1: Type: text/plain, Size: 2261 bytes --]
On Thu, Jun 21, 2012 at 05:37:00PM -0400, Wakko Warner wrote:
> Jose Manuel dos Santos Calhariz wrote:
> > 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.
>
> I've looked into /sys/block/md*/md before. I've noticed there is
> information not present in the output.
>
> I just checked. About the only thing important to me would be the "name"
> that mdadm -E lists. I don't know how important UUIDs would be but it could
> be.
>
> Looks like your script does essentially this one liner:
> find /sys/block/md*/md -type f | xargs grep .
>
> I didn't run it though. I think yours added the ls -l of the rdX/block/
> link.
> I looked through everything in the block for some of my devices and none had
> the serial number. I had to use scsi_id from udev to get it.
Good points, my script is a fragment of a bigger script to collect
information about a system. In my bigger script:
- I get the UUID of the raid by running "mdadm --detail" for all
/dev/md*.
- I get the serial number by running "smartctl -a" for all disks and
collect health information too.
>
> One thing you might want to do to yours is "exec >> ${FILEMD}" instead of all
> the >> ${FILEMD} that you had in your file.
>
Jose Calhariz
--
--
Ambição: um supremo desejo de ser vilipendiado por seus inimigos enquanto você está vivo e ser ridicularizado pelos amigos quando estiver morto
--Ambrose Bierce
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-06-22 11:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2012-06-21 21:37 ` Wakko Warner
2012-06-22 11:50 ` Jose Manuel dos Santos Calhariz
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).