]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add "raid" initrd profile
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Tue, 4 Mar 2025 07:37:25 +0000 (08:37 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Tue, 4 Mar 2025 08:27:14 +0000 (09:27 +0100)
This initrd profile provides support for assembling RAID arrays.

mkosi/config.py
mkosi/initrd.py
mkosi/resources/man/mkosi-initrd.1.md
mkosi/resources/man/mkosi.1.md
mkosi/resources/mkosi-initrd/mkosi.profiles/raid/mkosi.conf [new file with mode: 0644]

index 2cd7e680e792e703b2e28f98be12e6ff8bec24de..112f5edfc4ddd97a53740492b27dee658a7da3a9 100644 (file)
@@ -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:
index e02dae51df6c27323d648e714135b7f492bcb923..69aff88d1e89f4e64f3ba83250ad9d9744182312 100644 (file)
@@ -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 += [
index 59f1cd2315cf53ce1d9bc82543aed147f3b4f2a2..dbe4b29bba1f362469d558700fb4fd468866c97e 100644 (file)
@@ -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.
index b503b967fe41924c42b225185eacf987133bc8bc..a0c6bf27cb91b1741b185eadab044ef94b68a9b5 100644 (file)
@@ -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 (file)
index 0000000..9694a22
--- /dev/null
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Content]
+Packages=mdadm