@@ -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}