FS#10061 still isn't dead, its just resting: https://bbs.archlinux.org/viewtopic.php?pid=1056003 An strace from a helpful user shows that our mdadm call is trying to open a block device and the call never returns: open("/dev/sdb", O_RDONLY|O_DIRECT|O_LARGEFILE Fix this by only scanning explicitly the block devices we're interested in, found via sysfs. This is an all around win for everyone, especially users who have mdadm installed without any need for it. This changes some of our assumptions about the environment: - the mdadm binary exists when we find md devices in /sys - the user running mkinitcpio isn't any any specific UID or part of any particular group, but merely has read access to the block devices we're about to scan. Signed-off-by: Dave Reisner <dreisner@archlinux.org> --- install/autodetect | 28 ++++++++++++++++++++++------ 1 files changed, 22 insertions(+), 6 deletions(-) diff --git a/install/autodetect b/install/autodetect index 3fb87ce..5cc908c 100644 --- a/install/autodetect +++ b/install/autodetect @@ -1,6 +1,9 @@ #!/bin/bash build() { + local -a md_devs + local dev insufficient_perms + MODULE_FILE=$workdir/autodetect_modules add_if_avail() { @@ -29,15 +32,28 @@ build() { add_if_avail "$usrfstype" fi - if (( UID == 0 )) || in_array 'disk' $(groups); then - if [[ -x $(type -P mdadm) ]]; then - mdadm -Esv /dev/[hrsv]d* /dev/{ida,cciss,ataraid,mapper}/* | + # look for raid devices + shopt -s nullglob + for dev in /sys/class/block/*/md/dev-*; do + dev=/dev/${dev#*/dev-} + + [[ -r $dev ]] || insufficient_perms=1 + + md_devs+=("$dev") + done + shopt -u nullglob + + # scan members of raid devices if found + if (( ${#md_devs[*]} )); then + (( !QUIET )) && plain "found %d raid members to scan" "${#md_devs[*]}" + if (( ! insufficient_perms )); then + mdadm -Esv "${md_devs[@]}" | sed -n 's/.*level=\([^ ]\+\) .*/\1/p' | sed 's/\<raid[456]\>/raid456/g' | sort -u >>"$MODULE_FILE" + else + warning "Insufficient permission to perform autodetection for mdadm devices" + raid_autodetect_failed=1 fi - else - error "Insufficient permission to perform autodetection for mdadm devices" - raid_autodetect_failed=1 fi if (( !QUIET )) && [[ -s $MODULE_FILE ]]; then -- 1.7.9