by Joshua Branson — August 05, 2022
I am of the opinion, that in order to learn how to use an operating system, you have to use it often. Since I am madly in love with Guix System, but have an interest in the GNU/Hurd and OpenBSD, I might as well install those OSs on a virtual machine! I have already done that with the GNU/Hurd, and today I also did it for OpenBSD.
I was not that hard to do. I used this guide to install OpenBSD on a vm.
First let’s create a qemu img for OpenBSD.
qemu-img create -f qcow2 hd0.qcow2.img 100G
Now, let's create an install script.
cat install-bsd.sh #!/bin/sh qemu-system-x86_64 -m 2048 \ -no-reboot \ -cdrom cd71.iso \ -drive if=virtio,file=hd0.qcow2.img,format=qcow2 \ -enable-kvm \ -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 \ -device virtio-net,netdev=mynet0 \ -smp 2
As always installing OpenBSD is an absolute breeze. I do not know how to
manually partition things, so I just chose the auto install. Also OpenBSD
us.swapcaps.dvorak keyboard layout. That’s my layout! How cool is
that!? And it sets up that layout for the console and X by default. Guix
System does that, but not so well for wayland.
Now let's create a run script.
#!/bin/sh qemu-system-x86_64 -m 4G \ -no-reboot \ -drive if=virtio,file=hd0.qcow2.img,format=qcow2 \ -enable-kvm \ -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 \ -device virtio-net,netdev=mynet0 \ -smp 2
I find the
-no-reboot option helpful, because OpenBSD likes to try to autoreboot
itself, even when you give it the command:
I have ran OpenBSD before for about a week before, and it is always a pleasure to read man afterboot. With OpenBSD the man pages are absolutely excelent.
One of the first things I did was:
# cp /etc/examples/doas.conf /etc/
Now my user
berno can use
doas to install packages! Let’s install Emacs!
doas pkg_add emacs
Also OpenBSD has a habit of printing clues to the console after you type in a
command. For examle, after you install a package, OpenBSD tells you that it has
installed README files in
/usr/local/bsah/blah/README/emacs/. I find it really
cool that it reminds you of this. Also, when you run
doas syspatch it will
tell you that it updated syspatch. It will also say something like:
Please run syspatch again to apply the patches.
That’s a handy tip! And indeed,
doas syspatch -c showed that the patches had
not yet been applied.
Also whilst searching for the internet for how to install OpenBSD on a vm image, I came accross blog post that describes that you can automate OpenBSD installs. That might be something to play with later!
I would like to also set up my local OpenBSD to set up ssh. That way I could do something like this:
#+BEGIN_SRC shell :dir /ssh:berno@localhost:/home/berno :exports both ls | wc -l #+END_SRC #+RESULTS: : 9
I also think it would be fabulous if the OpenBSD team started to make a guix-like package manager/distro. I imagine that they could use perl to do it, since it seems like OpenBSD has embraced perl as their scripting language, and I think it their man pages show that perl can use some rather low lever operating system interfaces.