Use wake on LAN they said, it'll be fun they said. ðŸŽ‰

Posted February 12, 2023 by Victor Sonck ‐ 8 min read

This is the story of how unbelievably cumbersome it has been to try and setup my remote working space.

The Premise

The idea is simple, I have a framework laptop (which I LOVE), but it’s not very powerful. For heavy tasks like video editing, gaming and deep learning, I want to be able to remote into my home setup to offload the heavy lifting.

A nice, simple UI that does what it needs to do

The Operating System Mess

My setup consists of my laptop (running Linux), my GPU desktop (dual booting Windows and Linux) and my M1 Mac Mini (running MacOS Ventura 13.1).

Each operating system has its niche. Before the Mac mini, I used my Windows setup for Gaming, Video Editing and Fusion360. Linux, on the other hand is absolutely excellent for development, rock stable and does not serve you ads while opening the start menu.

This setup is troublesome, though. My video editing work is for coding-focussed videos, so I’d record everything on Linux, hop over to Windows to start editing, see something wasn’t right, reboot, hop back to Linux, deal with shared storage, … Yeah, not ideal. If I wanted to edit on the go I’m even more out of luck, because a laptop that can edit on Windows is heavy and ugly and has 0 battery life. Even if that wasn’t true, I’d also want to have Linux on it, to do some proper coding. Not to mention adobe software crashing every 1-2 hours on my Windows machine and even file explorer doing the well known white “Not Responsive” thing…

In comes the idea of a mac, with the new M1/2 chips, those machines seem like the magic unicorn of power, battery life and an OS that can handle both coding and video editing (and other software like Fusion360). So I bought myself a second hand M1 Mac Mini, just to see if I could handle the OS. The results of that experiment are matter for another blogpost, but the thesis is that it can take over everything from my Windows machine except for gaming and nothing from my Linux machine, which still leads in the development departement.

So now I have 2 machines sharing 3 operating systems, each has their own reason for being there.

I agree this is a mess, but it is my mess.

The Plan

To allow for my Linux laptop to do anything else than code, I want to be able to remote into any of my three home-based OS’s.

Ideally I have some sort of webpage/app/endpoint that I can reach from outside of my home network to boot any of my three home operating systems. I could then install the absolutetly excellent Parsec to take over any of my screens or use SSH for remote GPU Linux development using the equally excellent VSCode Remote Development Plugin. Great!

This is actually rather easily achieved: have a low-power raspberry pi running on my network at all times. It allows secure remote connections using a third excellent tool that I love called Zerotier. The Pi would serve a small little webpage, that has three buttons to launch any of the OS’s and keeps tab on which ones are currently active. On the backend the Pi could use wake on LAN packets to raise the selected machine, which would autostart Parsec and SSH and BOOM, done. Easy!

Not easy: Dual Boot

Assume for a second I can reliably get my PC to boot using the RPi, how would I choose which operating system I want to boot into? After a bit of searching and getting advice, I didn’t really find anything to my liking. Sure, random Windows tools like iReboot might be able to change the boot order from Windows, or I could labour to get Windows to be in Grub and then use grub-reboot, but that’s all very clunky and in my opinion a black hole of issues and bugs and edge-cases.

Instead, let’s just use a Raspberry Pi Zero, which can emulate a USB keyboard, and have it mash F11 to get to the boot menu, then just do something like arrow down + enter to boot a specific entry. The Pi would dangle at the back of the PC, being powered by it’s always-on USB port. Not super unclean actually.

Raspberry Pi Zero dangling from the back of my PC

Thanks to this excellent article, I got this to work rather quickly and wrote a small flask app that could send off the magic packet followed by a preset number of keystrokes to get to the correct operating system.

NULL_CHAR = chr(0)
def press_key(char_nr):
    with open("/dev/hidg0", "rb+") as fd:
        fd.write((NULL_CHAR*2+chr(char_nr)+NULL_CHAR*5).encode())
    with open("/dev/hidg0", "rb+") as fd:
        fd.write((NULL_CHAR*8).encode())

