Skip to content

Instantly share code, notes, and snippets.

@dakhnod
Created February 20, 2025 00:20
Show Gist options
  • Save dakhnod/93452cfb8dcf3e017916cb00a98cecb3 to your computer and use it in GitHub Desktop.
Save dakhnod/93452cfb8dcf3e017916cb00a98cecb3 to your computer and use it in GitHub Desktop.
Control your GRUB boot device (and other settings) via HTTP!
#!/usr/bin/env cat
net_dhcp
source (http,destination_ip_or_host:destination_port)/grub/config

First of all, I will have to disappoint/please you by saying that in this scenario GRUB is the one making the HTTP request, so you have to have a HTTP server running. Can be an ESP8266 or something weak.

In any case, the file /etc/grub.d/09-network just tells GRUB to source a config file via HTTP request. All you need to do is copy that file onto your linux system and run update-grub. After that, you can reboot and see if grub works as expected.

Your HTTP response (in my case under /grub/config) could look something like

set default=2

to boot entry number 3 (zero-based).

You can also set other variables like timeout there.

If you're feeling really fancy, you can replace source with configfile in the 09-network, and have whole menuenties there. Keep in mind that using configfile will not carry any env variables like default back to grub.cfg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment