2009-10-12 18:36:19 +02:00
|
|
|
{ config, pkgs, ... }:
|
2009-03-06 13:27:30 +01:00
|
|
|
|
|
|
|
###### implementation
|
2007-01-11 01:40:28 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
2007-01-23 21:09:06 +01:00
|
|
|
tempConf = "/var/run/mdadm.conf";
|
2009-03-06 13:27:30 +01:00
|
|
|
modprobe = config.system.sbin.modprobe;
|
|
|
|
inherit (pkgs) mdadm;
|
2007-01-11 01:40:28 +01:00
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
2009-10-12 20:09:34 +02:00
|
|
|
jobs.swraid =
|
2009-11-06 20:20:09 +01:00
|
|
|
{ startOn = "started udev or new-devices";
|
2009-03-06 13:27:30 +01:00
|
|
|
|
2009-10-12 18:36:19 +02:00
|
|
|
script =
|
|
|
|
''
|
2009-03-06 13:27:30 +01:00
|
|
|
# Load the necessary RAID personalities.
|
|
|
|
# !!! hm, doesn't the kernel load these automatically?
|
|
|
|
for mod in raid0 raid1 raid5; do
|
|
|
|
${modprobe}/sbin/modprobe $mod || true
|
|
|
|
done
|
|
|
|
|
|
|
|
# Scan /proc/partitions for RAID devices.
|
|
|
|
${mdadm}/sbin/mdadm --examine --brief --scan -c partitions > ${tempConf}
|
2009-11-06 20:20:09 +01:00
|
|
|
|
|
|
|
if ! test -s ${tempConf}; then exit 0; fi
|
2009-03-06 13:27:30 +01:00
|
|
|
|
|
|
|
# Activate each device found.
|
|
|
|
${mdadm}/sbin/mdadm --assemble -c ${tempConf} --scan
|
|
|
|
|
2009-11-06 22:38:40 +01:00
|
|
|
initctl emit -n new-devices
|
2009-10-12 18:36:19 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
task = true;
|
|
|
|
};
|
|
|
|
|
2007-01-11 01:40:28 +01:00
|
|
|
}
|