Ramblings of an aging IT geek
← Ramblings of an aging IT geek
hardware

a kvm over ip i built from a pi and a capture stick

Building a working KVM-over-IP out of a Raspberry Pi, a cheap HDMI capture dongle and a USB gadget cable, so I can reach the BIOS of a headless box from the sofa instead of carrying a monitor to the cupboard.

A soldering iron and electronics on a workbench

The problem that finally pushed me into building this: a homelab box stopped booting, sat there blinking at a screen I could not see, and the only way to find out why was to unplug a monitor and keyboard from somewhere, carry them to the cupboard under the stairs, crouch on the floor, and discover it was waiting at the BIOS for someone to press a key. A commercial IP-KVM that can do that costs more than the server it would be babysitting. So I built one.

A KVM-over-IP needs to do two things the machine's own OS cannot help with, because the whole point is reaching the machine before the OS is up. It must see the video output, including the BIOS, and it must pretend to be a keyboard and mouse. A Raspberry Pi can do both, given the right cheap parts.

the parts

  • A Raspberry Pi (I used a spare Pi 4, but a Pi 3 is plenty for this).
  • A USB HDMI capture dongle, the ubiquitous sub-£15 type that shows up as a standard UVC webcam.
  • A USB-C cable for the Pi 4's data port, or for a Pi Zero, the OTG port, to act as the keyboard/mouse gadget.
  • The PiKVM software image, which ties it all together.

The capture dongle is the clever bit and the reason this is now cheap. It takes the HDMI output of the server and presents it to the Pi as if it were a webcam. The Pi does not care that it is looking at a BIOS screen rather than a person, it just grabs frames. Because it is plain HDMI capture, it sees everything the monitor would, from the very first POST message onwards. That is the part the OS-level remote tools can never do.

A small circuit board and ribbon connections on a bench

the keyboard half

Seeing the screen is only half of it. To press the key the BIOS is waiting for, the Pi has to be a keyboard. This is the USB gadget mode, where the Pi's USB port stops being a host and starts pretending to be a device. Plug the Pi into the server's USB port with the right cable and, with the gadget modules loaded, the server sees a perfectly ordinary HID keyboard and mouse. It has no idea there is a whole Linux computer on the other end relaying my keystrokes over the network.

Wiring it up by hand is fiddly, which is why PiKVM exists and why I did not do it by hand. It bundles the video capture, the HID gadget, and a web interface into one image. You flash it, plug in the dongle and the gadget cable, and you get a browser tab showing the server's screen with a working keyboard and mouse.

the part that nearly stopped me

The annoyance, and there is always one, was power and the gadget port at the same time. On a Pi 4 the natural USB-C port is also where the gadget data lives, and you cannot trivially both power the Pi and use that port as a device without a split power arrangement. PiKVM documents this, and the answer is either a Pi that separates the two more cleanly or a little dual-role power board. I went the documented route rather than being clever, soldered the recommended split, and it behaved.

# what the gadget side looks like once it is up
$ lsmod | grep -E 'libcomposite|dwc2'
libcomposite           ...
dwc2                   ...

If those two are not loaded, the server will not see a keyboard, and you will sit there pressing keys into the void wondering why nothing happens. Ask me how I know.

was it worth it

Completely. The first real test was the box that started all this. I pulled up the web interface from the sofa, watched it POST, saw it sitting at the BIOS exactly as suspected, pressed the key, and watched it carry on booting. No crouching, no carrying a monitor, no cupboard. For the cost of a Pi I already owned and a dongle the price of a takeaway, I have something that does the job of a piece of kit that costs a few hundred pounds.

The honest caveats: it is a Pi, so it is not as instant as proper out-of-band management baked into server-grade hardware, and there is a moment of trust in plugging a network-connected device into the USB and HDMI of a machine you care about. I keep it on a segmented bit of the network for that reason. But for reaching the BIOS of a headless box that has decided to sulk, it is exactly the right amount of engineering, which is to say cheap, slightly held together with documentation, and genuinely useful.