mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 09:36:20 +09:00
improve stratis initrd support
it is now possible to supply a stratis pool uuid for every filesystem, and if that filesystem is required for boot, the relevant pool will be started in the initramfs.
This commit is contained in:
parent
3aa262b644
commit
92814241a8
4 changed files with 37 additions and 39 deletions
|
@ -476,7 +476,7 @@ In addition to numerous new and upgraded packages, this release has the followin
|
||||||
|
|
||||||
- `boot.initrd.luks.device.<name>` has a new `tryEmptyPassphrase` option, this is useful for OEM's who need to install an encrypted disk with a future settable passphrase
|
- `boot.initrd.luks.device.<name>` has a new `tryEmptyPassphrase` option, this is useful for OEM's who need to install an encrypted disk with a future settable passphrase
|
||||||
|
|
||||||
- there is a new `boot/stratisroot.nix` module that enables booting from a volume managed by the Stratis storage management daemon. Use `boot.stratis.rootPoolUuid` to configure the pool containing the root volume
|
- there is a new `boot/stratisroot.nix` module that enables booting from a volume managed by the Stratis storage management daemon. Use `fileSystems.<name>.stratis.poolUuid` to configure the pool containing the fs.
|
||||||
|
|
||||||
- Lisp gained a [manual section](https://nixos.org/manual/nixpkgs/stable/#lisp), documenting a new and backwards incompatible interface. The previous interface will be removed in a future release.
|
- Lisp gained a [manual section](https://nixos.org/manual/nixpkgs/stable/#lisp), documenting a new and backwards incompatible interface. The previous interface will be removed in a future release.
|
||||||
|
|
||||||
|
|
|
@ -1,19 +1,11 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, utils, ... }:
|
||||||
let
|
let
|
||||||
types = lib.types;
|
types = lib.types;
|
||||||
|
requiredStratisFilesystems = lib.attrsets.filterAttrs (_: x: utils.fsNeededForBoot x && x.stratis.poolUuid != null) config.fileSystems;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.boot.stratis = {
|
options = {};
|
||||||
rootPoolUuid = lib.mkOption {
|
config = lib.mkIf (builtins.length (lib.attrsets.attrValues requiredStratisFilesystems) != 0) {
|
||||||
type = types.uniq (types.nullOr types.str);
|
|
||||||
description = lib.mdDoc ''
|
|
||||||
UUID of the stratis pool that the root fs is located in
|
|
||||||
'';
|
|
||||||
example = "04c68063-90a5-4235-b9dd-6180098a20d9";
|
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
config = lib.mkIf (config.boot.stratis.rootPoolUuid != null) {
|
|
||||||
assertions = [
|
assertions = [
|
||||||
{
|
{
|
||||||
assertion = config.boot.initrd.systemd.enable;
|
assertion = config.boot.initrd.systemd.enable;
|
||||||
|
@ -36,25 +28,29 @@ in
|
||||||
thin_metadata_size = "${pkgs."thin-provisioning-tools"}/bin/thin_metadata_size";
|
thin_metadata_size = "${pkgs."thin-provisioning-tools"}/bin/thin_metadata_size";
|
||||||
stratis-min = "${pkgs.stratisd}/bin/stratis-min";
|
stratis-min = "${pkgs.stratisd}/bin/stratis-min";
|
||||||
};
|
};
|
||||||
services = {
|
services =
|
||||||
stratis-setup = {
|
lib.attrsets.mapAttrs' (
|
||||||
description = "setup for Stratis root filesystem";
|
mountPoint: fileSystem: {
|
||||||
unitConfig.DefaultDependencies = "no";
|
name = "stratis-setup-${fileSystem.stratis.poolUuid}";
|
||||||
conflicts = [ "shutdown.target" "initrd-switch-root.target" ];
|
value = {
|
||||||
onFailure = [ "emergency.target" ];
|
description = "setup for Stratis root filesystem";
|
||||||
unitConfig.OnFailureJobMode = "isolate";
|
unitConfig.DefaultDependencies = "no";
|
||||||
wants = [ "stratisd-min.service" "plymouth-start.service" ];
|
conflicts = [ "shutdown.target" "initrd-switch-root.target" ];
|
||||||
wantedBy = [ "initrd.target" ];
|
onFailure = [ "emergency.target" ];
|
||||||
after = [ "paths.target" "plymouth-start.service" "stratisd-min.service" ];
|
unitConfig.OnFailureJobMode = "isolate";
|
||||||
before = [ "initrd.target" "shutdown.target" "initrd-switch-root.target" ];
|
wants = [ "stratisd-min.service" "plymouth-start.service" ];
|
||||||
environment.STRATIS_ROOTFS_UUID = config.boot.stratis.rootPoolUuid;
|
wantedBy = [ "initrd.target" ];
|
||||||
serviceConfig = {
|
after = [ "paths.target" "plymouth-start.service" "stratisd-min.service" ];
|
||||||
Type = "oneshot";
|
before = [ "initrd.target" "shutdown.target" "initrd-switch-root.target" ];
|
||||||
ExecStart = "${pkgs.stratisd.initrd}/bin/stratis-rootfs-setup";
|
environment.STRATIS_ROOTFS_UUID = fileSystem.stratis.poolUuid;
|
||||||
RemainAfterExit = "yes";
|
serviceConfig = {
|
||||||
};
|
Type = "oneshot";
|
||||||
};
|
ExecStart = "${pkgs.stratisd.initrd}/bin/stratis-rootfs-setup";
|
||||||
};
|
RemainAfterExit = "yes";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
) requiredStratisFilesystems;
|
||||||
};
|
};
|
||||||
availableKernelModules = [ "dm-thin-pool" "dm-crypt" ] ++ [ "aes" "aes_generic" "blowfish" "twofish"
|
availableKernelModules = [ "dm-thin-pool" "dm-crypt" ] ++ [ "aes" "aes_generic" "blowfish" "twofish"
|
||||||
"serpent" "cbc" "xts" "lrw" "sha1" "sha256" "sha512"
|
"serpent" "cbc" "xts" "lrw" "sha1" "sha256" "sha512"
|
||||||
|
|
|
@ -36,6 +36,15 @@ let
|
||||||
description = lib.mdDoc "Location of the mounted file system.";
|
description = lib.mdDoc "Location of the mounted file system.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
stratis.poolUuid = lib.mkOption {
|
||||||
|
type = types.uniq (types.nullOr types.str);
|
||||||
|
description = lib.mdDoc ''
|
||||||
|
UUID of the stratis pool that the fs is located in
|
||||||
|
'';
|
||||||
|
example = "04c68063-90a5-4235-b9dd-6180098a20d9";
|
||||||
|
default = null;
|
||||||
|
};
|
||||||
|
|
||||||
device = mkOption {
|
device = mkOption {
|
||||||
default = null;
|
default = null;
|
||||||
example = "/dev/sda";
|
example = "/dev/sda";
|
||||||
|
|
|
@ -1038,12 +1038,6 @@ in {
|
||||||
"mkdir -p /mnt/boot",
|
"mkdir -p /mnt/boot",
|
||||||
"mount /dev/vda1 /mnt/boot"
|
"mount /dev/vda1 /mnt/boot"
|
||||||
)
|
)
|
||||||
|
|
||||||
(header, pool_line) = machine.succeed("stratis pool list").splitlines()
|
|
||||||
index = header.find("UUID")
|
|
||||||
uuid = pool_line[index - 32: index + 4]
|
|
||||||
machine.succeed("mkdir -p /mnt/etc/nixos")
|
|
||||||
machine.succeed(f"printf %s {uuid} > /mnt/etc/nixos/rootPoolUuid.txt")
|
|
||||||
'';
|
'';
|
||||||
bootLoader = "systemd-boot";
|
bootLoader = "systemd-boot";
|
||||||
extraInstallerConfig = { modulesPath, ...}: {
|
extraInstallerConfig = { modulesPath, ...}: {
|
||||||
|
@ -1058,6 +1052,5 @@ in {
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
extraConfig = "boot.stratis.rootPoolUuid = builtins.readFile ./rootPoolUuid.txt;";
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue