Skip to content

Instantly share code, notes, and snippets.

@afresh1
Last active May 4, 2022 02:32
Show Gist options
  • Save afresh1/804fc0a315ee41e88a24f1aa5e2d3552 to your computer and use it in GitHub Desktop.
Save afresh1/804fc0a315ee41e88a24f1aa5e2d3552 to your computer and use it in GitHub Desktop.
Installing OpenBSD in a bhyve VM under FreeNAS

Installing OpenBSD in a bhyve VM under FreeNAS

Install from a local image

  • Connect to a shell

  • Download an OpenBSD miniroot install image

      # fetch https://ftp.openbsd.org/pub/OpenBSD/snapshots/amd64/miniroot62.fs
    
  • dd it to the zvol you created

      # dd if=./miniroot62.fs of=/dev/zvol/ztank/vm_images/test bs=1M
    
    • make sure this is your zvol
  • figure out the VM ID for your OpenBSD VM (if you didn't earlier)

      # sqlite3 /data/freenas-v1.db 'SELECT id, name FROM vm_vm'
    
  • connect to the nmdm virtual console.

      # cu -l /dev/nmdm3B
    
    • where 3 is the id for your OpenBSD VM
    • I didn't find documentation about the fact that FreeNAS enables this serial console anywhere but the source.
  • Start the VM by clicking start in the UI.

  • On the console boot> prompt set tty com0

    • and do the install making sure to set console to com0 and choose GPT disk partitioning

Install over the network

On the server hosting the install data:

  • Enable httpd and create an install.conf in /var/www/htdocs

  • Enable tftpd and download some files to /tftpboot:

      cd /tftpboot
      ftp https://ftp.openbsd.org/pub/OpenBSD/snapshots/amd64/{BOOTX64.EFI,bsd.rd}
      ln -s BOOTX64.EFI auto_install
      mkdir etc
      echo "set tty com0\nset image bsd.rd" > etc/boot.conf
    
    • You need a very current BOOTX64.EFI with patrick@'s patch that got committed on 2017-11-25.
  • On your DHCP server, set up the entry for your bhyve VM:

    • Finding the MAC is left as an exercise for the reader

    • Although I watched my dhcp server logs the first time I booted the VM.

    • But, before you remove the VNC device above you can connect to the EFI console there and exit from the shell and find the MAC in the menus.

        host test {
            option host-name "test";
            hardware ethernet 00:XX:XX:XX:XX:30;
            fixed-address 192.168.0.71;
            next-server 192.168.0.50; # This is the IP of the install server
            filename "auto_install";
        }
      

You can connect to the console on /dev/nmdm3B as described above to do debugging, but once it works that is optional.

But, when you start the VM it should fall back to "EFI Network" and boot from the network.

Your OpenBSD install should now be working.

@afresh1
Copy link
Author

afresh1 commented Nov 12, 2017

Many thanks to @jre for helping me figure out that I needed to use the serial console to do this, and thanks to the FreeNAS team for actually connecting the VM to a serial console, even if it isn't documented.

@leonardorame
Copy link

Hey!, after struggling for hours installing OpenBSD 7.1 on TrueNAS 12 I read this https://a.zcopy.site/a/114081.html and figured out I must choose Whole disk GPT for EFI boot.

@afresh1
Copy link
Author

afresh1 commented May 4, 2022

@leonardorame: Thanks for the help. I guess I knew already that bhyve needed GPT and forgot that folks didn't. I expect your comment to help folks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment