diff --git a/mkosi/config.py b/mkosi/config.py index c966260a8..b5d2898ad 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -636,6 +636,8 @@ def default(cls) -> tuple["ToolsTreeProfile", ...]: class InitrdProfile(StrEnum): lvm = enum.auto() + network = enum.auto() + nfs = enum.auto() pkcs11 = enum.auto() plymouth = enum.auto() raid = enum.auto() diff --git a/mkosi/initrd.py b/mkosi/initrd.py index 42e00546e..3c6c464ec 100644 --- a/mkosi/initrd.py +++ b/mkosi/initrd.py @@ -196,6 +196,24 @@ 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 nfs_config() -> list[str]: + return [f"--extra-tree={f}:{f}" for f in ("/etc/idmapd.conf", "/etc/idmapd.conf.d") if Path(f).exists()] + + def raid_config() -> list[str]: return [ f"--extra-tree={f}:{f}" @@ -333,7 +351,11 @@ def main() -> None: for p in args.profile: cmdline += ["--profile", p] - if p == "raid": + if p == "network": + cmdline += network_config() + elif p == "nfs": + cmdline += nfs_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..4dd5d0518 100644 --- a/mkosi/resources/man/mkosi-initrd.1.md +++ b/mkosi/resources/man/mkosi-initrd.1.md @@ -45,6 +45,9 @@ 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 `nfs` profile enables support for NFS. It requires networking in the + initrd, using the `network` profile, or some other custom method. 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..12e46c3f0 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -1053,6 +1053,9 @@ 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 `nfs` profile enables support for NFS. It requires networking in the + initrd, using the `network` profile, or some other custom method. 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.conf.d/10-arch.conf b/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-arch.conf index d7e78f241..7c9bbfe44 100644 --- a/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-arch.conf +++ b/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-arch.conf @@ -14,6 +14,7 @@ Packages= libfido2 tpm2-tss + procps-ng util-linux RemoveFiles= diff --git a/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-azure-centos-fedora.conf b/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-azure-centos-fedora.conf index 8bb5de031..6fc183cc6 100644 --- a/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-azure-centos-fedora.conf +++ b/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-azure-centos-fedora.conf @@ -17,3 +17,5 @@ Packages= e2fsprogs xfsprogs dosfstools + + procps-ng diff --git a/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-debian-kali-ubuntu/mkosi.conf b/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-debian-kali-ubuntu/mkosi.conf index 030c097b6..e4e927d98 100644 --- a/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-debian-kali-ubuntu/mkosi.conf +++ b/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-debian-kali-ubuntu/mkosi.conf @@ -18,6 +18,7 @@ Packages= e2fsprogs dosfstools + procps util-linux # Various libraries that are dlopen'ed by systemd diff --git a/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-opensuse.conf b/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-opensuse.conf index e39b82f4b..6f830333a 100644 --- a/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-opensuse.conf +++ b/mkosi/resources/mkosi-initrd/mkosi.conf.d/10-opensuse.conf @@ -27,6 +27,7 @@ Packages= xfsprogs dosfstools + procps util-linux RemovePackages= 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 diff --git a/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf b/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf new file mode 100644 index 000000000..ad0fd9249 --- /dev/null +++ b/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Content] +KernelModules= + fs/nfs/ + net/sunrpc/ + nfs_acl diff --git a/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/arch.conf b/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/arch.conf new file mode 100644 index 000000000..2ab87316b --- /dev/null +++ b/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/arch.conf @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=arch + +[Content] +Packages=nfs-utils diff --git a/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/debian-ubuntu.conf b/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/debian-ubuntu.conf new file mode 100644 index 000000000..6574c1753 --- /dev/null +++ b/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/debian-ubuntu.conf @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=|debian +Distribution=|ubuntu + +[Content] +Packages=nfs-common diff --git a/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/fedora.conf b/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/fedora.conf new file mode 100644 index 000000000..c493b19fb --- /dev/null +++ b/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/fedora.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=fedora + +[Content] +Packages= + nfs-utils + libnfsidmap diff --git a/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/opensuse.conf b/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/opensuse.conf new file mode 100644 index 000000000..fdfec7c35 --- /dev/null +++ b/mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/opensuse.conf @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later + +[Match] +Distribution=opensuse + +[Content] +Packages= + nfs-client + libnfsidmap1