Comment 33 for bug 158918

The solution is a reliable UUID-based raid assembly mechanism.

One that does not depend on ARRAY definitions in mdadm.conf. At the same time making sure never to create devices named equal to the legacy 'standard' non-uniqe and non-persistent naming scheme /dev/md0 etc. causing much havoc.

Without direct support for this in mdadm I finaly think I figured a way with current mdadm features to realize this:

A) Hotplug Action
/lib/udev/rules.d/85-mdadm.rules needs to take care of mdadm.conf when a new raid member appears, and do tree things:

1) grep --invert-match ARRAY mdadm.conf > /var/run/mdadm/mdadm-udev-event-<eventID>.conf
(prior existence of /var/run/mdadm/ is required by mdadm --incremental anyway, see Bug #550131)

2) echo "ARRAY uuid=${<uuid-variable-from-udev>} name=${<uuid-variable-from-udev>}-md # ARRAY lines are dynamicaly rewritten on udev events" >> /var/run/mdadm/mdadm-udev-event-<eventID>.conf

3) mdadm --incremental --config=/var/run/mdadm/mdadm-udev-event-<eventID>.conf $env{DEVNAME}

B) Degrading Action
For arrays required during the boot process a watchdog like script or program like mountall needs to --run arrays degraded if they haven't come up after a timeout. (See https://wiki.ubuntu.com/ReliableRaid for more details.) But as mdadm --run /dev/<md-device> is not supported to start *only a specific* array degraded (i.e. to start only the rootfs degraded after a timeout in initramfs #251646) use this:

mdadm --remove <incomplete-md-device> <arbitrary-member-device-of-incomplete-array>
mdadm --incremental --run <arbitrary-member-device-of-incomplete-array>

PS: With this, to enable partitionable arrays just change the CREATE line in /etc/mdadm/mdadm.conf to contain auto=part.