Skip to content

Instantly share code, notes, and snippets.

@sagrodat
sagrodat / usb-grub-boot-switch.sh
Created August 16, 2026 12:40
GRUB dual-boot switch via USB presence
#!/bin/sh
#
# usb-grub-boot-switch.sh
#
# Switches the default GRUB boot entry based on whether a specific
# USB drive is plugged in at boot time.
#
# USB plugged in -> boots the entry set as BOOT_ENTRY_ID below
# USB not plugged -> boots the default entry from /etc/default/grub
# (GRUB_DEFAULT=<ID>)