]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add kernel-modules-initrd to SplitArtifacts
authorDaanDeMeyer <daan.j.demeyer@gmail.com>
Sat, 23 Aug 2025 19:48:51 +0000 (21:48 +0200)
committerDaanDeMeyer <daan.j.demeyer@gmail.com>
Sat, 23 Aug 2025 19:49:29 +0000 (21:49 +0200)
Useful when debugging the contents of the kernel modules initrd.

mkosi/__init__.py
mkosi/config.py
mkosi/resources/man/mkosi.1.md

index 2f67bdd4be9a85b83dd6e714c1e09dec79d16ad0..8f3852cef54d4e736952b389fa37c0ad3d4282b4 100644 (file)
@@ -1590,6 +1590,9 @@ def build_kernel_modules_initrd(context: Context, kver: str) -> Path:
 
         maybe_compress(context, compression, kmods, kmods)
 
+    if ArtifactOutput.kernel_modules_initrd in context.config.split_artifacts:
+        shutil.copy(kmods, context.staging / context.config.output_split_kernel_modules_initrd)
+
     return kmods
 
 
index 8f14d78e2962d4272d2241604772001e6b523633..938738932606f358dce687420611d1577867b15f 100644 (file)
@@ -620,6 +620,7 @@ class ArtifactOutput(StrEnum):
     pcrs = enum.auto()
     roothash = enum.auto()
     os_release = enum.auto()
+    kernel_modules_initrd = enum.auto()
 
     @staticmethod
     def compat_no() -> list["ArtifactOutput"]:
@@ -2265,6 +2266,10 @@ class Config:
     def output_split_os_release(self) -> str:
         return f"{self.output}.osrelease"
 
+    @property
+    def output_split_kernel_modules_initrd(self) -> str:
+        return f"{self.output}.kernel-modules-initrd"
+
     @property
     def output_nspawn_settings(self) -> str:
         return f"{self.output}.nspawn"
@@ -2306,6 +2311,7 @@ class Config:
             self.output_split_pcrs,
             self.output_split_roothash,
             self.output_split_os_release,
+            self.output_split_kernel_modules_initrd,
             self.output_nspawn_settings,
             self.output_checksum,
             self.output_signature,
index d1844ca432cd3c413cd7bbf7d9c7429aa8e2d2c8..6bbe83cb19877139b0b1bc47dfabaca064828fb5 100644 (file)
@@ -651,8 +651,8 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
 `SplitArtifacts=`, `--split-artifacts=`
 :   The artifact types to split out of the final image. A comma-delimited
     list consisting of `uki`, `kernel`, `initrd`, `os-release`, `prcs`, `partitions`,
-    `roothash` and `tar`. When building a bootable image `kernel` and `initrd`
-    correspond to their artifact found in the image (or in the UKI),
+    `roothash`, `kernel-modules-initrd` and `tar`. When building a bootable image `kernel`
+    and `initrd` correspond to their artifact found in the image (or in the UKI),
     while `uki` copies out the entire UKI. If `pcrs` is specified, a JSON
     file containing the pre-calculated TPM2 digests is written out, according
     to the [UKI specification](https://uapi-group.org/specifications/specs/unified_kernel_image/#json-format-for-pcrsig),
@@ -673,6 +673,11 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
     When `roothash` is specified and a dm-verity disk image is built, the dm-verity
     roothash is written out as a separate file, which is useful for offline signing.
 
+    `kernel-modules-initrd` corresponds to the separate kernel modules initrd which
+    mkosi appends to the main initrd. This is primarily intended for debugging as many
+    initrd inspection tools don't properly handle multiple initrds appended to each
+    other.
+
     By default `uki`, `kernel` and `initrd` are split out.
 
 `RepartDirectories=`, `--repart-directory=`