Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I pause execution of my shell script after calling the following command until the raid array has been assembled? From what I understand, this is an asynchronous process and status of the raid array needs to be polled.

mdadm --create -l10 -n4 /dev/md0 /dev/xvdh*

share|improve this question
up vote 1 down vote accepted

Since you're creating a new RAID 10, you can begin using the array immediately. The initial resync will continue in the background. You only need to wait for it to complete if building a RAID 5 array (and it's a good idea for a RAID 6, too).

See Initial Array Creation in the Linux RAID Wiki for further details.

share|improve this answer

Edit Sat Oct 27 17:03:42 CDT 2012:

While it's true that you can work with the RAID 10 array before it's finished re syncing, I figured that I would answer the question about how to pause during the re-sync process anyway.

This is how you pause the script for the re-syncing process (IMO/AFAIK/etc.):

# Add this where you want to pause...
while [ -n "$(mdadm --detail /dev/md0 | grep -ioE 'State :.*resyncing')" ]; do
    sleep 1

To use the example above, the whole script would be:

mdadm --create -l10 -n4 /dev/md0 /dev/xvdh*

while [ -n "$(mdadm --detail /dev/md0 | grep -ioE 'State :.*resyncing')" ]; do
    sleep 1

mke2fs -t ext4 -F /dev/md0

Please note that the above script is not tested and may contain bugs.

share|improve this answer
thanks. that works for the mke2fs command. but the raid array being built is an asynchronous process. the command "mdadm --detail /dev/md0" is used to query the status. – VinnyD Oct 27 '12 at 19:26
i updated my question to clarify what I'm asking. – VinnyD Oct 27 '12 at 21:44
@VinnyD Oh, then this becomes a bit more complex. Please post an example of what mdadm --detail /dev/md0 says while you want it paused. – Soviero Oct 27 '12 at 21:52
thanks for your help :) the response below answers my question. – VinnyD Oct 27 '12 at 22:10
@VinnyD See latest edit... – Soviero Oct 27 '12 at 22:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.