[systemd-devel] Need help with a systemd/mdadm interaction.

Lennart Poettering lennart at poettering.net
Wed Nov 13 07:03:16 PST 2013


On Tue, 12.11.13 11:31, NeilBrown (neilb at suse.de) wrote:

> 
> Hi,
>  I wonder if I could get some advice....
> 
> mdadm is quite good at assembling arrays incrementally.  "udev" runs
> "mdadm -I" for each new device and mdadm gathers them into arrays and
> activates the array once all the expected devices have been gathered.
> 
> This simple rule falls down if some expected device doesn't appear.
> 
> If an array is marked as degraded then mdadm doesn't expect the missing
> device and will happily start the degaded array.  However if the system shuts
> down with the md array fully functional, and a device is removed before the
> system is restarted, then mdadm does not know that the device is missing and
> will effectively wait for it forever.
> 
> mdadm can handle this, but it needs to be told.  The command:
>   mdadm -IRs
> will find any arrays which have enough devices to start degraded but haven't
> been started yet, and will start them.
> I used this quite effectively in out initrd.  There is a loop that count up
> to N waiting for the root device to appear and when we get to "N/2" I run
> "mdadm -IRs" which makes any newly-degraded arrays appear.
> 
> I'm wondering how to integrate this with systemd.  Systemd has its own
> mechanism to wait for devices to appear, but I cannot see anyway to run
> "mdadm -IRs" at the half-way mark.
> 
> It would of course be sufficient to wait for the complete timeout, then run
> "mdadm -IRs", then check if the device has appeared, but I can't see how to
> fit this into systemd either.
> 
> So: how can I fit this need for "run some command on device timeout which
> might be successful in activating the device"?
> 
> Alternately, is there some "all devices have been probed, nothing new will
> appear unless it is hot-plugged" event.  That would be equally useful (and
> probably mirrors what hardware-RAID cards do).

As pointed out by the others in the thread: there is no point in time
where all devices have shown. Whether USB, PCI Express or iSCSI or even
other stuff: assuming there was a point in time where everything has
shown up is wrong. There's no such point in time.

I also have the suspicion that the best strategy for handling degraded
arrays is to timeout and not assemble them but rather put the system in
a state where the admin has to become active. Auto-assembling degraded
arrays has the feel of taping over issues. If the admin chooses to
boot-up with degraded disks then that's ok, but I am pretty sure this is
something the admin should explicitly decide.

Note that systemd will timeout already when we look for devices to
mount. Hence, you could just decide to do nothing in mdadm: when the
stuff doesn't appear then systemd will already now put the system into
emergency mode and give the admin a shell.

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list