* 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}
|
echo "$@" >> ${logFile}
|
||||||
case $1 in
|
case $1 in
|
||||||
(NewArray)
|
(NewArray)
|
||||||
initctl emit -n new-devices
|
initctl emit -n new-raid-array
|
||||||
;;
|
;;
|
||||||
(*) ;;
|
(*) ;;
|
||||||
esac
|
esac
|
||||||
@ -25,33 +25,51 @@ in
|
|||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
jobs.swraid =
|
jobs.swraid = {
|
||||||
{ startOn = [ "startup" "new-devices" ];
|
startOn = [ "new-raid-array" ];
|
||||||
|
description = "Assemble RAID arrays.";
|
||||||
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
|
|
||||||
'';
|
|
||||||
|
|
||||||
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 = {
|
jobs.swraidEvents = {
|
||||||
name = "swraid-events";
|
name = "swraid-events";
|
||||||
description = "Watch mdadm events.";
|
description = "Watch mdadm events.";
|
||||||
startOn = [ "startup" ];
|
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}";
|
exec = "${mdadm}/sbin/mdadm --monitor --scan --program ${mdadmEventHandler}";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user