Developer creates boot button to switch between Linux and Windows | Computer

O Windows it’s the Linux can live peacefully on the same computer (or almost), but Stephen Holdaway I was tired of how the boot manager works GRUB. He then had the idea of ​​creating a physical solution to switch between the two systems: a selection button that was installed on his desk.

Windows x Linux selector (image: disclosure / Stephen Holdaway)

On the project page, Holdaway explains that he has used Linux and Windows on the same machine for a decade, but that the standard process of switching between the two operating systems via GRUB bothered him.

To enter Linux, the developer simply turned on the computer and waited for the operating system to load. But, to enter Windows, he had to select that system from the GRUB options list within a time limit that, if not respected, would load Linux by default.

Tired of this ritual, the developer thought of a more practical alternative:

How do I know which operating system I want to use in advance, why not create a physical switch to select between Linux and Windows?

Stephen Holdaway

Holdaway developed a solution based on two main components: a selection button and a tiny USB card equipped with a STM32 microcontroller (a low-cost chip and ARM architecture).

Of course, it was not enough to connect one thing to the other and start using it. But, studying the functioning of GRUB, the developer discovered details that paved the way for the solution.

All the

The entire kit for the Holdaway project (image: publicity / Stephen Holdaway)

Holdaway realized, for example, that GRUB has native support for USB devices, but when the modules responsible for this are triggered, the mechanisms that give access to the computer’s storage units (where the operating systems are installed, obviously) are disabled to avoid conflicts.

However, if the USB device has a storage function (such as a pendrive), it can be read by GRUB without making it difficult to access devices of the type existing on the machine.

One of the steps then consisted of making an encoding for the USB card to be recognized as a storage device, with the right to an emulated file system (Holdaway chose FAT12 to be simple and well documented).

The firmware of the USB card was coded by the developer in order to guide GRUB to load the operating system corresponding to the chosen position in the selector.

In short, the trick works like this: the USB device, already connected to the switch, is connected to the computer; when it is turned on, GRUB reads the device and executes the instructions to load Windows or Linux, depending on the position of the button. The result is demonstrated in the following video:

We can imagine some possible disadvantages for this selection, such as the risk of the button being accidentally pressed when the computer is already in use. But, as the USB device only interacts with GRUB and it is only triggered at boot time, it is assumed that the selector will not cause any damage or interference to the active operating system.

In this sense, the developer explained via Twitter that the USB card is not a real storage device, so recording instructions that could be triggered by changing the selector are ignored.

Of course, instead of having all this work, Stephen Holdaway could have used Windows Subsystem for Linux (WSL) or another solution of its kind to run Linux on Windows. But, also via Twitter, the developer explained that he prefers to rely on Linux natively because he considers Gnome and KDE more comfortable environments for his work.

The selector up and running (image: disclosure / Stephen Holdaway)

The selector up and running (image: disclosure / Stephen Holdaway)

To find more detailed information on how to create something like this, visit the project page.

Leave a Comment