From ecebb1f3facddeed4d0ea916eb26be9b2346cac6 Mon Sep 17 00:00:00 2001 From: Antonio Alvarez Feijoo Date: Thu, 10 Jul 2025 14:29:54 +0200 Subject: [PATCH] Add "nfs" initrd profile nfs-utils-2.8.4 will provide its own nfsroot-generator [1] to allow mounting the real rootfs via NFSv4, so this initrd profile will enable this feature. [1] http://git.linux-nfs.org/?p=steved/nfs-utils.git;a=commit;h=ed86ea08dadafbac948c6a45629a6f3282a77233 --- mkosi/config.py | 1 + mkosi/initrd.py | 6 ++++++ mkosi/resources/man/mkosi-initrd.1.md | 2 ++ mkosi/resources/man/mkosi.1.md | 2 ++ .../resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf | 7 +++++++ .../mkosi.profiles/nfs/mkosi.conf.d/arch.conf | 7 +++++++ .../mkosi.profiles/nfs/mkosi.conf.d/debian-ubuntu.conf | 8 ++++++++ .../mkosi.profiles/nfs/mkosi.conf.d/fedora.conf | 9 +++++++++ .../mkosi.profiles/nfs/mkosi.conf.d/opensuse.conf | 9 +++++++++ 9 files changed, 51 insertions(+) create mode 100644 mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf create mode 100644 mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/arch.conf create mode 100644 mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/debian-ubuntu.conf create mode 100644 mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/fedora.conf create mode 100644 mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/opensuse.conf diff --git a/mkosi/config.py b/mkosi/config.py index 25585a8bb..b5d2898ad 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -637,6 +637,7 @@ class ToolsTreeProfile(StrEnum): 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 3c61eec6a..3c6c464ec 100644 --- a/mkosi/initrd.py +++ b/mkosi/initrd.py @@ -210,6 +210,10 @@ def network_config() -> list[str]: ] +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}" @@ -349,6 +353,8 @@ def main() -> None: cmdline += ["--profile", p] if p == "network": cmdline += network_config() + elif p == "nfs": + cmdline += nfs_config() elif p == "raid": cmdline += raid_config() diff --git a/mkosi/resources/man/mkosi-initrd.1.md b/mkosi/resources/man/mkosi-initrd.1.md index 232085ce3..4dd5d0518 100644 --- a/mkosi/resources/man/mkosi-initrd.1.md +++ b/mkosi/resources/man/mkosi-initrd.1.md @@ -46,6 +46,8 @@ initrds and Unified Kernel Images for the current running system. 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 f9fca65c8..12e46c3f0 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -1054,6 +1054,8 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`, 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.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 -- 2.47.2