From: Daan De Meyer Date: Fri, 13 Feb 2026 16:05:40 +0000 (+0100) Subject: Don't build default initrd for directory images by default X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c984506005259cdcbde325ec996f1920b27d3c3;p=thirdparty%2Fmkosi.git Don't build default initrd for directory images by default We switched this around a long time ago to accomodate virtiofsd qemu boots as those needed an initrd without the image necessarily being bootable. Given Fedora and Arch now allow for direct kernel boot with virtiofsd without needing an initrd, let's switch back the default to not building an initrd for directory images, so that the same config can be used to build disk images for vm boot and directory images for container boot without having to build the initrd when building directory images. --- diff --git a/mkosi/config.py b/mkosi/config.py index 94ed5a965..a897b9a42 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -1125,7 +1125,7 @@ def config_default_initrds(namespace: dict[str, Any]) -> list[Path]: return [] if namespace["bootable"] == ConfigFeature.auto and ( - namespace["output_format"] == OutputFormat.cpio + namespace["output_format"] in (OutputFormat.cpio, OutputFormat.directory) or namespace["output_format"].is_extension_or_portable_image() or namespace["overlay"] ): @@ -5298,7 +5298,7 @@ def want_kernel(config: Config) -> bool: return False if config.bootable == ConfigFeature.auto and ( - config.output_format == OutputFormat.cpio + config.output_format in (OutputFormat.cpio, OutputFormat.directory) or config.output_format.is_extension_or_portable_image() or config.overlay ): diff --git a/mkosi/resources/man/mkosi.1.md b/mkosi/resources/man/mkosi.1.md index 86fe39aa3..906b6abdb 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -1124,10 +1124,11 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`, : Use user-provided initrd(s). Takes a comma-separated list of paths to initrd files. This option may be used multiple times in which case the initrd lists are combined. If this setting is not specified and a bootable image is requested, - **mkosi** will automatically build a default initrd. To disable building the default - initrd, assign the empty string to this setting. To build the default initrd even when - specifying this setting, the special value `default` can be assigned alongside the other - values. + **mkosi** will automatically build a default initrd if the image looks like it might + be a bootable image based on a few factors (output format, is a kernel package installed, ...). + To disable building the default initrd, assign the empty string to this setting. To build the + default initrd even when specifying this setting, the special value `default` can be assigned + alongside the other values. When the default initrd is used, it can be further configured using the settings below and with `mkosi.initrd.conf` which can either be a file or directory containing extra configuration