diff --git a/dankclaw/host/grub b/dankclaw/host/grub new file mode 100644 index 0000000..1515f69 --- /dev/null +++ b/dankclaw/host/grub @@ -0,0 +1,40 @@ +# If you change this file or any /etc/default/grub.d/*.cfg file, +# run 'update-grub' afterwards to update /boot/grub/grub.cfg. +# For full documentation of the options in these files, see: +# info -f grub -n 'Simple configuration' + +GRUB_DEFAULT=0 +GRUB_TIMEOUT_STYLE=hidden +GRUB_TIMEOUT=0 +GRUB_DISTRIBUTOR=`( . /etc/os-release && echo ${NAME} )` +GRUB_CMDLINE_LINUX_DEFAULT="quiet splash amd_iommu=off" +GRUB_CMDLINE_LINUX="" + +# If your computer has multiple operating systems installed, then you +# probably want to run os-prober. However, if your computer is a host +# for guest OSes installed via LVM or raw disk devices, running +# os-prober can cause damage to those guest OSes as it mounts +# filesystems to look for things. +#GRUB_DISABLE_OS_PROBER=false + +# Uncomment to enable BadRAM filtering, modify to suit your needs +# This works with Linux (no patch required) and with any kernel that obtains +# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) +#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef" + +# Uncomment to disable graphical terminal +#GRUB_TERMINAL=console + +# The resolution used on graphical terminal +# note that you can use only modes which your graphic card supports via VBE/GOP/UGA +# you can see them in real GRUB with the command `videoinfo' +#GRUB_GFXMODE=640x480 + +# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux +#GRUB_DISABLE_LINUX_UUID=true + +# Uncomment to disable generation of recovery mode menu entries +#GRUB_DISABLE_RECOVERY="true" + +# Uncomment to get a beep at grub start +#GRUB_INIT_TUNE="480 440 1" diff --git a/scripts/set-dankclaw-bootline.sh b/scripts/set-dankclaw-bootline.sh new file mode 100755 index 0000000..3b7a2f4 --- /dev/null +++ b/scripts/set-dankclaw-bootline.sh @@ -0,0 +1,68 @@ +#!/usr/bin/env bash +# set-dankclaw-bootline.sh — install the tracked GRUB command line +# (dankclaw/host/grub) on Dankclaw and refresh grub.cfg. +# +# Kernel command-line state is HOST state: the deployer owns containers and +# LLM units, never /etc/default/grub, so this script is the only sanctioned way +# to change it, and the tracked file is the only sanctioned source. Run it from +# the checkout on Dankclaw. +# +# ./scripts/set-dankclaw-bootline.sh # show the diff, install, update-grub +# ./scripts/set-dankclaw-bootline.sh --reboot # ... and reboot into it +# +# The boot line is decided in +# serverAppConfigs-docs/LLM/dankclaw-iommu-translation-off.md; changing it +# without updating that decision record is a bug. Reboot takes the whole stack +# down (Caddy edge, Authentik, Pi-hole, Gitea, OpenWebUI, both LLM units) — +# plan the window, and remember frank-archon is on Dankserver and unaffected. +set -euo pipefail + +REPO="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +SRC="$REPO/dankclaw/host/grub" +DST="/etc/default/grub" +REBOOT=0 +[ "${1:-}" = "--reboot" ] && REBOOT=1 +[ $# -gt 1 ] && { echo "usage: $0 [--reboot]" >&2; exit 2; } + +[ -r "$SRC" ] || { echo "missing tracked boot line: $SRC" >&2; exit 1; } + +# Refuse to touch any machine but Dankclaw: this file is Dankclaw's, and the +# same checkout exists on hosts with a different command line. +HOST_ID="$(hostname -s 2>/dev/null || cat /etc/hostname)" +case "$HOST_ID" in + *dankclaw*) ;; + *) echo "refusing: this boot line belongs to Dankclaw, host is '$HOST_ID'" >&2; exit 1 ;; +esac + +echo "== diff (live $DST -> tracked $SRC)" +if diff -u "$DST" "$SRC" || true; then :; fi + +if cmp -s "$DST" "$SRC"; then + echo "== boot line already matches the tracked copy" +else + echo "== installing" + sudo install -m 0644 -o root -g root "$SRC" "$DST" + echo "== update-grub" + sudo update-grub +fi + +echo "== pending entry" +sudo grep -m1 "menuentry 'Ubuntu'" -A4 /boot/grub/grub.cfg | grep -m1 linux | tr ' ' '\n' | grep -E '^(iommu|amd_iommu)' || true +echo "== running kernel" +tr '\0' ' ' < /proc/cmdline; echo + +WANT="$(sed -n 's/^GRUB_CMDLINE_LINUX_DEFAULT="\(.*\)"/\1/p' "$SRC")" +NOW="$(cat /proc/cmdline)" +for tok in $WANT; do + case " $NOW " in + *" $tok "*) ;; + *) echo "PENDING: '$tok' is in grub.cfg but not in the running kernel — needs a reboot" ;; + esac +done + +if [ "$REBOOT" = 1 ]; then + echo "== rebooting now" + sudo systemctl reboot +else + echo "== not rebooting (pass --reboot)" +fi