//home | tags | archives | about | grosu.nl | eulinux.org | RSS Feed

Running OpenBSD on a Hetzner.de server

floyd - Tue 10 July 2018 - openbsd, qemu

Disclaimer: I'm not running any servers at Hetzner currently, and cannot give you any recommendations over the quality of their services.

You know you just can't pass those cheap hetzner dedicated servers. I mean, come on, EUR24/month for your own dedi? Sign me up!

There's only one problem with Hetzner: you can only choose from some predefined OSs, and you need to jump through hoops if you want a custom install.

I wanted to run OpenBSD, and of course there's no OS image available. Now, there are two options:

  • request a kvm so you could mount your own .iso file, and do a custom install (but that will require you to talk to support, and you only get the kvm console for a few hours), or:
  • hack it in using the rescue console and qemu ;)

First of all, you will need an install image that has the serial console enabled. On your OpenBSD machine (you're already running OpenBSD, right? ;), download the latest installXX.fs (minirootXX.fs will do, too). Then, you need to modify boot.conf inside the install image.

    vnconfig -c vnd0 install63.fs
    mount /dev/vnd0a /mnt/
    echo "stty com0 115200" >> /mnt/etc/boot.conf
    echo "set tty com0" >> /mnt/etc/boot.conf
    umount /mnt/
    vnconfig -u vnd0

Sync your modified install63.fs to the server (which is already booted in the rescue console).

    # not sure why this was needed, qemu should do this internally
    root@rescue ~ # iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
    root@rescue ~ # qemu-system-x86_64 -m 4096 -hdb /dev/sda -hdc /dev/sdb \
        -hda install63.fs -net nic -nographic -serial mon:stdio -net user

At this point, you will be left in the serial console and should see OpenBSD booting. From here, just follow the standard OpenBSD installation process, or, in case your system has 2x HDDs/SSDs, follow the softraid installation guide as well.

After the installation is done (don't forget about installboot(8) if you're installing on softraid), you can try and see if this newly installed system boots:

    root@rescue ~ # qemu-system-x86_64 -m 4096 -hda /dev/sda -hdb /dev/sdb \
        -net nic -nographic -serial mon:stdio -net user

One last thing you'll have to do is to rename hostname.em0 to something else, depending on the NIC model available on your server. In my case, I had to:

    # cd /etc/
    # mv hostname.em0 hostname.re0

Exit qemu, and exit the rescue console. If the NIC configuration is correct, your new system should start responding to ping soon enough.