Skip to content

Add "nfs" (and "network") initrd profiles #3766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mkosi/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
24 changes: 23 additions & 1 deletion mkosi/initrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down Expand Up @@ -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:
Expand Down
3 changes: 3 additions & 0 deletions mkosi/resources/man/mkosi-initrd.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
3 changes: 3 additions & 0 deletions mkosi/resources/man/mkosi.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions mkosi/resources/mkosi-initrd/mkosi.conf.d/10-arch.conf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Packages=
libfido2
tpm2-tss

procps-ng
util-linux

RemoveFiles=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@ Packages=
e2fsprogs
xfsprogs
dosfstools

procps-ng
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Packages=
e2fsprogs
dosfstools

procps
util-linux

# Various libraries that are dlopen'ed by systemd
Expand Down
1 change: 1 addition & 0 deletions mkosi/resources/mkosi-initrd/mkosi.conf.d/10-opensuse.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Packages=
xfsprogs
dosfstools

procps
util-linux

RemovePackages=
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Match]
Distribution=|fedora
Distribution=|opensuse

[Content]
Packages=systemd-networkd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Match]
Distribution=!arch

[Content]
Packages=systemd-resolved
7 changes: 7 additions & 0 deletions mkosi/resources/mkosi-initrd/mkosi.profiles/nfs/mkosi.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Content]
KernelModules=
fs/nfs/
net/sunrpc/
nfs_acl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Match]
Distribution=arch

[Content]
Packages=nfs-utils
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Match]
Distribution=|debian
Distribution=|ubuntu

[Content]
Packages=nfs-common
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Match]
Distribution=fedora

[Content]
Packages=
nfs-utils
libnfsidmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# SPDX-License-Identifier: LGPL-2.1-or-later

[Match]
Distribution=opensuse

[Content]
Packages=
nfs-client
libnfsidmap1