summary refs log tree commit diff
path: root/nixos/modules/tasks/swraid.nix
diff options
context:
space:
mode:
authorkklas <kresimir.klas@gmail.com>2016-02-25 14:08:27 +0100
committerNikolay Amiantov <ab@fmap.me>2016-03-09 21:03:49 +0300
commitaac666e302807805154190ebe105711d585c90ee (patch)
tree47074587e093a60c0d244602cd7938575f70e74b /nixos/modules/tasks/swraid.nix
parentb20439ef6745c9f7106e155ffd72c4220b3e9dbf (diff)
downloadnixlib-aac666e302807805154190ebe105711d585c90ee.tar
nixlib-aac666e302807805154190ebe105711d585c90ee.tar.gz
nixlib-aac666e302807805154190ebe105711d585c90ee.tar.bz2
nixlib-aac666e302807805154190ebe105711d585c90ee.tar.lz
nixlib-aac666e302807805154190ebe105711d585c90ee.tar.xz
nixlib-aac666e302807805154190ebe105711d585c90ee.tar.zst
nixlib-aac666e302807805154190ebe105711d585c90ee.zip
sw-raid: make mdmon start from initrd
Also add required systemd services for starting/stopping mdmon.

Closes #13447.
abbradar: fixed `mdadmShutdown` service name according to de facto conventions.
Diffstat (limited to 'nixos/modules/tasks/swraid.nix')
-rw-r--r--nixos/modules/tasks/swraid.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/nixos/modules/tasks/swraid.nix b/nixos/modules/tasks/swraid.nix
index 8e9728919718..18df0e224d55 100644
--- a/nixos/modules/tasks/swraid.nix
+++ b/nixos/modules/tasks/swraid.nix
@@ -12,4 +12,45 @@
     cp -v ${pkgs.mdadm}/lib/udev/rules.d/*.rules $out/
   '';
 
+  systemd.services.mdadmShutdown = {
+    wantedBy = [ "final.target"];
+    after = [ "umount.target" ];
+
+    unitConfig = {
+      DefaultDependencies = false;
+    };
+
+    serviceConfig = {
+      Type = "oneshot";
+      ExecStart = ''${pkgs.mdadm}/bin/mdadm --wait-clean --scan'';
+    };
+  };
+
+  systemd.services."mdmon@" = {
+    description = "MD Metadata Monitor on /dev/%I";
+
+    unitConfig.DefaultDependencies = false;
+
+    serviceConfig = {
+      Type = "forking";
+      Environment = "IMSM_NO_PLATFORM=1";
+      ExecStart = ''${pkgs.mdadm}/bin/mdmon --offroot --takeover %I'';
+      KillMode = "none";
+    };
+  };
+
+  systemd.services."mdadm-grow-continue@" = {
+    description = "Manage MD Reshape on /dev/%I";
+
+    unitConfig.DefaultDependencies = false;
+
+    serviceConfig = {
+      ExecStart = ''${pkgs.mdadm}/bin/mdadm --grow --continue /dev/%I'';
+      StandardInput = "null";
+      StandardOutput = "null";
+      StandardError = "null";
+      KillMode = "none";
+    };
+  };
+ 
 }