Hi everybody!!
Here is the problem,
I'm trying to develop a script that can help me with the raid creation, but, till now, I have been dealing for more than a week and I still didn't achieve any satisfactory results. :icon_cry:
Here is the code to execute:
# mdadm --manage /dev/md0 --add /dev/sdb1
# mdadm --manage /dev/md1 --add /dev/sdb2
# mdadm --manage /dev/md2 --add /dev/sdb3
# mdadm --manage /dev/md3 --add /dev/sdb4
This wouldn't be difficult at all if this script was by itself but it comes after a partition disk operations and before I use grub for define the boot.
Here is how the structure of my global program looks like:
Global.sh
./Script for disk partition
./Mdadm script
./Grub script
The main problem is that the "grub script" must wait the "mdadm" one, otherwise it has no sense and it will return a mistake.
Because I'm a newbie in shell scripting I have been browsing around and I tried some of the things that look alike, but never I found a particular solution for this. :icon_confused:
Here is the last one I tried
mdadm --manage /dev/md0 --add /dev/sdb1 &
wait $!
until [ $? == "0" ]
do
clear
cat /proc/mdstat #I want to know the status of the procedure at any time
sleep 1
done
......
...... #The same for the rest of cases
It doesn't works even with the first one of them, It looks that doesn't goes inside the "until" and if I push a couple of times "enter" I can reach the prompt .
mdadm --manage /dev/md0 --add /dev/sdb1 &
mdadm --manage /dev/md1 --add /dev/sdb2 &
mdadm --manage /dev/md2 --add /dev/sdb3 &
mdadm --manage /dev/md3 --add /dev/sdb4 &
wait $!
This also doesn't works in the way I need, I can reach the prompt and grub doesn't wait.
Let's summarize:
*I would like to make an script with this commands inside
# mdadm --manage /dev/md0 --add /dev/sdb1
# mdadm --manage /dev/md1 --add /dev/sdb2
# mdadm --manage /dev/md2 --add /dev/sdb3
# mdadm --manage /dev/md3 --add /dev/sdb4
*The next script to execute (grub.sh) has to wait till all this processes are finished
Meanwhile the execution:
*In order to control the raid operations this command=> "cat /proc/mdstat" has to be execute with a little delay all the time
*The user cannot reach the prompt, thus is, the keyboard should be "blocked"
P.S.:I'm running Debian
P.S.2:Sorry for my English, I hope we can understand each other :icon_rolleyes:
Thanks for any collaboration :icon_idea: