Skip to content

Commit 4c02132

Browse files
committed
Add "network" initrd profile
This profile provides networking in the initrd using systemd-networkd.
1 parent 6aaa651 commit 4c02132

File tree

6 files changed

+35
-1
lines changed

6 files changed

+35
-1
lines changed

mkosi/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,7 @@ def default(cls) -> tuple["ToolsTreeProfile", ...]:
636636

637637
class InitrdProfile(StrEnum):
638638
lvm = enum.auto()
639+
network = enum.auto()
639640
pkcs11 = enum.auto()
640641
plymouth = enum.auto()
641642
raid = enum.auto()

mkosi/initrd.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,20 @@ def process_crypttab(staging_dir: Path) -> list[str]:
196196
return cmdline
197197

198198

199+
def network_config() -> list[str]:
200+
return [
201+
f"--extra-tree={f}:{f}"
202+
for f in (
203+
"/etc/systemd/network",
204+
"/etc/systemd/networkd.conf",
205+
"/etc/systemd/networkd.conf.d",
206+
"/etc/systemd/resolved.conf",
207+
"/etc/systemd/resolved.conf.d",
208+
)
209+
if Path(f).exists()
210+
]
211+
212+
199213
def raid_config() -> list[str]:
200214
return [
201215
f"--extra-tree={f}:{f}"
@@ -333,7 +347,9 @@ def main() -> None:
333347

334348
for p in args.profile:
335349
cmdline += ["--profile", p]
336-
if p == "raid":
350+
if p == "network":
351+
cmdline += network_config()
352+
elif p == "raid":
337353
cmdline += raid_config()
338354

339355
if args.kernel_image:

mkosi/resources/man/mkosi-initrd.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ initrds and Unified Kernel Images for the current running system.
4545
disabled.
4646

4747
The `lvm` profile enables support for LVM.
48+
The `network` profile enables support for network via **systemd-networkd**.
4849
The `pkcs11` profile enables support for PKCS#11.
4950
The `plymouth` profile provides a graphical interface at boot (animation and
5051
password prompt).

mkosi/resources/man/mkosi.1.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,7 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
10531053
disabled.
10541054

10551055
The `lvm` profile enables support for LVM.
1056+
The `network` profile enables support for network via **systemd-networkd**.
10561057
The `pkcs11` profile enables support for PKCS#11.
10571058
The `plymouth` profile provides a graphical interface at boot (animation and
10581059
password prompt).
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
3+
[Match]
4+
Distribution=|fedora
5+
Distribution=|opensuse
6+
7+
[Content]
8+
Packages=systemd-networkd
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
3+
[Match]
4+
Distribution=!arch
5+
6+
[Content]
7+
Packages=systemd-resolved

0 commit comments

Comments
 (0)