Event based initramfs proposal
Problem
The initramfs has a number of scripts to configure lvm, raid or crypto devices (provided by their respective packages). Those script are run once in fixed order allowing for certain combinations of them, e.g. lvm on crypto. But some combinations won't work, especially nested setups, e.g. raid on raid.
Another problem is that block devices might take a long time to appear, specifically USB drivers take so long to load and detect an USB block device that by that time the scripts for crypto, lvm and raid have often already been run. Booting from LVM on an USB block device becomes a game of chance or is simply impossible without manually adding rootdelay=xx to the boot options.
Proposal
The proposed solution is to make the initramfs aware of events so that it can rerun the scripts dealing with block devices again if more block devices appear. The simple solution sketeched out below is purposefully kept simple.
some irc notes
- udev rule that writes each new block device to /run/new-block-devices (SUBSYSTEM=block)
- simple loop in /init shell script
count=0 while [ $count -lt $TIMEOUT ]; do sleep 1 count=$((count+1)) echo -n "." udevadm --settle mv /run/new-block-dev /run/new-block-dev.processing && \ { udevadm --settle; run-parts --arg=/run/new-block-dev.processing /script/block-trigger } if [ root device exists ]; then break fi }
/scripts/block-trigger/* get called with a file as argument containing a list of new devices. This can be used to only process new devices instead of all, e.g. for mdadm to do incremental builds.