-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/stratis: initrd support for stratis root volumes #229767
Changes from all commits
2eed1de
1632e73
9f1bc0f
d141144
8aa320b
3aa262b
9281424
cb410a8
765349d
feb5a3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ config, lib, pkgs, utils, ... }: | ||
let | ||
requiredStratisFilesystems = lib.attrsets.filterAttrs (_: x: utils.fsNeededForBoot x && x.stratis.poolUuid != null) config.fileSystems; | ||
in | ||
{ | ||
options = {}; | ||
config = lib.mkIf (requiredStratisFilesystems != {}) { | ||
assertions = [ | ||
{ | ||
assertion = config.boot.initrd.systemd.enable; | ||
message = "stratis root fs requires systemd stage 1"; | ||
} | ||
]; | ||
boot.initrd = { | ||
systemd = { | ||
storePaths = [ | ||
"${pkgs.stratisd}/lib/udev/stratis-base32-decode" | ||
"${pkgs.stratisd}/lib/udev/stratis-str-cmp" | ||
"${pkgs.lvm2.bin}/bin/dmsetup" | ||
"${pkgs.stratisd}/libexec/stratisd-min" | ||
"${pkgs.stratisd.initrd}/bin/stratis-rootfs-setup" | ||
]; | ||
packages = [pkgs.stratisd.initrd]; | ||
extraBin = { | ||
thin_check = "${pkgs."thin-provisioning-tools"}/bin/thin_check"; | ||
thin_repair = "${pkgs."thin-provisioning-tools"}/bin/thin_repair"; | ||
thin_metadata_size = "${pkgs."thin-provisioning-tools"}/bin/thin_metadata_size"; | ||
stratis-min = "${pkgs.stratisd}/bin/stratis-min"; | ||
}; | ||
services = | ||
lib.attrsets.mapAttrs' ( | ||
mountPoint: fileSystem: { | ||
name = "stratis-setup-${fileSystem.stratis.poolUuid}"; | ||
value = { | ||
description = "setup for Stratis root filesystem"; | ||
unitConfig.DefaultDependencies = "no"; | ||
conflicts = [ "shutdown.target" "initrd-switch-root.target" ]; | ||
onFailure = [ "emergency.target" ]; | ||
unitConfig.OnFailureJobMode = "isolate"; | ||
wants = [ "stratisd-min.service" "plymouth-start.service" ]; | ||
wantedBy = [ "initrd.target" ]; | ||
after = [ "paths.target" "plymouth-start.service" "stratisd-min.service" ]; | ||
before = [ "initrd.target" "shutdown.target" "initrd-switch-root.target" ]; | ||
environment.STRATIS_ROOTFS_UUID = fileSystem.stratis.poolUuid; | ||
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" | ||
"serpent" "cbc" "xts" "lrw" "sha1" "sha256" "sha512" | ||
"af_alg" "algif_skcipher" | ||
]; | ||
services.udev.packages = [ | ||
pkgs.stratisd.initrd | ||
pkgs.lvm2 | ||
]; | ||
}; | ||
}; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,15 @@ let | |
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; | ||
}; | ||
|
||
Comment on lines
+39
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure how I feel about extending the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, sure. But I don't see how that creates a problem. Due to how I could put this information somewhere else, I just found it convenient this way. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On second thought, I think this makes the most sense. Associating it with the FS gives the most useful information. |
||
device = mkOption { | ||
default = null; | ||
example = "/dev/sda"; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
simpleUefiGrub | ||
simpleUefiGrubSpecialisation | ||
simpleUefiSystemdBoot | ||
stratisRoot | ||
# swraid | ||
zfsroot | ||
; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why
isolate
? Seems like the upstream units all usereplace-irreversibly
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No particular reason, I just modeled it after this:
https://github.com/stratis-storage/stratisd/blob/7d0125be75a68d25329a6e72db4b581fadee536b/src/bin/generators/stratis_setup_generator.rs#L44
I can change it to
replace-irreversibly
if you want.