Wake, Boot, Repeat: Remote OS Selection With GRUB And ESP

Bits of GRUB syntax on pink background

What do you do when you need to choose an OS at boot but aren’t physically near your machine? [Dakhnod]’s inventive solution is a mix of GRUB, Wake-on-LAN (WOL), and a lightweight ESP8266 running a simple HTTP server. In the past, [dakhnod] already enlightened us with another smart ESP hack. This one’s a clever combination of network booting and remote control that opens up possibilities beyond the usual dual-boot selector.

At its core, the hack modifies GRUB to fetch its boot configuration over HTTP. The ESP8266 (or any low-power device) serves up a config file defining which OS should launch. The trick lies in adding a custom script that tells GRUB to source an external config:

#!/usr/bin/env cat 
net_dhcp 
source (http,destination_ip_or_host:destination_port)/grub/config

Since GRUB itself makes the HTTP request, the system needs a running web server. That could be a Raspberry Pi, another machine, or the ESP itself. From there, a WOL-enabled ESP button can wake the PC and set the boot parameters remotely.

Is it secure? Well, that depends on your network. An open, unauthenticated web server dishing out GRUB configs is risky, but within a controlled LAN or a VLAN-segmented environment, it’s an intriguing option. Automation possibilities are everywhere — imagine remotely booting test rigs, toggling between OS environments for debugging, or even setting up kiosk machines that reconfigure themselves based on external triggers.

For those looking to take it further, using configfile instead of source allows for more dynamic menu entries, although it won’t persist environment variables. You could even combine it with this RasPi hack to control the uptime of the HTTP server. The balance between convenience and security is yours to strike.

If you’ve got your own wild GRUB customisation, let’s hear it!

14 thoughts on “Wake, Boot, Repeat: Remote OS Selection With GRUB And ESP

    1. Maybe it would be possible to serve as a boot image just the boot manager, altered on the basis of what OS is supposed to be booted. That wouldn’t require much storage, since the actual OS would still be on the machine.

  1. Kinda neat. Years ago (pre ESP!) we solved this with writing the config to a shared partition which grub read. Typically it rebooted into an automated DD script to re-image the machine, then again into the newly imaged OS. Worked fine unless a guest OS crashed so badly we had to physically reboot it.

  2. haha this hack makes me angry, just because it reminds me of the frustration of working with headless or remote machines. which luckily, i don’t have to be reminded of because (a) i’m not in system administration anymore, and (b) the tools for dealing with that nightmare have evolved tremendously in the last 20+ years.

    but anyways imo the hack for this is called netboot. it’s 2025 and every motherboard supports PXE. you don’t have to go buy an EEPROM with a bootloader flashed on it and hope you have one of the network cards that accepts it. it’s built in to your BIOS now.

    it’s kind of neat that grub has every feature under the sun but in practice if you actually want to decide what to boot up over the network then PXE is designed just for that

    1. Even better than PXE/WoL – just about any Intel vPro-branded PC made in the last 15 years will support hardware-level KVM for full video redirection from initial POST onwards. Enabling & configuring it used to be an exercise in frustration but it’s now straightforward.

      I may be betraying ignorance here, but who still dual-boots? I thought all the cool kids were now using Proxmox or equivalent.

      1. Addendum (I’m the author of the “David” comment above) – I see there’s already another commenter here who beat me to the use of the handle “David”. I have no desire to confuse or impersonate, so will use “David H’ moving forward. Apologies if that, in itself, has caused confusion :)

      2. Time and a place for both, but on the whole I agree with you the hardware you get now is so potent, virtualisation tech fairly seamless from baremetal so its rarely really worth the effort to dual boot.

        That said I do still dual boot myself – when you want to experiment with something lower power or that just doesn’t have huge disk capacity spare inbuilt, or want to be really really darn sure your ‘secure’ banking install isn’t open to a security vulnerability in the virtualisation layers…

  3. Lots of esp8266 web server arduino sketches on the Web, usually for displaying sensor reading, or screen button relay control. Customize to push grub info when labeled screen button pushed?

  4. What do you do when you need to choose an OS at boot but aren’t physically near your machine?

    I ssh in (usually via OpenVNC), then:

    $ sudo grub-reboot ‘1>1’ # or whatever sequence number I want to boot.
    $ sudo reboot

    Simple as that. :)

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.