From daa8ecfe7a2091accb93f962020e47ddf92b7b45 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 11 Jan 2007 00:40:28 +0000 Subject: [PATCH] * Activate software RAID arrays. svn path=/nixos/trunk/; revision=7631 --- system/upstart.nix | 5 +++++ upstart-jobs/swraid.nix | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 upstart-jobs/swraid.nix diff --git a/system/upstart.nix b/system/upstart.nix index c490bc7b2fa..dc89e62c098 100644 --- a/system/upstart.nix +++ b/system/upstart.nix @@ -31,6 +31,11 @@ import ../upstart-jobs/gather.nix { inherit (pkgs) kernel module_init_tools lvm2; }) + # Activate software RAID arrays. + (import ../upstart-jobs/swraid.nix { + inherit (pkgs) kernel module_init_tools mdadm; + }) + # Hardware scan; loads modules for PCI devices. (import ../upstart-jobs/hardware-scan.nix { inherit (pkgs) kernel module_init_tools; diff --git a/upstart-jobs/swraid.nix b/upstart-jobs/swraid.nix new file mode 100644 index 00000000000..f62bccbf967 --- /dev/null +++ b/upstart-jobs/swraid.nix @@ -0,0 +1,36 @@ +{kernel, module_init_tools, mdadm}: + +let + + tempConf = "/var/state/mdadm.conf"; + +in + +{ + name = "swraid"; + + job = " +start on udev +#start on new-devices + +script + + # Load the necessary RAID personalities. + export MODULE_DIR=${kernel}/lib/modules/ + for mod in raid0 raid1 raid5; do + ${module_init_tools}/sbin/modprobe $mod || true + done + + # Scan /proc/partitions for RAID devices. + ${mdadm}/sbin/mdadm --examine --brief --scan -c partitions > ${tempConf} + + # Activate each device found. + ${mdadm}/sbin/mdadm --assemble -c ${tempConf} --scan + + initctl emit new-devices + +end script + + "; + +}