]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add "nfs" initrd profile 3766/head
authorAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Thu, 10 Jul 2025 12:29:54 +0000 (14:29 +0200)
committerAntonio Alvarez Feijoo <antonio.feijoo@suse.com>
Thu, 10 Jul 2025 12:49:08 +0000 (14:49 +0200)
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
mkosi/initrd.py
mkosi/resources/man/mkosi-initrd.1.md
mkosi/resources/man/mkosi.1.md
mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf [new file with mode: 0644]
mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/arch.conf [new file with mode: 0644]
mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/debian-ubuntu.conf [new file with mode: 0644]
mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/fedora.conf [new file with mode: 0644]
mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf.d/opensuse.conf [new file with mode: 0644]

index 25585a8bb652759625d4192b36cfa5106fd80ae0..b5d2898ad7c9002aadbee263c212c4f5684c7cf4 100644 (file)
@@ -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()
index 3c61eec6a5e3d7da77972575159a28c15f473611..3c6c464ec3de90fe544e5cb6b8563e2ece9063b5 100644 (file)
@@ -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()
 
index 232085ce33f1972f82a1e77a3a4a7267e562293a..4dd5d0518974220397dd5a518e265c54e6404fbb 100644 (file)
@@ -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).
index f9fca65c872f98981b601c29d3526e3a401af408..12e46c3f0762fc8f8bcf5ead4ff34d7072c28c79 100644 (file)
@@ -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 (file)
index 0000000..ad0fd92
--- /dev/null
@@ -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 (file)
index 0000000..2ab8731
--- /dev/null
@@ -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 (file)
index 0000000..6574c17
--- /dev/null
@@ -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 (file)
index 0000000..c493b19
--- /dev/null
@@ -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 (file)
index 0000000..fdfec7c
--- /dev/null
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+[Match]
+Distribution=opensuse
+
+[Content]
+Packages=
+        nfs-client
+        libnfsidmap1