整理mdadm

This commit is contained in:
陈浩南 2023-07-09 13:33:40 +08:00
parent 782f08d860
commit 4e2a01a90c
3 changed files with 27 additions and 21 deletions

View File

@ -139,6 +139,8 @@
"/dev/disk/by-uuid/55fdd19f-0f1d-4c37-bd4e-6df44fc31f26" = { mapper = "root"; ssd = true; }; "/dev/disk/by-uuid/55fdd19f-0f1d-4c37-bd4e-6df44fc31f26" = { mapper = "root"; ssd = true; };
"/dev/md/swap" = { mapper = "swap"; ssd = true; }; "/dev/md/swap" = { mapper = "swap"; ssd = true; };
}; };
mdadm =
"ARRAY /dev/md/swap metadata=1.2 name=chn-PC:swap UUID=2b546b8d:e38007c8:02990dd1:df9e23a4";
}; };
};} };}
) )

View File

@ -124,11 +124,6 @@ inputs:
''; '';
}; };
}; };
services.swraid =
{
enable = true;
mdadmConf = "ARRAY /dev/md/swap metadata=1.2 name=chn-PC:swap UUID=2b546b8d:e38007c8:02990dd1:df9e23a4";
};
# modules in initrd # modules in initrd
# modprobe --show-depends # modprobe --show-depends
availableKernelModules = availableKernelModules =

View File

@ -11,6 +11,7 @@ inputs:
}; };
decrypt.auto = mkOption { type = types.attrsOf (types.submodule { options = decrypt.auto = mkOption { type = types.attrsOf (types.submodule { options =
{ mapper = mkOption { type = types.nonEmptyStr; }; ssd = mkOption { type = types.bool; }; }; }); }; { mapper = mkOption { type = types.nonEmptyStr; }; ssd = mkOption { type = types.bool; }; }; }); };
mdadm = mkOption { type = types.nullOr types.str; };
# swap and resume # swap and resume
# swap != resume.device if swap is a file # swap != resume.device if swap is a file
@ -51,23 +52,31 @@ inputs:
) )
(inputs.localLib.attrsToList inputs.config.nixos.fileSystems.mount.btrfs))) (inputs.localLib.attrsToList inputs.config.nixos.fileSystems.mount.btrfs)))
); );
boot.initrd.luks.devices = boot.initrd =
( {
builtins.listToAttrs (builtins.map luks.devices =
( (
device: builtins.listToAttrs (builtins.map
{ (
name = device.value.mapper; device:
value =
{ {
device = device.name; name = device.value.mapper;
allowDiscards = device.value.ssd; value =
bypassWorkqueues = device.value.ssd; {
crypttabExtraOpts = [ "fido2-device=auto" ]; device = device.name;
}; allowDiscards = device.value.ssd;
} bypassWorkqueues = device.value.ssd;
) crypttabExtraOpts = [ "fido2-device=auto" ];
(inputs.localLib.attrsToList inputs.config.nixos.fileSystems.decrypt.auto)) };
}
)
(inputs.localLib.attrsToList inputs.config.nixos.fileSystems.decrypt.auto))
);
}
// (
if inputs.config.nixos.fileSystems.mdadm != null then
{ services.swraid = { enable = true; mdadmConf = inputs.config.nixos.fileSystems.mdadm; }; }
else {}
); );
}; };
} }