If, in /lib/systemd/system-shutdown there were just one file with the following contents:
#!/bin/sh # We need to ensure all md arrays with external metadata # (e.g. IMSM, DDF) are clean before completing the shutdown. /sbin/mdadm --wait-clean --scan # If this is a shutdown due to low battery, turn off the UPS /sbin/upsmon -K >/dev/null 2>&1 && /sbin/upsdrvctl shutdown Then the race condition would be gone. There would be no parallelism to worry about. But, this mostly flies in the face of the modern approach of per-package drop-in files, and may require package installers to do file editing. Not a happy prospect. Uncharacteristically, systemd doesn't provide any other means of managing dependencies or order for scripts in this directory. To me, a far more elegant solution would be for systemd-shutdown to provide the needed determinism, by running scripts serially. The drop-in files could then be: 50-mdadm.shutdown 99-nutshutdown

