Initialize AlmaLinux PXE boot repo

This commit is contained in:
andersen committed 2026-03-08 09:23:03 -04:00
commit 75c7000b36
9 files changed
+580

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
# Local artifacts
*.log
*.tmp
*.swp
*.swo
# PXE/TFTP assets
tftpboot/
httpboot/
images/
isos/
/*.iso
/*.ISO
AlmaLinux-10.1-x86_64-minimal.iso
# Python
.venv/
__pycache__/
# Editor
.DS_Store
.idea/
.vscode/
+67
View File
@@ -0,0 +1,67 @@
# pxe_boot_alma
AlmaLinux 10 PXE boot and unattended Kickstart deployment for a two-server setup:
- `server1`: PXE host that provides DHCP/TFTP/HTTP boot assets with `dnsmasq`
- `server2`: target host that boots from the network and installs AlmaLinux automatically
This repo is meant to be the source of truth for:
- `dnsmasq` configuration
- PXE boot menus
- AlmaLinux Kickstart files
- helper scripts to build and sync boot assets
- replication documentation
## Goal
Boot `server2` from the network, point it at an AlmaLinux 10 install tree hosted by `server1`, and complete installation with a Kickstart file that can also bootstrap your existing `kickstart` and `tools` repos in `%post`.
## Repo Layout
- `dnsmasq/`: sample `dnsmasq` config
- `boot/grub2/`: UEFI GRUB menu example
- `boot/pxelinux.cfg/`: BIOS PXELINUX menu example
- `kickstarts/`: AlmaLinux Kickstart templates
- `scripts/`: helper scripts for ISO extraction and post-install bootstrap
- `docs/`: replication and operating notes
## High-Level Flow
1. Put the AlmaLinux ISO in this repo root or another local path.
2. Use [`scripts/sync_alma_tree.sh`](/usr/local/valherun/pxe_boot_alma/scripts/sync_alma_tree.sh) to copy the ISO contents into an HTTP-served tree on `server1`.
3. Copy `vmlinuz` and `initrd.img` from the Alma tree into your TFTP directory.
4. Install the sample `dnsmasq` config from [`dnsmasq/dnsmasq.conf.example`](/usr/local/valherun/pxe_boot_alma/dnsmasq/dnsmasq.conf.example) and adjust interface/IP/path values.
5. Use the sample PXE menu files from [`boot/grub2/grub.cfg`](/usr/local/valherun/pxe_boot_alma/boot/grub2/grub.cfg) and [`boot/pxelinux.cfg/default`](/usr/local/valherun/pxe_boot_alma/boot/pxelinux.cfg/default).
6. Customize [`kickstarts/alma10-auto.ks`](/usr/local/valherun/pxe_boot_alma/kickstarts/alma10-auto.ks).
7. Boot `server2` from PXE.
## Existing Repo Integration
The starter Kickstart includes a `%post` phase that can call your current repos:
- `/usr/local/valherun/kickstart`
- `/usr/local/valherun/tools`
The wrapper script is [`scripts/post-install-bootstrap.sh`](/usr/local/valherun/pxe_boot_alma/scripts/post-install-bootstrap.sh). It clones those repos onto the installed Alma host and then runs the reusable pieces directly:
- `kickstart/bin/create_valherun.sh`
- `kickstart/bash_profiles.sh --adduser`
- `tools/bin/install_codex_access.sh`
- `tools/bin/update_sshd_config.sh`
This avoids relying on `kickstart.sh --all` for unattended installs.
## First Files To Edit
Before using this in production, update:
- [`dnsmasq/dnsmasq.conf.example`](/usr/local/valherun/pxe_boot_alma/dnsmasq/dnsmasq.conf.example)
- [`boot/grub2/grub.cfg`](/usr/local/valherun/pxe_boot_alma/boot/grub2/grub.cfg)
- [`boot/pxelinux.cfg/default`](/usr/local/valherun/pxe_boot_alma/boot/pxelinux.cfg/default)
- [`kickstarts/alma10-auto.ks`](/usr/local/valherun/pxe_boot_alma/kickstarts/alma10-auto.ks)
- [`scripts/post-install-bootstrap.sh`](/usr/local/valherun/pxe_boot_alma/scripts/post-install-bootstrap.sh) if you want different bootstrap behavior
## Replication Guide
Full setup steps live in [`docs/replication.md`](/usr/local/valherun/pxe_boot_alma/docs/replication.md).
+17
View File
@@ -0,0 +1,17 @@
set default=0
set timeout=10
menuentry 'Install AlmaLinux 10 (Automated Kickstart)' {
linuxefi /vmlinuz-alma10 \
ip=dhcp \
inst.repo=http://192.168.10.10/alma/10/BaseOS/x86_64/os \
inst.ks=http://192.168.10.10/kickstarts/alma10-auto.ks
initrdefi /initrd-alma10.img
}
menuentry 'Install AlmaLinux 10 (Manual Installer)' {
linuxefi /vmlinuz-alma10 \
ip=dhcp \
inst.repo=http://192.168.10.10/alma/10/BaseOS/x86_64/os
initrdefi /initrd-alma10.img
}
+15
View File
@@ -0,0 +1,15 @@
DEFAULT menu.c32
PROMPT 0
TIMEOUT 50
MENU TITLE AlmaLinux 10 PXE Boot
LABEL alma10-auto
MENU LABEL Install AlmaLinux 10 (Automated Kickstart)
KERNEL /vmlinuz-alma10
APPEND initrd=/initrd-alma10.img ip=dhcp inst.repo=http://192.168.10.10/alma/10/BaseOS/x86_64/os inst.ks=http://192.168.10.10/kickstarts/alma10-auto.ks
LABEL alma10-manual
MENU LABEL Install AlmaLinux 10 (Manual Installer)
KERNEL /vmlinuz-alma10
APPEND initrd=/initrd-alma10.img ip=dhcp inst.repo=http://192.168.10.10/alma/10/BaseOS/x86_64/os
+31
View File
@@ -0,0 +1,31 @@
# Example dnsmasq config for AlmaLinux PXE on server1.
# Adjust interface names, addresses, and file paths before use.
interface=eth0
bind-interfaces
domain-needed
bogus-priv
log-dhcp
# DHCP range for PXE clients
dhcp-range=192.168.10.100,192.168.10.150,255.255.255.0,12h
dhcp-option=option:router,192.168.10.1
dhcp-option=option:dns-server,192.168.10.10
# Set a fixed lease for a known PXE target if desired.
# dhcp-host=52:54:00:12:34:56,server2,192.168.10.20
enable-tftp
tftp-root=/srv/tftp
# Detect firmware type. BIOS clients use PXELINUX; UEFI clients use GRUB EFI.
dhcp-match=set:bios,option:client-arch,0
dhcp-match=set:efi64,option:client-arch,7
dhcp-match=set:efi64,option:client-arch,9
dhcp-boot=tag:bios,pxelinux.0
dhcp-boot=tag:efi64,EFI/BOOT/BOOTX64.EFI
# If server1 is not the DHCP server, convert this to proxy-DHCP mode instead.
# dhcp-range=192.168.10.0,proxy,255.255.255.0
+233
View File
@@ -0,0 +1,233 @@
# Replication Guide
This document describes how to reproduce the AlmaLinux PXE + Kickstart environment on a fresh `server1`.
## Topology
- `server1`: PXE services
- runs `dnsmasq`
- serves TFTP boot files
- serves Alma install tree and Kickstarts over HTTP
- `server2`: install target
- configured to network boot first
Example addresses:
- `server1`: `192.168.10.10`
- `server2`: DHCP client on the same VLAN/subnet
Replace these with your real values everywhere below.
## Services
You need these on `server1`:
- `dnsmasq`
- an HTTP server such as `nginx`, `httpd`, or `caddy`
- TFTP root directory
Common paths used in this repo:
- TFTP root: `/srv/tftp`
- HTTP root: `/srv/www`
- Alma install tree: `/srv/www/alma/10/BaseOS/x86_64/os`
- Kickstarts: `/srv/www/kickstarts`
## 1. Install Packages On Server 1
Example for AlmaLinux or RHEL-family hosts:
```bash
sudo dnf install -y dnsmasq nginx syslinux-tftpboot grub2-efi-x64 shim-x64
```
Example for Debian or Ubuntu:
```bash
sudo apt-get update
sudo apt-get install -y dnsmasq nginx pxelinux syslinux-common grub-efi-amd64-bin shim-signed
```
Package names vary slightly by distro. Adjust as needed for your host.
## 2. Prepare HTTP And TFTP Paths
```bash
sudo mkdir -p /srv/tftp/pxelinux.cfg
sudo mkdir -p /srv/tftp/EFI/BOOT
sudo mkdir -p /srv/www/alma/10/BaseOS/x86_64/os
sudo mkdir -p /srv/www/kickstarts
```
## 3. Copy AlmaLinux ISO Contents To HTTP Root
Place the ISO in this repo, then run:
```bash
./scripts/sync_alma_tree.sh \
--iso ./AlmaLinux-10.1-x86_64-minimal.iso \
--http-root /srv/www/alma/10/BaseOS/x86_64/os
```
This mounts the ISO read-only and copies the contents into the HTTP install tree.
## 4. Copy PXE Boot Files
From the extracted Alma tree, copy:
- `images/pxeboot/vmlinuz`
- `images/pxeboot/initrd.img`
Example:
```bash
sudo cp /srv/www/alma/10/BaseOS/x86_64/os/images/pxeboot/vmlinuz /srv/tftp/vmlinuz-alma10
sudo cp /srv/www/alma/10/BaseOS/x86_64/os/images/pxeboot/initrd.img /srv/tftp/initrd-alma10.img
```
For BIOS clients, also copy PXELINUX assets:
```bash
sudo cp /usr/share/syslinux/pxelinux.0 /srv/tftp/
sudo cp /usr/share/syslinux/menu.c32 /srv/tftp/
sudo cp /usr/share/syslinux/libutil.c32 /srv/tftp/
```
For UEFI clients, install or copy the GRUB EFI loader that matches your distro packaging.
Typical examples:
- `/boot/efi/EFI/almalinux/grubx64.efi`
- `/usr/lib/grub/x86_64-efi-signed/grubnetx64.efi.signed`
- `/usr/share/shim/BOOTX64.EFI`
## 5. Publish Kickstart Files
Copy the Kickstart file into the HTTP root:
```bash
sudo cp kickstarts/alma10-auto.ks /srv/www/kickstarts/alma10-auto.ks
sudo cp scripts/post-install-bootstrap.sh /srv/www/kickstarts/post-install-bootstrap.sh
```
The sample Kickstart expects to be reachable at:
```text
http://192.168.10.10/kickstarts/alma10-auto.ks
```
Adjust the IP or hostname in:
- `kickstarts/alma10-auto.ks`
- `kickstarts/post-install-bootstrap.sh`
- `boot/grub2/grub.cfg`
- `boot/pxelinux.cfg/default`
## 6. Install dnsmasq Config
Use [`dnsmasq/dnsmasq.conf.example`](/usr/local/valherun/pxe_boot_alma/dnsmasq/dnsmasq.conf.example) as the base.
Important fields to customize:
- interface name
- DHCP range
- router and DNS values
- `dhcp-boot`
- `enable-tftp`
- `tftp-root`
Then install and restart:
```bash
sudo cp dnsmasq/dnsmasq.conf.example /etc/dnsmasq.d/pxe-alma.conf
sudo systemctl enable --now dnsmasq
sudo systemctl restart dnsmasq
```
## 7. Install PXE Menu Files
BIOS:
```bash
sudo cp boot/pxelinux.cfg/default /srv/tftp/pxelinux.cfg/default
```
UEFI:
```bash
sudo cp boot/grub2/grub.cfg /srv/tftp/grub.cfg
```
Some UEFI layouts expect the config under:
- `/srv/tftp/EFI/BOOT/grub.cfg`
- `/srv/tftp/grub/grub.cfg`
Use the location expected by your GRUB EFI binary.
## 8. Make Sure HTTP Is Serving The Tree
Verify from another host:
```bash
curl -I http://192.168.10.10/alma/10/BaseOS/x86_64/os/
curl -I http://192.168.10.10/kickstarts/alma10-auto.ks
```
## 9. Boot Server 2
Set `server2` to:
- UEFI PXE boot, or BIOS PXE boot depending on hardware
- network boot ahead of disk boot
When PXE works correctly:
1. `server2` gets an IP from `dnsmasq`
2. it downloads the bootloader from TFTP
3. it loads kernel + initrd
4. installer fetches the install tree from HTTP
5. Kickstart runs unattended
## 10. Post-Install Bootstrap
The sample Kickstart calls [`scripts/post-install-bootstrap.sh`](/usr/local/valherun/pxe_boot_alma/scripts/post-install-bootstrap.sh) during `%post`.
That script:
1. installs `git`, `curl`, `sudo`, and related basics if missing
2. clones your `kickstart` repo to `/usr/local/valherun/kickstart`
3. clones your `tools` repo to `/usr/local/valherun/tools`
4. optionally runs:
- `kickstart/bin/create_valherun.sh`
- `kickstart/bash_profiles.sh --adduser`
- `tools/bin/install_codex_access.sh`
- `tools/bin/update_sshd_config.sh`
This gives you a second-stage bootstrap after the base OS install is complete.
## Notes About Your Existing kickstart.sh
Your current [`kickstart.sh`](/usr/local/valherun/kickstart/kickstart.sh) is useful for interactive host bootstrap, but it is not ideal for unattended Kickstart `%post` as-is because:
- it prompts by default
- `--all` re-enables the Unraid path internally
For unattended Alma installs, this repo uses the reusable sub-scripts directly instead.
## Validation Checklist
Before attempting install:
- `dnsmasq --test`
- `curl -I` against the Alma tree
- `curl -I` against the Kickstart file
- confirm `vmlinuz` and `initrd.img` exist in TFTP root
- confirm `server2` can PXE on the intended NIC and VLAN
## Suggested Next Improvements
- add a host-specific Kickstart per target machine
- add static DHCP reservation for `server2`
- add UEFI HTTP Boot if the hardware supports it
- add a wrapper to sync repo files directly into `/srv/tftp` and `/srv/www`
+48
View File
@@ -0,0 +1,48 @@
#version=RHEL10
text
eula --agreed
lang en_US.UTF-8
keyboard us
timezone America/New_York --utc
url --url="http://192.168.10.10/alma/10/BaseOS/x86_64/os"
network --bootproto=dhcp --device=link --activate --hostname=alma10-auto
rootpw --lock
firewall --enabled --service=ssh
selinux --enforcing
services --enabled=sshd,chronyd
firstboot --disable
reboot
zerombr
clearpart --all --initlabel
autopart --type=lvm
bootloader --location=mbr
%packages
@^minimal-environment
curl
git
sudo
wget
bash-completion
vim-enhanced
%end
%post --erroronfail --log=/root/ks-post.log
set -euxo pipefail
mkdir -p /root/pxe_boot_alma
cat > /root/pxe_boot_alma/post-install-bootstrap.sh <<'EOF'
#!/bin/bash
set -euo pipefail
bash <(curl -fsSL http://192.168.10.10/kickstarts/post-install-bootstrap.sh)
EOF
chmod 700 /root/pxe_boot_alma/post-install-bootstrap.sh
/root/pxe_boot_alma/post-install-bootstrap.sh
%end
+70
View File
@@ -0,0 +1,70 @@
#!/bin/bash
set -euo pipefail
REPO_BASE="${REPO_BASE:-/usr/local/valherun}"
KICKSTART_REPO_URL="${KICKSTART_REPO_URL:-https://git.valherun.com/valherun/kickstart.git}"
TOOLS_REPO_URL="${TOOLS_REPO_URL:-https://git.valherun.com/valherun/tools.git}"
INSTALL_VALHERUN="${INSTALL_VALHERUN:-true}"
INSTALL_CODEX="${INSTALL_CODEX:-true}"
UPDATE_SSHD="${UPDATE_SSHD:-true}"
DEPLOY_BASH_PROFILES="${DEPLOY_BASH_PROFILES:-true}"
ensure_pkg() {
if command -v dnf >/dev/null 2>&1; then
dnf install -y "$@"
elif command -v yum >/dev/null 2>&1; then
yum install -y "$@"
elif command -v apt-get >/dev/null 2>&1; then
apt-get update
apt-get install -y "$@"
else
echo "Unsupported package manager" >&2
exit 1
fi
}
clone_or_update() {
local url="$1"
local dest="$2"
if [[ -d "$dest/.git" ]]; then
git -C "$dest" pull --ff-only
return
fi
mkdir -p "$(dirname "$dest")"
git clone "$url" "$dest"
}
if [[ $EUID -ne 0 ]]; then
echo "This script must run as root." >&2
exit 1
fi
ensure_pkg git curl sudo wget bash-completion
clone_or_update "$KICKSTART_REPO_URL" "$REPO_BASE/kickstart"
clone_or_update "$TOOLS_REPO_URL" "$REPO_BASE/tools"
if [[ "$INSTALL_VALHERUN" == "true" ]]; then
bash "$REPO_BASE/kickstart/bin/create_valherun.sh" valherun || true
fi
if [[ "$DEPLOY_BASH_PROFILES" == "true" ]]; then
if id -u valherun >/dev/null 2>&1; then
bash "$REPO_BASE/kickstart/bash_profiles.sh" --adduser
else
bash "$REPO_BASE/kickstart/bash_profiles.sh"
fi
fi
if [[ "$INSTALL_CODEX" == "true" ]]; then
bash "$REPO_BASE/tools/bin/install_codex_access.sh"
fi
if [[ "$UPDATE_SSHD" == "true" ]]; then
bash "$REPO_BASE/tools/bin/update_sshd_config.sh"
fi
echo "Post-install bootstrap complete."
+76
View File
@@ -0,0 +1,76 @@
#!/bin/bash
set -euo pipefail
ISO_PATH=""
HTTP_ROOT=""
MOUNT_DIR=""
usage() {
cat <<'EOF'
Usage: sync_alma_tree.sh --iso FILE --http-root DIR [--mount-dir DIR]
Mount an AlmaLinux ISO read-only and copy its contents into an HTTP-served
install tree for PXE/Kickstart use.
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--iso)
ISO_PATH="$2"
shift 2
;;
--http-root)
HTTP_ROOT="$2"
shift 2
;;
--mount-dir)
MOUNT_DIR="$2"
shift 2
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown option: $1" >&2
usage >&2
exit 1
;;
esac
done
if [[ -z "$ISO_PATH" || -z "$HTTP_ROOT" ]]; then
usage >&2
exit 1
fi
if [[ ! -f "$ISO_PATH" ]]; then
echo "ISO not found: $ISO_PATH" >&2
exit 1
fi
if [[ $EUID -ne 0 ]]; then
echo "Re-running with sudo..."
exec sudo "$0" "$@"
fi
if [[ -z "$MOUNT_DIR" ]]; then
MOUNT_DIR="$(mktemp -d /tmp/alma-iso.XXXXXX)"
fi
cleanup() {
if mountpoint -q "$MOUNT_DIR"; then
umount "$MOUNT_DIR"
fi
rmdir "$MOUNT_DIR" 2>/dev/null || true
}
trap cleanup EXIT
mkdir -p "$HTTP_ROOT"
mount -o loop,ro "$ISO_PATH" "$MOUNT_DIR"
rsync -aH --delete "$MOUNT_DIR"/ "$HTTP_ROOT"/
echo "Synced AlmaLinux tree to $HTTP_ROOT"