@app.get("/windows")
def launch_windows():
    wake_pc()
    start_time = time.time()
    # Mash F11 for 2 minutes straight
    while time.time() - start_time < 120:
        try:
            press_key(68)  # 68 = F11
        except BrokenPipeError:
            continue
    press_key(81) # 81 = Down Arrow
    press_key(40) # 40 = Enter
    return {"STATUS": "SUCCESS"}

Not easy 2: Windows

This seemed to work just fine. Until I was at my friends house and the PC just didn’t want to boot. After much searching, it appeared that when the last booted OS before the shutdown was Windows, WOL wouldn’t work because the network card was shut down. (I did lay on my stomach under my desk while shutting down to see the status light go out. They stay on when linux shuts down. I do not have a picture of this.)

Mind you, I followed every instruction I could find on how to enable WOL on Windows 11. None of them worked. This offical microsoft forum post best describes my troubles, after which a Microsoft rep just kind of said it’s a PC or BIOS issue. I would like to add here that Linux worked 100% all the time always on the same, exact hardware. So no, that’s not the issue, it’s your spyware that refuses my calls.

At this point every single article or blogpost I found asked me to change the same damn settings that I already changed hours before and had checked and rechecked. So, back to hardware it is. I hereby welcome to my WOL setup: the relay.

change_inflation

Every PC enthusiast knows you can boot a PC by simply shorting 2 pins on the motherboard, this is exactly what the power button does. So it was quite easy to solder together a splitter, that connects these 2 pins to both the power button (so it’s still functional) and the relay in parallel. Now the raspberry pi can simply enable the relay for half a second and we’re in business.

It’s telling that this approach was quicker in nr. of hours spent than to try to get WOL working on Windows 11. Also, when asking how to power up a PC using a relay online, the amount of people just shouting “JuSt UsE WakE ON laN” is immense. It’s actually good advice and made me see how frustrated I had become to see it over and over, knowing it just didn’t work for me.

Not easy 3: Windows again

Did you know, that if you take over a remote windows machine that has no mouse attached to it, you cannot see the cursor in remote desktop software? Yeah, that’s a thing. So to be able to actually see what I’m doing, there is now an old mouse just … attached … to the back of my PC.

A random old mouse lying behind my PC

Not easy 4: MacOS

The PC was up first, because surely MacOS, being based on UNIX, would support WOL out of the box, no questions asked, right? Right? Wrong. They somehow borked it too (one more) and there is no way I’m diving in the unibody aluminium mac mini case to solder some power leads straight onto the mac’s PCB.

SO BACK TO F****ING HARDWARE IT IS, RIGHT??

This time you can see the desperation in my execution: I clamped a servo to the power cable and allowed the pi to steer it. It pushes the power button for me. I hope this jank setup cringes the apple engineers into re-enabling WOL. What has my life come to.

change_inflation

Not easy 5: Windows again again

Oh did you also know that if there is not active monitor attached to Windows, it will just not send anything to a remote desktop software by default? Yeah FUN RIGHT? Luckily for me, Parsec has me covered there by having an option to fallback to a virtual monitor that they provide, which you can then take over.

Not easy 6: MacOS again

It seems for now that Parsec isn’t launching at boot and the actual Parsec window even has to be in focus for another PC to take control over it. I have not yet found the mental enegery to do something about it.

Conclusion

Currently my setup half-works thanks to a giant mess of cables and electronics. The raspberry pi uses a relay to enable my PC, then emulates a keyboard and mashes the boot setup button for a while before launching a hard-coded set of keystrokes to boot into the correct operating system. It can also start the mac mini by means of a servo actually physically pushing the power button, but I have no solution as of yet to actually remotely take it over.

Did I mention Linux worked first try for everything?