sw-raid: make mdmon start from initrd
Also add required systemd services for starting/stopping mdmon.
(cherry picked from commit aac666e302
)
See https://github.com/NixOS/nixpkgs/pull/13447#issuecomment-189963243 for cherry-pick discussion.
This commit is contained in:
parent
9c36de8cb2
commit
d005b64940
|
@ -58,6 +58,7 @@ let
|
||||||
|
|
||||||
# Add RAID mdadm tool.
|
# Add RAID mdadm tool.
|
||||||
copy_bin_and_libs ${pkgs.mdadm}/sbin/mdadm
|
copy_bin_and_libs ${pkgs.mdadm}/sbin/mdadm
|
||||||
|
copy_bin_and_libs ${pkgs.mdadm}/sbin/mdmon
|
||||||
|
|
||||||
# Copy udev.
|
# Copy udev.
|
||||||
copy_bin_and_libs ${udev}/lib/systemd/systemd-udevd
|
copy_bin_and_libs ${udev}/lib/systemd/systemd-udevd
|
||||||
|
|
|
@ -12,4 +12,45 @@
|
||||||
cp -v ${pkgs.mdadm}/lib/udev/rules.d/*.rules $out/
|
cp -v ${pkgs.mdadm}/lib/udev/rules.d/*.rules $out/
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
systemd.services.mdadm-shutdown = {
|
||||||
|
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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user