Commit 034ec122 authored by Vinicius Ruoso's avatar Vinicius Ruoso

Fixed the way to discover witch device is out of raid

Based on the /sys/block information, we will always get the correct
information of the raid state.
Signed-off-by: default avatarVinicius Ruoso <vkr07@c3sl.ufpr.br>
parent cb1ec7d3
......@@ -509,18 +509,26 @@ elif grep -q "_" /proc/mdstat; then
else
for MDSTAT in $(grep '_' /proc/mdstat |cut -db -f1); do
# get the out off array disk
if grep -B1 $MDSTAT /proc/mdstat |head -1 |grep -q sda; then
DISK=sdb
else
DISK=sda
fi
# get the current array and partition
MD=$(grep -B1 $MDSTAT /proc/mdstat |head -1 |cut -d\ -f1)
PARTITION=$(grep -B1 $MDSTAT /proc/mdstat|head -1| \
sed -e "s/.*raid1 sd.\([0-9]\).*/\1/")
# discover witch disk are not sync on this md array
DEVICES="$(ls /sys/block/${MD}/md/ | grep "dev-")"
for DEVICE in $DEVICES; do
DISKSTATE="$(cat /sys/block/${MD}/md/${DEVICE}/state)"
if test "$DISKSTATE" = "in_sync"; then
DISKPARTITION="$(cut -d- -f2 <<< "$DEVICE")"
if grep -q "sda" <<< "$DISKPARTITION"; then
DISK=sdb
else
DISK=sda
fi
break
fi
done
# maybe the partition is not there
if test -e /dev/$DISK$PARTITION; then
......
......@@ -38,14 +38,27 @@ elif grep -q "_" /proc/mdstat; then
# other issues: disk sync, out of array or partitions missing
else
for MDSTAT in $(grep '_' /proc/mdstat|cut -db -f1);do
if grep -B1 $MDSTAT /proc/mdstat|head -1|grep -q sda; then
DISK=sdb
else
DISK=sda
fi
MD=$(grep -B1 $MDSTAT /proc/mdstat|head -1| cut -d\ -f1)
# get the current array and partition
MD=$(grep -B1 $MDSTAT /proc/mdstat |head -1 |cut -d\ -f1)
PARTITION=$(grep -B1 $MDSTAT /proc/mdstat|head -1| \
sed -e "s/.*raid1 sd.\([0-9]\).*/\1/")
# discover witch disk are not sync on this md array
DEVICES="$(ls /sys/block/${MD}/md/ | grep "dev-")"
for DEVICE in $DEVICES; do
DISKSTATE="$(cat /sys/block/${MD}/md/${DEVICE}/state)"
if test "$DISKSTATE" = "in_sync"; then
DISKPARTITION="$(cut -d- -f2 <<< "$DEVICE")"
if grep -q "sda" <<< "$DISKPARTITION"; then
DISK=sdb
else
DISK=sda
fi
break
fi
done
if test -e /dev/$DISK$PARTITION ; then
if grep -B1 $MDSTAT /proc/mdstat | grep -q recovery ; then
MSG="$MSG $DISK${PARTITION}_SYNCHRONIZING_RAID"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment