Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/evidence/own-gpu-driver/rung2/window-boot.sh # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / evidence / own-gpu-driver / rung2 / window-boot.sh` 103 lines ยท 6919 bytes Raw Blame History 1 #!/usr/bin/env bash 2 # window-boot.sh: the self-reverting boot path for L332 GPU windows (NoNvDriver review, 2026-10-26). 3 # 4 # Replaces "write /etc/modprobe.d/zz-aien-gpu-window*.conf and reboot". That file persists: if part 2 never runs, every 5 # later boot (watchdog reset, power cycle) comes up WITHOUT NVIDIA's driver until a person deletes it. Here instead: 6 # - GRUB default stays entry 0 (NVIDIA's driver). GRUB_DEFAULT is not touched; grub.cfg is not regenerated. 7 # - /boot/grub/custom.cfg (sourced by /etc/grub.d/41_custom) adds ONE extra entry 'aien-gpu-window'. 'arm' selects it 8 # for the next boot only, via grub-reboot (grubenv next_entry; 00_header honours it with GRUB_DEFAULT=0 and clears 9 # it on use). 10 # - That entry adds: aien.gpuwindow=1 (activates the two inert units), systemd.watchdog_sec=30 (PID 1 arms the SBSA 11 # hardware watchdog for this boot: a hard hang resets the box into the default entry), panic=10 oops=panic 12 # (a kernel panic or oops reboots after 10 s into the default entry). 13 # - aien-gpu-window-hold.service writes the "do not load NVIDIA" file to /run/modprobe.d (tmpfs: this boot only). 14 # - aien-gpu-window-lease.service reboots 25 min after boot (L405 lease 20 min + 5 min restore margin). 15 # Any reboot after the window boot, wanted or not, lands on NVIDIA's driver with nothing to clean up. 16 # 17 # Usage: 18 # window-boot.sh check (default) read-only: builds the entry and units into a temp dir, runs grub-script-check 19 # and systemd-analyze verify, shows what install would change. Writes nothing outside /tmp. 20 # window-boot.sh install --yes copies custom.cfg and the two units (inert on normal boots). Coordinator + Drake approval. 21 # window-boot.sh arm --yes next boot only = 'aien-gpu-window' (grub-reboot). Inside the window only. 22 # window-boot.sh status what is installed / armed now. 23 # window-boot.sh uninstall --yes removes custom.cfg and the units. 24 set -euo pipefail 25 export PATH=$PATH:/usr/sbin:/sbin 26 HERE=$(cd "$(dirname "$0")" && pwd) 27 ENTRY=aien-gpu-window 28 UNITS="aien-gpu-window-hold.service aien-gpu-window-lease.service" 29 KVER=$(uname -r) 30 CUSTOM=/boot/grub/custom.cfg 31 die() { echo "WINDOW_BOOT: FAIL ($*)" >&2; exit 1; } 32 33 # The entry repeats the running kernel's command line (minus GRUB's BOOT_IMAGE) and adds the window flags. 34 build_entry() { 35 local uuid cmd 36 uuid=$(sed -n 's/.*root=UUID=\([0-9a-fA-F-]\{36\}\).*/\1/p' /proc/cmdline) 37 [[ -n $uuid ]] || die "no root=UUID= in /proc/cmdline" 38 [[ $(findmnt -no UUID -T /boot) == "$uuid" ]] || die "/boot is not on the root filesystem $uuid; entry paths would be wrong" 39 [[ -f /boot/vmlinuz-$KVER && -f /boot/initrd.img-$KVER ]] || die "kernel or initrd for $KVER missing in /boot" 40 cmd=$(sed 's/^BOOT_IMAGE=[^ ]* //' /proc/cmdline) 41 case " $cmd " in *" aien.gpuwindow="*|*" module_blacklist="*|*" modprobe.blacklist="*) die "running cmdline already carries window flags";; esac 42 cat < "$t/custom.cfg" 58 grub-script-check "$t/custom.cfg" || die "grub-script-check refused $t/custom.cfg" 59 echo "entry: grub-script-check PASS ($t/custom.cfg)" 60 grep -q 'custom.cfg' /etc/grub.d/41_custom || die "/etc/grub.d/41_custom does not source custom.cfg" 61 grep -q 'next_entry' /etc/grub.d/00_header || die "/etc/grub.d/00_header has no next_entry (grub-reboot would not work)" 62 echo "grub: 41_custom sources custom.cfg; 00_header honours next_entry; GRUB_DEFAULT=$(sed -n 's/^GRUB_DEFAULT=//p' /etc/default/grub) unchanged" 63 [[ -e /sys/class/watchdog/watchdog0 ]] && echo "watchdog: $(cat /sys/class/watchdog/watchdog0/identity) present ($(cat /sys/class/watchdog/watchdog0/state))" \ 64 || echo "watchdog: NONE (systemd.watchdog_sec has no device; hangs need a power cycle)" 65 for u in $UNITS; do cp "$HERE/window-boot/$u" "$t/$u"; done 66 (cd "$t" && systemd-analyze verify --man=no $UNITS) || die "systemd-analyze verify refused the units" 67 echo "units: systemd-analyze verify PASS" 68 local initrd; initrd=$(lsinitramfs "/boot/initrd.img-$KVER") && [[ -n $initrd ]] || die "cannot list /boot/initrd.img-$KVER: initramfs check would pass silently" 69 grep -qE '/nvidia(_uvm|_modeset|_drm)?\.ko' <<< "$initrd" && die "nvidia modules in initramfs: /run/modprobe.d would come too late" 70 echo "initramfs: no nvidia modules" 71 if [[ -e $CUSTOM ]]; then diff -u "$CUSTOM" "$t/custom.cfg" && echo "custom.cfg: installed copy identical" || echo "custom.cfg: install would REPLACE the file above"; else echo "custom.cfg: not installed (install would create it)"; fi 72 echo "WINDOW_BOOT CHECK: PASS (nothing written outside $t)" 73 } 74 75 need_yes() { [[ ${1:-} == --yes ]] || die "$2 needs --yes"; } 76 77 case ${1:-check} in 78 check) check ;; 79 install) need_yes "${2:-}" install; check 80 t=$(mktemp -d /tmp/window-boot.XXXXXX); build_entry > "$t/custom.cfg" 81 [[ ! -e $CUSTOM ]] || cmp -s "$CUSTOM" "$t/custom.cfg" || die "$CUSTOM exists with other content; refusing to overwrite" 82 sudo install -m 0644 "$t/custom.cfg" "$CUSTOM" 83 for u in $UNITS; do sudo install -m 0644 "$HERE/window-boot/$u" "/etc/systemd/system/$u"; done 84 sudo systemctl daemon-reload; sudo systemctl enable $UNITS 85 echo "WINDOW_BOOT INSTALL: PASS (inert until 'arm')" ;; 86 arm) need_yes "${2:-}" arm 87 [[ -f $CUSTOM ]] && grep -qF -- "--id $ENTRY" "$CUSTOM" || die "entry not installed" 88 for u in $UNITS; do systemctl is-enabled -q "$u" || die "$u not enabled"; done 89 sudo grub-reboot "$ENTRY" 90 [[ $(grub-editenv /boot/grub/grubenv list | sed -n 's/^next_entry=//p') == "$ENTRY" ]] || die "grubenv next_entry not set" 91 echo "WINDOW_BOOT ARM: PASS (next boot only: $ENTRY; every later boot: default entry with NVIDIA)" ;; 92 status) 93 echo "default: GRUB_DEFAULT=$(sed -n 's/^GRUB_DEFAULT=//p' /etc/default/grub); grubenv: $(grub-editenv /boot/grub/grubenv list | tr '\n' ' ')" 94 [[ -f $CUSTOM ]] && echo "custom.cfg: installed" || echo "custom.cfg: absent" 95 for u in $UNITS; do echo "$u: $(systemctl is-enabled "$u" 2>/dev/null || true) $(systemctl is-active "$u" 2>/dev/null || true)"; done 96 grep -q 'aien.gpuwindow=1' /proc/cmdline && echo "this boot: WINDOW BOOT" || echo "this boot: normal" ;; 97 uninstall) need_yes "${2:-}" uninstall 98 sudo systemctl disable $UNITS || true 99 for u in $UNITS; do sudo rm -f "/etc/systemd/system/$u"; done 100 sudo rm -f "$CUSTOM"; sudo systemctl daemon-reload 101 echo "WINDOW_BOOT UNINSTALL: PASS" ;; 102 *) die "unknown command ${1}" ;; 103 esac