installing-openbsd-on-a-vm.html 5.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <!DOCTYPE html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" /><meta name="keywords" content="GNU, Emacs, Libre Software, Hurd, Guile, Guix" /><meta name="description" content="GNUcode.me is a website focusing on libre software projects, especially the GNU project." /><link type="application/atom+xml" rel="alternate" title="GNUcode.me -- Feed" href="/feed.xml" /><a rel="me" href="https://fosstodon.org/@thegnuguy"></a><link type="text/css" href="css/footer.min.css" rel="stylesheet"></link><link type="text/css" href="css/header.min.css" rel="stylesheet"></link><link type="text/css" href="css/main.min.css" rel="stylesheet"></link><title>Installing OpenBSD on a VM — GNUcode.me</title></head><body><header><nav><ul><li><a href="index.html">GNUcode.me</a></li><li><a href="services.html">Services</a></li><li><a href="about.html">About</a></li><li><a href="business-ideas.html">Business-ideas</a></li></ul></nav></header><h1>Installing OpenBSD on a VM</h1><main><section class="basic-section-padding"><article><h3>by Joshua Branson — August 05, 2022</h3><div><p>I am of the opinion, that in order to learn how to use an operating system, you
  2. have to use it often. Since I am madly in love with Guix System, but have an
  3. interest in the GNU/Hurd and OpenBSD, I might as well install those OSs on a
  4. virtual machine! I have already done that with the GNU/Hurd, and today I also
  5. did it for OpenBSD.</p><p>I was not that hard to do. I used this guide to <a href="https://wiki.qemu.org/index.php/Hosts/BSD#OpenBSD">install OpenBSD on a vm.</a></p><p>First let’s create a qemu img for OpenBSD.</p><p><code>qemu-img create -f qcow2 hd0.qcow2.img 100G</code></p><p>Now, let's create an install script.</p><pre><code>cat install-bsd.sh
  6. #!/bin/sh
  7. qemu-system-x86_64 -m 2048 \
  8. -no-reboot \
  9. -cdrom cd71.iso \
  10. -drive if=virtio,file=hd0.qcow2.img,format=qcow2 \
  11. -enable-kvm \
  12. -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 \
  13. -device virtio-net,netdev=mynet0 \
  14. -smp 2</code></pre><p>As always installing OpenBSD is an absolute breeze. I do not know how to
  15. manually partition things, so I just chose the auto install. Also OpenBSD
  16. supports a <code>us.swapcaps.dvorak</code> keyboard layout. That’s my layout! How cool is
  17. that!? And it sets up that layout for the console and X by default. Guix
  18. System does that, but not so well for wayland.</p><pre><code>cat run-bsd.sh</code></pre><p>Now let's create a run script.</p><pre><code>#!/bin/sh
  19. qemu-system-x86_64 -m 4G \
  20. -no-reboot \
  21. -drive if=virtio,file=hd0.qcow2.img,format=qcow2 \
  22. -enable-kvm \
  23. -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7922-:22 \
  24. -device virtio-net,netdev=mynet0 \
  25. -smp 2</code></pre><p>I find the <code>-no-reboot</code> option helpful, because OpenBSD likes to try to autoreboot
  26. itself, even when you give it the command: <code>halt</code>.</p><p>I have ran OpenBSD before for about a week before, and it is always a pleasure
  27. to read man afterboot. With OpenBSD the man pages are absolutely excelent.</p><p>One of the first things I did was:</p><p><code># cp /etc/examples/doas.conf /etc/</code></p><p>Now my user <code>berno</code> can use <code>doas</code> to install packages! Let’s install Emacs!</p><p><code>doas pkg_add emacs</code></p><p>Also OpenBSD has a habit of printing clues to the console after you type in a
  28. command. For examle, after you install a package, OpenBSD tells you that it has
  29. installed README files in <code>/usr/local/bsah/blah/README/emacs/</code>. I find it really
  30. cool that it reminds you of this. Also, when you run <code>doas syspatch</code> it will
  31. tell you that it updated syspatch. It will also say something like:</p><blockquote><p>Please run syspatch again to apply the patches.</p></blockquote><p>That’s a handy tip! And indeed, <code>doas syspatch -c</code> showed that the patches had
  32. not yet been applied.</p><p>Also whilst searching for the internet for how to install OpenBSD on a vm image,
  33. I came accross <a href="https://www.skreutz.com/posts/autoinstall-openbsd-on-qemu/">blog post</a> that describes that you can automate OpenBSD installs.
  34. That might be something to play with later!</p><p>I would like to also set up my local OpenBSD to set up ssh. That way I could do
  35. something like this:</p><pre><code>#+BEGIN_SRC shell :dir /ssh:berno@localhost:/home/berno :exports both
  36. ls | wc -l
  37. #+END_SRC
  38. #+RESULTS:
  39. : 9</code></pre><p>I also think it would be fabulous if the OpenBSD team started to make a
  40. guix-like package manager/distro. I imagine that they could use perl to do it,
  41. since it seems like OpenBSD has embraced perl as their scripting language, and I
  42. think it their man pages show that perl can use some rather low lever operating
  43. system interfaces.</p></div></article></section></main><footer><p>© 2020 Joshua Branson. The text on this site is free culture under the Creative Commons Attribution Share-Alike 4.0 International license.</p><p>This website is build with Haunt, a static site generator written in Guile Scheme. Source code is <a href="https://notabug.org/jbranso/gnucode.me">available.</a></p><p>The color theme of this website is based off of the famous <a href="#3f3f3f" target="_blank">zenburn</a> theme.</p></footer></body>