diff --git a/docs/md/archiso.md b/docs/md/archiso.md index f7630a7..53f854b 100644 --- a/docs/md/archiso.md +++ b/docs/md/archiso.md @@ -216,3 +216,75 @@ sudo dd if=~/m-archy-out/m-archy-*.iso of=/dev/sdX bs=4M status=progress oflag=s ``` Or use `ventoy` / `balenaEtcher` as alternatives. + +--- + +## PXE Boot / netboot.xyz + +Every build also produces a `*-netboot-*.tar.gz` artifact alongside the ISO. This tarball contains the kernel, initrd, and squashfs image laid out for HTTP-based PXE booting. The live initramfs already includes the `archiso_pxe_http` hook, so no extra packages or custom kernel parameters beyond the ones below are required. + +### 1. Build with a netboot URL + +```bash +bash setup/archiso/build.sh --netboot-url http://your-server/m-archy +# or combined with an answerfile: +bash setup/archiso/build.sh --preconf --netboot-url http://your-server/m-archy +``` + +This generates `~/m-archy-out/m-archy-netboot.ipxe` alongside the netboot tarball. + +### 2. Serve the artifacts + +Extract the netboot tarball so that its contents are reachable at the base URL you provided: + +```bash +# On your web server +mkdir -p /srv/http/m-archy +tar -xzf ~/m-archy-out/*-netboot-*.tar.gz -C /srv/http/m-archy +cp ~/m-archy-out/m-archy-netboot.ipxe /srv/http/m-archy/ +``` + +The server must expose at minimum: + +``` +http://your-server/m-archy/arch/boot/x86_64/vmlinuz-linux +http://your-server/m-archy/arch/boot/x86_64/initramfs-linux.img +http://your-server/m-archy/arch/x86_64/airootfs.sfs +http://your-server/m-archy/m-archy-netboot.ipxe +``` + +### 3. Add to netboot.xyz + +In your netboot.xyz configuration (or the **Custom iPXE** option in the netboot.xyz menu), chainload the generated script: + +``` +chain http://your-server/m-archy/m-archy-netboot.ipxe +``` + +Or add a named menu item: + +``` +item m-archy M-Archy Arch Linux Installer +... +:m-archy +chain http://your-server/m-archy/m-archy-netboot.ipxe +``` + +### Manual iPXE parameters + +If you prefer to write the boot stanza by hand (e.g. for a self-hosted netboot.xyz with YAML menus): + +``` +kernel http://your-server/m-archy/arch/boot/x86_64/vmlinuz-linux \ + archiso_http_srv=http://your-server/m-archy/ \ + archisobasedir=arch \ + ip=dhcp +initrd http://your-server/m-archy/arch/boot/x86_64/initramfs-linux.img +boot +``` + +| Kernel parameter | Purpose | +|-----------------|---------| +| `archiso_http_srv=/` | Base URL the initramfs fetches the squashfs from (trailing slash required) | +| `archisobasedir=arch` | Subdirectory prefix — matches `install_dir` in `profiledef.sh` | +| `ip=dhcp` | Acquire an IP before the HTTP fetch | diff --git a/setup/archiso/build.sh b/setup/archiso/build.sh index acdc82a..c07eac0 100755 --- a/setup/archiso/build.sh +++ b/setup/archiso/build.sh @@ -1,12 +1,14 @@ #!/usr/bin/env bash -# build.sh — build the M-Archy Arch Linux ISO +# build.sh — build the M-Archy Arch Linux ISO + netboot artifacts # # Usage: -# bash build.sh [--preconf [FILE]] [OUT_DIR] +# bash build.sh [--preconf [FILE]] [--netboot-url URL] [OUT_DIR] # -# --preconf Embed ~/answerfile.json into the ISO at /answerfile.json -# --preconf FILE Embed the specified answerfile instead -# OUT_DIR Output directory (default: ~/m-archy-out, or $OUT_DIR env) +# --preconf Embed ~/answerfile.json into the ISO at /answerfile.json +# --preconf FILE Embed the specified answerfile instead +# --netboot-url URL Base URL where netboot artifacts will be served +# (generates m-archy-netboot.ipxe in OUT_DIR) +# OUT_DIR Output directory (default: ~/m-archy-out, or $OUT_DIR env) set -euo pipefail @@ -15,6 +17,7 @@ DOTFILES_DIR="$(cd "$SCRIPT_DIR/../.." && pwd)" # ── Argument parsing ─────────────────────────────────────────────────────────── PRECONF_FILE="" +NETBOOT_URL="" OUT_ARG="" while [[ $# -gt 0 ]]; do @@ -32,6 +35,14 @@ while [[ $# -gt 0 ]]; do PRECONF_FILE="${1#--preconf=}" shift ;; + --netboot-url) + [[ $# -gt 1 ]] || { echo "ERROR: --netboot-url requires a URL argument" >&2; exit 1; } + NETBOOT_URL="$2"; shift 2 + ;; + --netboot-url=*) + NETBOOT_URL="${1#--netboot-url=}" + shift + ;; -*) echo "Unknown flag: $1" >&2; exit 1 ;; @@ -113,3 +124,48 @@ if [[ -n "$PRECONF_FILE" ]]; then else echo "No answerfile — guided (manual) installer will start automatically on boot." fi + +# ── Netboot artifacts ────────────────────────────────────────────────────────── +NETBOOT_TARBALL="$(ls "$OUT_DIR/"*-netboot-*.tar.gz 2>/dev/null | head -n1 || true)" +if [[ -n "$NETBOOT_TARBALL" ]]; then + echo + echo "Netboot artifact: $NETBOOT_TARBALL" + echo " Extract and serve its contents from an HTTP server, then boot via PXE." + echo " Internal layout (relative to tarball root):" + tar -tzf "$NETBOOT_TARBALL" | sed 's/^/ /' + + if [[ -n "$NETBOOT_URL" ]]; then + # Strip trailing slash for consistency + BASE_URL="${NETBOOT_URL%/}" + IPXE_FILE="$OUT_DIR/m-archy-netboot.ipxe" + cat > "$IPXE_FILE" < to generate an iPXE script." + fi +fi diff --git a/setup/archiso/overlay/profiledef.sh b/setup/archiso/overlay/profiledef.sh index c2f9df7..8a45852 100644 --- a/setup/archiso/overlay/profiledef.sh +++ b/setup/archiso/overlay/profiledef.sh @@ -6,7 +6,7 @@ iso_publisher="The_miro " iso_application="M-Archy Arch Linux Installer" iso_version="$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y.%m.%d)" install_dir="arch" -buildmodes=('iso') +buildmodes=('iso' 'netboot') bootmodes=('bios.syslinux' 'uefi.systemd-boot') arch="x86_64" pacman_conf="pacman.conf"