Merge pull request #168793 from helsinki-systems/feat/systemd-stage-1-mdraid-merge
nixos/stage-1-init: Merge mdraid module into swraid
This commit is contained in:
commit
9c70501b37
6 changed files with 42 additions and 49 deletions
|
@ -1187,7 +1187,6 @@
|
|||
./system/boot/systemd/tmpfiles.nix
|
||||
./system/boot/systemd/user.nix
|
||||
./system/boot/systemd/initrd.nix
|
||||
./system/boot/systemd/initrd-mdraid.nix
|
||||
./system/boot/timesyncd.nix
|
||||
./system/boot/tmp.nix
|
||||
./system/etc/etc-activation.nix
|
||||
|
|
|
@ -355,7 +355,7 @@ let
|
|||
[ { object = bootStage1;
|
||||
symlink = "/init";
|
||||
}
|
||||
{ object = pkgs.writeText "mdadm.conf" config.boot.initrd.services.mdraid.mdadmConf;
|
||||
{ object = pkgs.writeText "mdadm.conf" config.boot.initrd.services.swraid.mdadmConf;
|
||||
symlink = "/etc/mdadm.conf";
|
||||
}
|
||||
{ object = pkgs.runCommand "initrd-kmod-blacklist-ubuntu" {
|
||||
|
@ -731,6 +731,6 @@ in
|
|||
};
|
||||
|
||||
imports = [
|
||||
(mkRenamedOptionModule [ "boot" "initrd" "mdadmConf" ] [ "boot" "initrd" "services" "mdraid" "mdadmConf" ])
|
||||
(mkRenamedOptionModule [ "boot" "initrd" "mdadmConf" ] [ "boot" "initrd" "services" "swraid" "mdadmConf" ])
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
{ config, pkgs, lib, ... }: let
|
||||
|
||||
cfg = config.boot.initrd.services.mdraid;
|
||||
|
||||
in {
|
||||
options.boot.initrd.services.mdraid = {
|
||||
enable = (lib.mkEnableOption "mdraid support in initrd") // {
|
||||
visible = false;
|
||||
};
|
||||
|
||||
mdadmConf = lib.mkOption {
|
||||
description = "Contents of <filename>/etc/mdadm.conf</filename> in initrd.";
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf (config.boot.initrd.systemd.enable && cfg.enable) {
|
||||
boot.initrd.systemd = {
|
||||
contents."/etc/mdadm.conf" = lib.mkIf (cfg.mdadmConf != "") {
|
||||
text = cfg.mdadmConf;
|
||||
};
|
||||
|
||||
initrdBin = [ pkgs.mdadm ];
|
||||
};
|
||||
|
||||
boot.initrd.services.udev.packages = [ pkgs.mdadm ];
|
||||
boot.initrd.systemd.packages = [ pkgs.mdadm ];
|
||||
|
||||
boot.kernelModules = [ "dm-raid" ];
|
||||
};
|
||||
}
|
|
@ -1,17 +1,43 @@
|
|||
{ pkgs, ... }:
|
||||
{ config, pkgs, lib, ... }: let
|
||||
|
||||
{
|
||||
cfg = config.boot.initrd.services.swraid;
|
||||
|
||||
environment.systemPackages = [ pkgs.mdadm ];
|
||||
in {
|
||||
|
||||
services.udev.packages = [ pkgs.mdadm ];
|
||||
options.boot.initrd.services.swraid = {
|
||||
enable = (lib.mkEnableOption "swraid support using mdadm") // {
|
||||
visible = false; # only has effect when the new stage 1 is in place
|
||||
};
|
||||
|
||||
systemd.packages = [ pkgs.mdadm ];
|
||||
mdadmConf = lib.mkOption {
|
||||
description = "Contents of <filename>/etc/mdadm.conf</filename> in initrd.";
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
};
|
||||
};
|
||||
|
||||
boot.initrd.availableKernelModules = [ "md_mod" "raid0" "raid1" "raid10" "raid456" ];
|
||||
config = {
|
||||
environment.systemPackages = [ pkgs.mdadm ];
|
||||
|
||||
boot.initrd.extraUdevRulesCommands = ''
|
||||
cp -v ${pkgs.mdadm}/lib/udev/rules.d/*.rules $out/
|
||||
'';
|
||||
services.udev.packages = [ pkgs.mdadm ];
|
||||
|
||||
systemd.packages = [ pkgs.mdadm ];
|
||||
|
||||
boot.initrd.availableKernelModules = lib.mkIf (config.boot.initrd.systemd.enable -> cfg.enable) [ "md_mod" "raid0" "raid1" "raid10" "raid456" ];
|
||||
|
||||
boot.initrd.extraUdevRulesCommands = lib.mkIf (!config.boot.initrd.systemd.enable) ''
|
||||
cp -v ${pkgs.mdadm}/lib/udev/rules.d/*.rules $out/
|
||||
'';
|
||||
|
||||
boot.initrd.systemd = lib.mkIf cfg.enable {
|
||||
contents."/etc/mdadm.conf" = lib.mkIf (cfg.mdadmConf != "") {
|
||||
text = cfg.mdadmConf;
|
||||
};
|
||||
|
||||
packages = [ pkgs.mdadm ];
|
||||
initrdBin = [ pkgs.mdadm ];
|
||||
};
|
||||
|
||||
boot.initrd.services.udev.packages = lib.mkIf cfg.enable [ pkgs.mdadm ];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -521,8 +521,8 @@ in
|
|||
systemd-confinement = handleTest ./systemd-confinement.nix {};
|
||||
systemd-cryptenroll = handleTest ./systemd-cryptenroll.nix {};
|
||||
systemd-escaping = handleTest ./systemd-escaping.nix {};
|
||||
systemd-initrd-mdraid = handleTest ./systemd-initrd-mdraid.nix {};
|
||||
systemd-initrd-simple = handleTest ./systemd-initrd-simple.nix {};
|
||||
systemd-initrd-swraid = handleTest ./systemd-initrd-swraid.nix {};
|
||||
systemd-journal = handleTest ./systemd-journal.nix {};
|
||||
systemd-machinectl = handleTest ./systemd-machinectl.nix {};
|
||||
systemd-networkd = handleTest ./systemd-networkd.nix {};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import ./make-test-python.nix ({ lib, pkgs, ... }: {
|
||||
name = "systemd-initrd-mdraid";
|
||||
name = "systemd-initrd-swraid";
|
||||
|
||||
nodes.machine = { pkgs, ... }: {
|
||||
# Use systemd-boot
|
||||
|
@ -17,7 +17,7 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
|
|||
enable = true;
|
||||
emergencyAccess = true;
|
||||
};
|
||||
services.mdraid = {
|
||||
services.swraid = {
|
||||
enable = true;
|
||||
mdadmConf = ''
|
||||
ARRAY /dev/md0 devices=/dev/vdc,/dev/vdd
|
||||
|
@ -26,7 +26,7 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
|
|||
kernelModules = [ "raid0" ];
|
||||
};
|
||||
|
||||
specialisation.boot-mdraid.configuration.virtualisation.bootDevice = "/dev/disk/by-label/testraid";
|
||||
specialisation.boot-swraid.configuration.virtualisation.bootDevice = "/dev/disk/by-label/testraid";
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
|
@ -36,7 +36,7 @@ import ./make-test-python.nix ({ lib, pkgs, ... }: {
|
|||
machine.succeed("mkdir -p /mnt && mount /dev/md0 /mnt && echo hello > /mnt/test && umount /mnt")
|
||||
|
||||
# Boot from the RAID
|
||||
machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-mdraid.conf")
|
||||
machine.succeed("bootctl set-default nixos-generation-1-specialisation-boot-swraid.conf")
|
||||
machine.succeed("sync")
|
||||
machine.crash()
|
||||
machine.wait_for_unit("multi-user.target")
|
Loading…
Reference in a new issue