* Use postStart instead of preStart.
* Assemble devices only if there is a new entry. * Add 'new-raid-array' flag to assemble new arrays. * Emit new-devices flag to triggers the 'filesystems' task. svn path=/nixos/trunk/; revision=19145
This commit is contained in:
parent
e70214c853
commit
4cf78fdb77
@ -15,7 +15,7 @@ let
|
||||
echo "$@" >> ${logFile}
|
||||
case $1 in
|
||||
(NewArray)
|
||||
initctl emit -n new-devices
|
||||
initctl emit -n new-raid-array
|
||||
;;
|
||||
(*) ;;
|
||||
esac
|
||||
@ -25,33 +25,51 @@ in
|
||||
|
||||
{
|
||||
|
||||
jobs.swraid =
|
||||
{ startOn = [ "startup" "new-devices" ];
|
||||
|
||||
script =
|
||||
''
|
||||
# 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}
|
||||
|
||||
if ! test -s ${tempConf}; then exit 0; fi
|
||||
|
||||
# Activate each device found.
|
||||
${mdadm}/sbin/mdadm --assemble -c ${tempConf} --scan
|
||||
'';
|
||||
jobs.swraid = {
|
||||
startOn = [ "new-raid-array" ];
|
||||
description = "Assemble RAID arrays.";
|
||||
|
||||
task = true;
|
||||
};
|
||||
script = ''
|
||||
# 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
|
||||
|
||||
# Save previous probe
|
||||
mv ${tempConf} ${tempConf}.old
|
||||
|
||||
# Scan /proc/partitions for RAID devices.
|
||||
${mdadm}/sbin/mdadm --examine --brief --scan -c partitions > ${tempConf}
|
||||
|
||||
if ! diff ${tempConf} ${tempConf}.old > /dev/null; then
|
||||
# Activate each device found.
|
||||
${mdadm}/sbin/mdadm --assemble -c ${tempConf} --scan
|
||||
|
||||
# Send notifications.
|
||||
initctl emit -n new-devices
|
||||
fi
|
||||
|
||||
# Remove previous configuration.
|
||||
rm ${tempConf}.old
|
||||
'';
|
||||
|
||||
task = true;
|
||||
};
|
||||
|
||||
jobs.swraidEvents = {
|
||||
name = "swraid-events";
|
||||
description = "Watch mdadm events.";
|
||||
startOn = [ "startup" ];
|
||||
|
||||
postStart = ''
|
||||
echo > ${tempConf}
|
||||
|
||||
# Assemble early raid devices.
|
||||
initctl emit -n new-raid-array
|
||||
'';
|
||||
|
||||
# !!! Someone should ensure that this is indeed doing what the manual says.
|
||||
exec = "${mdadm}/sbin/mdadm --monitor --scan --program ${mdadmEventHandler}";
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user