Script to save array info
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.
Signature · 2 lines
Microsoft has beaten Volkswagen's world record. Volkswagen only created 21 million bugs.
Quoted 6 lines · Wakko Warner
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
Quoted 7 lines
echo /dev/$x /lib/udev/scsi_id --export --page=0x80 --whitelisted /dev/$x mdadm -E /dev/$xdone
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
Quoted 6 lines · Wakko Warner
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
Quoted 8 lines
echo /dev/$x /lib/udev/scsi_id --export --page=0x80 --whitelisted /dev/$x mdadm -E /dev/$xdone
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}
doneSignature · 7 lines
--
Jose Calhariz
A coisa mais difícil de entender no mundo é o imposto de renda
--Albert EinsteinQuoted 12 lines · Jose Manuel dos Santos Calhariz
Quoted 11 lines · Wakko Warner
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*;doecho /dev/$x /lib/udev/scsi_id --export --page=0x80 --whitelisted /dev/$x mdadm -E /dev/$xdone
Quoted 7 lines
Quoted 2 lines
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.
Signature · 2 lines
Microsoft has beaten Volkswagen's world record. Volkswagen only created 22 million bugs.
Quoted 28 lines · Wakko Warner
Quoted 12 lines · Jose Manuel dos Santos Calhariz
Quoted 11 lines · Wakko Warner
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*;doecho /dev/$x /lib/udev/scsi_id --export --page=0x80 --whitelisted /dev/$x mdadm -E /dev/$xdone
Quoted 7 lines
Quoted 2 lines
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*/mdbefore. 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.
Quoted 7 lines
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 usescsi_idfrom 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.
Quoted 4 lines
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
Signature · 5 lines
-- 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