Introduce a new section in NETWORK-BOOT-TROUBLESHOOTING.md addressing issues where boot stops after start4.elf, detailing necessary config.txt settings for kernel and initramfs. Include instructions for ensuring the presence of required files in the TFTP root and a command to verify configurations on the LXC. Update initrd.img to reflect changes in the network boot process.
46 lines
1.6 KiB
Bash
Executable File
46 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Ensure TFTP config.txt on the LXC has kernel=kernel8.img and initramfs initrd.img followkernel
|
|
# so the bootloader loads the kernel and initrd (otherwise boot stops after start4.elf).
|
|
# Run on LXC: bash ensure-tftpboot-config-kernel-initrd.sh
|
|
# Or: ssh root@10.20.30.153 'bash -s' < emmc-provisioning/scripts/ensure-tftpboot-config-kernel-initrd.sh
|
|
|
|
set -e
|
|
TFTP_ROOT="${TFTP_ROOT:-/srv/tftpboot}"
|
|
CONFIG="$TFTP_ROOT/config.txt"
|
|
|
|
if [[ ! -f "$CONFIG" ]]; then
|
|
echo "Error: $CONFIG not found."
|
|
exit 1
|
|
fi
|
|
|
|
CHANGED=0
|
|
if ! grep -qE '^kernel=kernel8\.img' "$CONFIG" 2>/dev/null; then
|
|
echo "Adding kernel=kernel8.img to $CONFIG"
|
|
echo "kernel=kernel8.img" >> "$CONFIG"
|
|
CHANGED=1
|
|
fi
|
|
if ! grep -qE 'initramfs initrd\.img' "$CONFIG" 2>/dev/null; then
|
|
echo "Adding initramfs initrd.img followkernel to $CONFIG"
|
|
echo "" >> "$CONFIG"
|
|
echo "# Provisioning initramfs (network-boot-initramfs)" >> "$CONFIG"
|
|
echo "initramfs initrd.img followkernel" >> "$CONFIG"
|
|
CHANGED=1
|
|
fi
|
|
|
|
if [[ "$CHANGED" -eq 1 ]]; then
|
|
echo "Config updated. Ensure $TFTP_ROOT has kernel8.img and initrd.img."
|
|
else
|
|
echo "Config already has kernel and initramfs lines."
|
|
fi
|
|
grep -E 'kernel|initramfs' "$CONFIG" 2>/dev/null || true
|
|
|
|
# Ensure serial-prefix dir gets a real copy of config (some TFTP servers don't follow symlinks)
|
|
for serial_dir in "$TFTP_ROOT"/[0-9a-f]*/; do
|
|
[[ -d "$serial_dir" ]] || continue
|
|
if [[ -L "$serial_dir/config.txt" ]] || [[ ! -f "$serial_dir/config.txt" ]]; then
|
|
rm -f "$serial_dir/config.txt"
|
|
cp "$CONFIG" "$serial_dir/config.txt"
|
|
echo "Copied config.txt into $(basename "$serial_dir")/ (real file) so device gets full config."
|
|
fi
|
|
done
|