From 686f57d7f91f1c71bb10a69474e1ca795287bc71 Mon Sep 17 00:00:00 2001 From: Antonio Alvarez Feijoo Date: Tue, 4 Mar 2025 08:37:25 +0100 Subject: [PATCH] Add "raid" initrd profile This initrd profile provides support for assembling RAID arrays. --- mkosi/config.py | 1 + mkosi/initrd.py | 12 ++++++++++++ mkosi/resources/man/mkosi-initrd.1.md | 1 + mkosi/resources/man/mkosi.1.md | 1 + .../mkosi-initrd/mkosi.profiles/raid/mkosi.conf | 4 ++++ 5 files changed, 19 insertions(+) create mode 100644 mkosi/resources/mkosi-initrd/mkosi.profiles/raid/mkosi.conf diff --git a/mkosi/config.py b/mkosi/config.py index 2cd7e680e..112f5edfc 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -602,6 +602,7 @@ class ToolsTreeProfile(StrEnum): class InitrdProfile(StrEnum): lvm = enum.auto() + raid = enum.auto() def expand_delayed_specifiers(specifiers: dict[str, str], text: str) -> str: diff --git a/mkosi/initrd.py b/mkosi/initrd.py index e02dae51d..69aff88d1 100644 --- a/mkosi/initrd.py +++ b/mkosi/initrd.py @@ -124,6 +124,16 @@ def process_crypttab(staging_dir: str) -> list[str]: return cmdline +def add_raid_config() -> list[str]: + cmdline = [] + + for f in ("/etc/mdadm.conf", "/etc/mdadm.conf.d", "/etc/mdadm/mdadm.conf", "/etc/mdadm/mdadm.conf.d"): + if Path(f).exists(): + cmdline += ["--extra-tree", f"{f}:{f}"] + + return cmdline + + def initrd_finalize(staging_dir: str, output: str, output_dir: str) -> None: if output_dir: with umask(~0o700) if os.getuid() == 0 else cast(umask, contextlib.nullcontext()): @@ -274,6 +284,8 @@ def main() -> None: for p in args.profile: cmdline += ["--profile", p] + if p == "raid": + cmdline += add_raid_config() if args.kernel_image: cmdline += [ diff --git a/mkosi/resources/man/mkosi-initrd.1.md b/mkosi/resources/man/mkosi-initrd.1.md index 59f1cd231..dbe4b29bb 100644 --- a/mkosi/resources/man/mkosi-initrd.1.md +++ b/mkosi/resources/man/mkosi-initrd.1.md @@ -45,6 +45,7 @@ initrds and Unified Kernel Images for the current running system. disabled. The `lvm` profile enables support for LVM. + The `raid` profile enables support for RAID arrays. `--debug` : Enable additional debugging output. diff --git a/mkosi/resources/man/mkosi.1.md b/mkosi/resources/man/mkosi.1.md index b503b967f..a0c6bf27c 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -1022,6 +1022,7 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`, disabled. The `lvm` profile enables support for LVM. + The `raid` profile enables support for RAID arrays. `InitrdPackages=`, `--initrd-package=` : Extra packages to install into the default initrd. Takes a comma diff --git a/mkosi/resources/mkosi-initrd/mkosi.profiles/raid/mkosi.conf b/mkosi/resources/mkosi-initrd/mkosi.profiles/raid/mkosi.conf new file mode 100644 index 000000000..9694a2231 --- /dev/null +++ b/mkosi/resources/mkosi-initrd/mkosi.profiles/raid/mkosi.conf @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Content] +Packages=mdadm -- 2.47.3