From: Antonio Alvarez Feijoo Date: Thu, 10 Jul 2025 12:48:42 +0000 (+0200) Subject: Add "network" initrd profile X-Git-Tag: v26~183^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c021322d87a1ee8c8f8e7fd042ec3f3cb808b15;p=thirdparty%2Fmkosi.git Add "network" initrd profile This profile provides networking in the initrd using systemd-networkd. --- diff --git a/mkosi/config.py b/mkosi/config.py index c966260a8..25585a8bb 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -636,6 +636,7 @@ class ToolsTreeProfile(StrEnum): class InitrdProfile(StrEnum): lvm = enum.auto() + network = enum.auto() pkcs11 = enum.auto() plymouth = enum.auto() raid = enum.auto() diff --git a/mkosi/initrd.py b/mkosi/initrd.py index 42e00546e..3c61eec6a 100644 --- a/mkosi/initrd.py +++ b/mkosi/initrd.py @@ -196,6 +196,20 @@ def process_crypttab(staging_dir: Path) -> list[str]: return cmdline +def network_config() -> list[str]: + return [ + f"--extra-tree={f}:{f}" + for f in ( + "/etc/systemd/network", + "/etc/systemd/networkd.conf", + "/etc/systemd/networkd.conf.d", + "/etc/systemd/resolved.conf", + "/etc/systemd/resolved.conf.d", + ) + if Path(f).exists() + ] + + def raid_config() -> list[str]: return [ f"--extra-tree={f}:{f}" @@ -333,7 +347,9 @@ def main() -> None: for p in args.profile: cmdline += ["--profile", p] - if p == "raid": + if p == "network": + cmdline += network_config() + elif p == "raid": cmdline += raid_config() if args.kernel_image: diff --git a/mkosi/resources/man/mkosi-initrd.1.md b/mkosi/resources/man/mkosi-initrd.1.md index 5131c3102..232085ce3 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 `network` profile enables support for network via **systemd-networkd**. The `pkcs11` profile enables support for PKCS#11. The `plymouth` profile provides a graphical interface at boot (animation and password prompt). diff --git a/mkosi/resources/man/mkosi.1.md b/mkosi/resources/man/mkosi.1.md index feea867a9..f9fca65c8 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -1053,6 +1053,7 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`, disabled. The `lvm` profile enables support for LVM. + The `network` profile enables support for network via **systemd-networkd**. The `pkcs11` profile enables support for PKCS#11. The `plymouth` profile provides a graphical interface at boot (animation and password prompt). diff --git a/mkosi/resources/mkosi-initrd/mkosi.profiles/network/mkosi.conf.d/systemd-networkd.conf b/mkosi/resources/mkosi-initrd/mkosi.profiles/network/mkosi.conf.d/systemd-networkd.conf new file mode 100644 index 000000000..b81de4627 --- /dev/null +++ b/mkosi/resources/mkosi-initrd/mkosi.profiles/network/mkosi.conf.d/systemd-networkd.conf @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=|fedora +Distribution=|opensuse + +[Content] +Packages=systemd-networkd diff --git a/mkosi/resources/mkosi-initrd/mkosi.profiles/network/mkosi.conf.d/systemd-resolved.conf b/mkosi/resources/mkosi-initrd/mkosi.profiles/network/mkosi.conf.d/systemd-resolved.conf new file mode 100644 index 000000000..4ecc6e5ac --- /dev/null +++ b/mkosi/resources/mkosi-initrd/mkosi.profiles/network/mkosi.conf.d/systemd-resolved.conf @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=!arch + +[Content] +Packages=systemd-resolved