From 3024db26548f7070193ff1b1e4adabfdc71cbed3 Mon Sep 17 00:00:00 2001 From: Aiden McClelland Date: Thu, 12 Mar 2026 11:12:42 -0600 Subject: [PATCH] feat: add GRUB installer USB boot detection via configfile Install a /etc/grub.d/07_startos_installer script that searches for a .startos-installer marker file at boot. When found, it creates a "StartOS Installer" menu entry that loads the USB's own grub.cfg via configfile, making it the default with a 5-second timeout. Uses configfile instead of chainloader because on hybrid ISOs the .startos-installer marker and /boot/grub/grub.cfg are on the ISO9660 root partition, while the EFI binary lives on a separate embedded ESP. chainloader would look for the EFI binary on the wrong partition. --- debian/startos/postinst | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/debian/startos/postinst b/debian/startos/postinst index 24a433c2b..a3e3e946a 100755 --- a/debian/startos/postinst +++ b/debian/startos/postinst @@ -54,18 +54,36 @@ if [ -f /etc/default/grub ]; then cp /usr/share/grub/unicode.pf2 /boot/grub/fonts/unicode.pf2 fi # Install conditional serial console script for GRUB - cat > /etc/grub.d/01_serial << 'GRUBEOF' -#!/bin/sh -cat << 'EOF' -# Conditionally enable serial console (avoids breaking gfxterm on EFI -# systems where the serial port is unavailable) -if serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1; then - terminal_input console serial - terminal_output gfxterm serial -fi -EOF -GRUBEOF + cat > /etc/grub.d/01_serial <<-'GRUBEOF' + #!/bin/sh + cat << 'EOF' + # Conditionally enable serial console (avoids breaking gfxterm on EFI + # systems where the serial port is unavailable) + if serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1; then + terminal_input console serial + terminal_output gfxterm serial + fi + EOF + GRUBEOF chmod +x /etc/grub.d/01_serial + # Install GRUB script to boot from StartOS installer USB when present. + # At boot, GRUB searches for the .startos-installer marker and, + # if found, loads the USB's own grub.cfg as the default boot entry. + cat > /etc/grub.d/07_startos_installer <<-'GRUBEOF' + #!/bin/sh + cat << 'EOF' + search --no-floppy --file --set=installer_dev /.startos-installer + if [ -n "$installer_dev" ]; then + menuentry "StartOS Installer" --id startos-installer { + set root=$installer_dev + configfile /boot/grub/grub.cfg + } + set default=startos-installer + set timeout=5 + fi + EOF + GRUBEOF + chmod +x /etc/grub.d/07_startos_installer fi VERSION="$(cat /usr/lib/startos/VERSION.txt)"