-
-
Notifications
You must be signed in to change notification settings - Fork 3k
feat(extensions): add netboot extension for TFTP+NFS diskless boot #9656
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
Draft
iav
wants to merge
16
commits into
armbian:main
Choose a base branch
from
iav:enh/netboot-extension
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b74e166
feat(core): add artifact_ready extension hook for post-build artifacts
iav 3fa8cf0
fix(templates): make nfs-boot.cmd.template architecture-agnostic
iav 03c9bcc
feat(rootfs-to-image): rootfs export tree + configurable compression
iav ad090b7
feat(extensions/netboot): netboot extension for TFTP+NFS diskless boot
iav 2e93919
feat(core): add ROOTFS_TYPE=nfs-root for full network boot
iav e4d3657
docs(netboot): add full netboot setup guide
iav 44a8879
fix(rootfs): preserve xattrs/ACLs/sparse + scope archive hook to nfs
iav d147be9
feat(extensions/netboot): netboot-deploy.sh reference deploy hook
iav b16c764
docs(extensions/netboot): troubleshooting for NFS over TCP / DHCP siaddr
iav 9bfa53b
feat(extensions/netboot): initramfs stall watchdog for nfs-root boot
iav 80f89b9
fix(host-utils): use chown -h to tolerate dangling symlinks in reset_…
iav f9e363c
style: shfmt alignment in main-config.sh and rootfs-create.sh
iav 8e04c31
fix(extensions/netboot-deploy): copy SSH_KEY to root-owned scratch be…
iav 7aa19b8
fix(rootfs): exclude_home array instead of embedded-quotes string
iav 9446841
fix(rootfs): exclude_home as single-quoted string for run_host_comman…
iav 36ac04d
fix(netboot): silence "Couldn't identify type of root file system" fo…
iav File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| #!/bin/sh | ||
| # Fix ROOTSERVER in /run/net-${interface}.conf for nfsroot=<path> (path-only) boots. | ||
| # | ||
| # The standard 70-net-conf hook sets ROOTSERVER='${new_routers}' (default | ||
| # gateway). The kernel's own IP-Config (ip=dhcp) correctly resolves the boot | ||
| # server from DHCP siaddr and records it as "bootserver" in /proc/net/pnp. | ||
| # Appending ROOTSERVER from there overrides the gateway value; shell-source | ||
| # semantics in /scripts/nfs pick the last assignment. | ||
| # | ||
| # Installed by the Armbian `netboot` extension. | ||
|
|
||
| if ${if_configured?} && ${if_up?} && [ "${protocol-}" = dhcp ] \ | ||
| && [ -f "/run/net-${interface?}.conf" ]; then | ||
|
|
||
| # Read boot server from kernel IP-Config — set from DHCP siaddr. | ||
| # /proc/net/pnp is only populated when the kernel handles DHCP itself | ||
| # (ip=dhcp in cmdline); if it is absent or has no valid bootserver entry | ||
| # we clear ROOTSERVER explicitly so nfs-mount fails fast rather than | ||
| # silently trying the default gateway written by 70-net-conf. | ||
| bootserver=$(grep '^bootserver ' /proc/net/pnp 2>/dev/null | cut -d' ' -f2) | ||
| if [ -n "$bootserver" ] && [ "$bootserver" != "0.0.0.0" ]; then | ||
| printf "ROOTSERVER='%s'\n" "$bootserver" >> "/run/net-${interface}.conf" | ||
| else | ||
| printf '71-netboot-rootpath: bootserver not found in /proc/net/pnp, clearing ROOTSERVER\n' >&2 | ||
| printf "ROOTSERVER=''\n" >> "/run/net-${interface}.conf" | ||
| fi | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Installed by the Armbian `netboot` extension for ROOTFS_TYPE=nfs-root. | ||
| # | ||
| # update-initramfs probes the root filesystem to decide whether to include | ||
| # the fsck hook. For nfs-root images the root device shows up as "/dev/nfs", | ||
| # which initramfs-tools cannot classify, producing: | ||
| # | ||
| # W: Couldn't identify type of root file system '/dev/nfs' for fsck hook | ||
| # | ||
| # fsck is not applicable to NFS anyway, so suppress the probe entirely. | ||
| FSCKFIX=no |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| #!/bin/sh | ||
| # Initramfs hook: include 71-netboot-rootpath in the dhcpcd hooks dir of the | ||
| # generated initramfs. That hook overrides ROOTSERVER in | ||
| # /run/net-${interface}.conf with the boot server from /proc/net/pnp so the | ||
| # initramfs nfs-mount script does not fall back to the default gateway. | ||
| # Companion of the Armbian `netboot` extension. | ||
|
|
||
| set -e | ||
|
|
||
| PREREQ="" | ||
| case "$1" in | ||
| prereqs) echo "$PREREQ"; exit 0 ;; | ||
| esac | ||
|
|
||
| . /usr/share/initramfs-tools/hook-functions | ||
|
|
||
| # Mirror the destination directory choice from the upstream `dhcpcd` hook | ||
| # (depends on whether dhcpcd ships its hooks in /usr/lib/dhcpcd or /usr/libexec). | ||
| if [ -e /usr/lib/dhcpcd/dhcpcd-run-hooks ]; then | ||
| dhcpcd_dir=/usr/lib/dhcpcd | ||
| else | ||
| dhcpcd_dir=/usr/libexec | ||
| fi | ||
|
|
||
| copy_file config /usr/share/initramfs-tools/dhcpcd-hooks/71-netboot-rootpath \ | ||
| "${dhcpcd_dir}/dhcpcd-hooks/71-netboot-rootpath" |
24 changes: 24 additions & 0 deletions
24
extensions/netboot/files/initramfs-scripts/init-premount/zz-netboot-watchdog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| #!/bin/sh | ||
| PREREQ="" | ||
| prereqs() { echo "$PREREQ"; } | ||
| case $1 in | ||
| prereqs) prereqs; exit 0 ;; | ||
| esac | ||
|
|
||
| # Only arm on NFS root boots. | ||
| grep -q "root=/dev/nfs" /proc/cmdline || exit 0 | ||
|
|
||
| # Trigger SysRq-B (immediate reboot, not a kernel panic — different kernel path, | ||
| # reboot via PSCI on arm64) after 10 min if NFS root mount hangs. | ||
| # nfs-bottom/zz-netboot-watchdog-cancel kills this on successful mount. | ||
| ( | ||
| sleep 600 | ||
| echo "netboot-watchdog: 10 min elapsed, forcing reboot" > /dev/kmsg 2>/dev/null | ||
| # Force-enable SysRq before triggering. If kernel.sysrq is 0 at runtime | ||
| # (hardened image, sysctl override, etc.), `echo b` writes succeed at the | ||
| # shell level but are no-ops in the kernel — the watchdog would log its | ||
| # message and then hang. Setting `1` enables the full command set. | ||
| echo 1 > /proc/sys/kernel/sysrq 2>/dev/null || true | ||
| echo b > /proc/sysrq-trigger | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| ) & | ||
| echo $! > /run/netboot-watchdog.pid | ||
21 changes: 21 additions & 0 deletions
21
extensions/netboot/files/initramfs-scripts/nfs-bottom/zz-netboot-watchdog-cancel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/bin/sh | ||
| PREREQ="" | ||
| prereqs() { echo "$PREREQ"; } | ||
| case $1 in | ||
| prereqs) prereqs; exit 0 ;; | ||
| esac | ||
|
|
||
| # Cancel the NFS watchdog started by init-premount/zz-netboot-watchdog. | ||
| # Validate the pidfile content before signalling: a stale or corrupted file | ||
| # (truncated, non-numeric, or PID 1 from kernel/init) must not produce an | ||
| # unintended kill. Only proceed for a numeric PID strictly greater than 1. | ||
| if [ -f /run/netboot-watchdog.pid ]; then | ||
| read -r watchdog_pid < /run/netboot-watchdog.pid 2>/dev/null || watchdog_pid="" | ||
| case "${watchdog_pid}" in | ||
| '' | *[!0-9]*) ;; | ||
| *) | ||
| [ "${watchdog_pid}" -gt 1 ] && kill "${watchdog_pid}" 2> /dev/null || true | ||
| ;; | ||
| esac | ||
| rm -f /run/netboot-watchdog.pid | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| fi | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.