On 7/11/26 5:46 AM, Genes Lists wrote:
If you use dracut to build the initrd, then you can make a "pre-mount" script to do what you want.

Rough outline would be :

(1) make sure grep / sleep are included in the initrd:

   Create /etc/dracut.conf.d/99-mdadm-check.conf
   Or any other ".conf" file in that directory.

   And add this line to it:

   install_items+=" /usr/bin/grep /usr/bin/sleep "

(2) Add a pre-mount script to check on mdadm state:

     mkdir -p /usr/lib/dracut/hooks/pre-mount/

     Add the script: /usr/lib/dracut/hooks/pre-mount/99-check-mdadm.sh

#!/bin/sh
# /usr/lib/dracut/hooks/pre-mount/99-check-mdadm.sh
# Check if mdadm is resyncing
#
if grep -qE "resync|recovery|check" /proc/mdstat; then
     echo "*** >>> RAID Array is Resyncing / Rebuilding <<<"
     cat /proc/mdstat
     sleep 10
fi

Untested but should work okay.

Thank you Genes!

That is spot on. I've not use drakut with Arch before, but have used it with openSUSE for years, and it has worked fantastic. That also made me chuckle a bit. While Arch has been discussing/offering drakut for a while now, openSUSE seems set on moving away from it... for whatever winds blow through the decision tree over there.

Above in the script, should I loop it while the resync condition is true instead of a one-shot to ensure the resync finishes before letting the mount attempt occur? Or, just use the one-shot and let the boot process wait at that point until it sees what it needs to keep going?

It was obviously smart enough to handle the condition on its own, it just wasn't very informative about it.

I don't know if that's possible, I don't know the boot process that well, but that was one question that came to mind looking at the script.

Thank you again for the insight, that really helped point me toward where and how this could be done.

--
David C. Rankin, J.D.,P.E.

Reply via email to