modify mkraid.sh

This commit is contained in:
zorro
2010-10-08 10:30:48 +08:00
parent bf71d303b2
commit 335bb9802e

View File

@@ -83,13 +83,13 @@ setArgument(){
esac
done
if [ ! "${ACTIVELIST}" ];then
if [ -z "${ACTIVELIST}" ];then
ACTIVENUM=0
else
ACTIVENUM=`echo $ACTIVELIST | tr , ' ' | wc -w`
fi
if [ ! "${SPARELIST}" ]; then
if [ -z "${SPARELIST}" ]; then
SPARENUM=0
else
SPARENUM=`echo $SPARELIST | tr , ' ' | wc -w`
@@ -147,7 +147,7 @@ testBeforeMkraid(){
# used"
for i in ${DEVICELIST}
do
if mdadm -Ds -v | grep -w $i ; then
if mdadm -Ds -v | grep -w $i >>${DEV_LOG} 2>>${DEV_LOG} ; then
info "incorrect active and spare devices name, maybe it has been used"
return 6
fi
@@ -164,7 +164,7 @@ testBeforeMkraid(){
testAfterCreate(){
#test "(7) create or assimble raid device lose"
if [ "${1}" != "0" ];then
info "create or assimble $RAIDNAME lose" >>${LOGDIR}${LOGFILE} 2>>${LOGDIR}${LOGFILE}
info "create or assimble $RAIDNAME lose"
return 7
fi
return 0
@@ -182,10 +182,10 @@ usage(){
echo "According to the arguments,this shell make raid by create mode. Before make it, there is some testing for the arguments, and the ERRNO will be setted to the approprate value. This shell support RAID0 1 5 and 10 at present. "
echo""
echo "ARGUMENT:
<raidname> -- RAID devices name, example \"/dev/mdX\"
<raidlevel> -- RAID level, example \"0, 1, 5, 10\"
<activelist> -- the RAID active member's list, the interval symbol must be ',',example \"/dev/sda1,/dev/sdb1,/dev/sdc1,/dev/hda1 ... \"
<sparelist> -- the RAID spare member's list, this is not must. the interval symbol same as activelist"
<raidname> -- RAID devices name, example /dev/mdX
<raidlevel> -- RAID level, example 0, 1, 5, 10
<activelist> -- the RAID active member list, the interval symbol must be ',',example /dev/sda1,/dev/sdb1,/dev/sdc1,/dev/hda1 ...
<sparelist> -- the RAID spare member list, this is not must. the interval symbol same as activelist"
echo ""
echo "RETURN VALUE:
7 create or assimble raid device lose
@@ -195,15 +195,14 @@ usage(){
3 the raid name has exist
2 this levelY need more devices
1 error argument to the mkraid from user
0 make raid allright
The ERRNO will be setted to the approprate value and the return value will be return. The raid confgure message will output on stdout."
0 make raid allright"
echo ""
echo "EXAMPLE:
If you want to make raid1 named the /dev/md0 with two active devices named /dev/sda1 /dev/sdb1 and one spare device named /dev/sdc1, you can write for this:"
echo ""
echo " mkraid -n /dev/md0 -l 1 -a /dev/sda1,/dev/sdb1 -s /dev/sdc1"
echo ""
echo "But if you want to make raid0 with spare devices, there will be some mistake and exit with 5. Other mistake please watch by yourself."
echo "But if you want to make raid0 with spare devices, there will be some mistake and exiting with 5. Other mistake please watch by yourself."
echo ""
echo ""
echo "Report bugs to <zrlang@linx-info.com>"
@@ -226,7 +225,7 @@ else
op_x="-x$SPARENUM"
fi
echo yes | mdadm -C -q $RAIDNAME -l$RAIDLEVEL -n$ACTIVENUM $op_x $DEVICELIST >>${DEV_LOG} 2>>${DEV_LOG}
yes| mdadm -C -q $RAIDNAME -l$RAIDLEVEL -n$ACTIVENUM $op_x $DEVICELIST >>${DEV_LOG} 2>>${DEV_LOG}
testAfterCreate $?; erv
info "make $RAIDNAME allright"