Bug#770002: initramfs-tools: the mdadm runs arrays when all disks are not yet ready.

Andrey Nikitin andrey.d.nikitin at gmail.com
Fri Nov 28 15:29:45 UTC 2014


Important note.

Previously, under `dpkg-reconfigure mdadm` I mistakenly identified
all my arrays as used for rootfs (type "all").

However, this is no longer true.

Now I reconfigure mdadm again and set "need for rootfs" value of a "none".
The problem is not happening now, see dmsg output below.

[   17.162392] sd 2:0:0:0: [sdb] Attached SCSI disk
[   17.988913] sd 4:0:0:0: [sdc] Attached SCSI disk

[   19.562406] md: bind<sdb1>
[   19.579620] md: bind<sdb3>
[   19.585215] md: bind<sdb4>
[   19.624217] md: bind<sdc3>
[   19.764786] md: raid1 personality registered for level 1
[   19.765166] md/raid1:md1: active with 2 out of 2 mirrors
[   19.765207] md1: detected capacity change from 0 to 393999024128
[   19.765781]  md1: unknown partition table
[   19.772188] md: bind<sdc1>
[   19.773942] md/raid1:md0: active with 2 out of 2 mirrors
[   19.773980] md0: detected capacity change from 0 to 98566144
[   19.774519]  md0: unknown partition table
[   19.775138] md: bind<sdc4>
[   19.777105] md/raid1:md2: active with 2 out of 2 mirrors
[   19.777139] md2: detected capacity change from 0 to 1892745216
[   19.795001]  md2: unknown partition table

So maybe my problem is not a bug,
but it would be good before running mdadm run|assemble to check
the readiness all disks devices, used by all md arrays.


[code]
#!/bin/sh

PREREQ="udev"

prereqs()
{
	echo "${PREREQ}"
}

case ${1} in
	prereqs)
		prereqs
		exit 0
		;;
esac

set -eu

# TODO set this list from hook script
MD_PARTS="sdb1 sdb3 sdb4 sdc1 sdc3 sdc4"

[ -x /sbin/mdadm ] || exit 0

if [ -r /scripts/functions ]; then
   . /scripts/functions
elif [ -r /usr/share/initramfs-tools/scripts/functions ]; then
   . /usr/share/initramfs-tools/scripts/functions
fi

check_part()
{
   part="${1}"

   # If the root device hasn't shown up yet, give it a little while
   # to deal with removable devices
   if [ ! -e "${part}" ] || ! $(get_fstype "${part}" >/dev/null); then
        log_begin_msg "Waiting for part ${part}"

        # Default delay is 5s
        slumber=${ROOTDELAY:-5}
	
        slumber=$(( ${slumber} * 10 ))
        while [ ! -e "${part}" ] \
                || ! $(get_fstype "${part}" >/dev/null); do
            /bin/sleep 0.1
            slumber=$(( ${slumber} - 1 ))
            [ ${slumber} -gt 0 ] || break
        done

        if [ ${slumber} -gt 0 ]; then
           log_end_msg 0
	else
	   log_end_msg 1 || true
	fi
   fi
}


wait_for_udev 10

for part in $MD_PARTS
do
   dev="/dev/$part"
   check_part ${dev}
done
[/code]



More information about the pkg-mdadm-devel mailing list