git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commitaac666e302807805154190ebe105711d585c90ee authorkklas <kresimir.klas@gmail.com> dateThu 25 Feb 2016, 14:08 (11 years ago) parentb20439e
2 files changed+42
nixos/modules/system/boot/stage-1.nix+1 nixos/modules/tasks/swraid.nix+41
nixos/modules/system/boot/stage-1.nix+1
@@ -58,6 +58,7 @@ let
5858
5959 # Add RAID mdadm tool.
6060 copy_bin_and_libs ${pkgs.mdadm}/sbin/mdadm
61+ copy_bin_and_libs ${pkgs.mdadm}/sbin/mdmon
6162
6263 # Copy udev.
6364 copy_bin_and_libs ${udev}/lib/systemd/systemd-udevd
nixos/modules/tasks/swraid.nix+41
@@ -12,4 +12,45 @@
1212 cp -v ${pkgs.mdadm}/lib/udev/rules.d/*.rules $out/
1313 '';
1414
15+ systemd.services.mdadmShutdown = {
16+ wantedBy = [ "final.target"];
17+ after = [ "umount.target" ];
18+
19+ unitConfig = {
20+ DefaultDependencies = false;
21+ };
22+
23+ serviceConfig = {
24+ Type = "oneshot";
25+ ExecStart = ''${pkgs.mdadm}/bin/mdadm --wait-clean --scan'';
26+ };
27+ };
28+
29+ systemd.services."mdmon@" = {
30+ description = "MD Metadata Monitor on /dev/%I";
31+
32+ unitConfig.DefaultDependencies = false;
33+
34+ serviceConfig = {
35+ Type = "forking";
36+ Environment = "IMSM_NO_PLATFORM=1";
37+ ExecStart = ''${pkgs.mdadm}/bin/mdmon --offroot --takeover %I'';
38+ KillMode = "none";
39+ };
40+ };
41+
42+ systemd.services."mdadm-grow-continue@" = {
43+ description = "Manage MD Reshape on /dev/%I";
44+
45+ unitConfig.DefaultDependencies = false;
46+
47+ serviceConfig = {
48+ ExecStart = ''${pkgs.mdadm}/bin/mdadm --grow --continue /dev/%I'';
49+ StandardInput = "null";
50+ StandardOutput = "null";
51+ StandardError = "null";
52+ KillMode = "none";
53+ };
54+ };
55+
1556}