{"id":2367,"date":"2019-04-16T16:37:30","date_gmt":"2019-04-16T16:37:30","guid":{"rendered":"http:\/\/hauweele.net\/~gawen\/blog\/?p=2367"},"modified":"2019-04-16T16:56:02","modified_gmt":"2019-04-16T16:56:02","slug":"bhyve-openbsd-on-freenas","status":"publish","type":"post","link":"https:\/\/hauweele.net\/~gawen\/blog\/?p=2367","title":{"rendered":"Bhyve OpenBSD on FreeNAS"},"content":{"rendered":"<p><a href=\"https:\/\/www.openbsd.org\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2370 size-medium\" src=\"https:\/\/hauweele.net\/~gawen\/blog\/wp-content\/uploads\/2019\/04\/puffy-300x258.png\" alt=\"\" width=\"300\" height=\"258\" srcset=\"https:\/\/hauweele.net\/~gawen\/blog\/wp-content\/uploads\/2019\/04\/puffy-300x258.png 300w, https:\/\/hauweele.net\/~gawen\/blog\/wp-content\/uploads\/2019\/04\/puffy-768x661.png 768w, https:\/\/hauweele.net\/~gawen\/blog\/wp-content\/uploads\/2019\/04\/puffy-348x300.png 348w, https:\/\/hauweele.net\/~gawen\/blog\/wp-content\/uploads\/2019\/04\/puffy.png 800w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Lately I&#8217;ve been playing with bhyve on FreeBSD and FreeNAS in the prospect of spinning up small VMs for a mini compile farm (and just as an excuse to play around). In this post I will share my experience in installing OpenBSD 6.4 as a bhyve UEFI VM on FreeNAS-11.2 through the new GUI.<\/p>\n<p>This post is divided in three parts. First the creation of the VM through FreeNAS new GUI. Then the installation of OpenBSD from boot to finish. Lastly some bits of documentation and related posts that were helpful along the way.<\/p>\n<h2>Create the VM<\/h2>\n<p>The installation will go through serial instead of VNC. Also, instead of the CDROM ISO we use a disk image for the installation.<\/p>\n<p>In the FreeNAS GUI, selects <em>Virtual Machines &gt; ADD<\/em>, then proceed with the wizard. Some parameters of the wizard are pretty obvious, so there won&#8217;t be an explanation for each one of them. If need be, check the <a href=\"https:\/\/www.ixsystems.com\/documentation\/freenas\/11.2\/virtualmachines.html#creating-vms\">FreeNAS doc on creating VMs<\/a>.<\/p>\n<p><b>Guest Operating System<\/b>, not exactly sure what this does. Guess it&#8217;s basically a template for the next steps of the wizard. Since this is a BSD system, select <em>FreeBSD<\/em> as this is the closest there is.<\/p>\n<p>We don&#8217;t need VNC, so make sure that <b>Enable VNC<\/b> is unchecked. As for <b>Boot Method<\/b>, you can select <em>UEFI<\/em>, you don&#8217;t need <em>UEFI-CSM<\/em>.<\/p>\n<p>For the hard disk in <b>Select Disk Type<\/b> and similarly for the network interface in <b>Adapter Type<\/b>, select a <em>VirtIO<\/em> type.<\/p>\n<p>For the <b>Installation Media<\/b>, leave it blank. This is for an ISO image but OpenBSD&#8217;s installXX.iso didn&#8217;t work so we are going to use a raw disk image instead.<\/p>\n<p>Go ahead and create the VM. But don&#8217;t start it yet. We have to add a raw disk device.<\/p>\n<p>Fetch <em>installXX.fs<\/em> from <a href=\"https:\/\/www.openbsd.org\/faq\/faq4.html#Download\">OpenBSD download page<\/a>, and put it somewhere on the FreeNAS host. For the following, I&#8217;ll assume this is <em>install64.fs<\/em>.<\/p>\n<p>Then select <i>Devices &gt; ADD<\/i> for the VM. Select <b>Type<\/b>: <em>Raw File<\/em> and <b>Raw File<\/b>: the location of <em>install64.fs<\/em> on the FreeNAS host. Also <b>Mode<\/b>: <em>VirtIO<\/em>; <b>Device Order<\/b>: <em>1003<\/em> (the device order is important, otherwise the OpenBSD install would incorrectly guess the target device); <b>Raw filesize<\/b>: <em>1<\/em> (which means 1GB).<\/p>\n<p>Now you can start the VM and open the <em>Serial<\/em> console. You should be greeted by:<\/p>\n<pre>&gt;&gt; OpenBSD\/amd64 BOOTX64 3.40\r\nboot&gt;\r\n<\/pre>\n<p>Time to install OpenBSD!<\/p>\n<h2>Install OpenBSD<\/h2>\n<p>You are on the serial console with the OpenBSD install bootloader waiting for you. On the console <code>boot&gt;<\/code>, type <code>set tty com0<\/code>, then <code>boot<\/code>. <\/p>\n<p>Do not directly start the installation, we first have to create the EFI partition, so select <code>(S)hell<\/code> instead. At the command prompt, create the EFI partition as described below, then start the install.<\/p>\n<pre>\r\n## Check that sd0 is the correct target device\r\n# disklabel -p M sd0\r\n...\r\n16 partitions:\r\n#                size           offset  fstype [fsize bsize   cpg]\r\n  c:         15625.0M                0  unused\r\n\r\n## Initialise a GPT partition table with the special boot partition on sd0.\r\n# fdisk -iyg -b 960 sd0\r\nWriting MBR at offset 0.\r\nWriting GPT.\r\n\r\n## Start the installer\r\n# install\r\n<\/pre>\n<p>At the partitioning step, select <code>(O)penBSD area<\/code>. We will setup a single root partition layout. You should know that the OpenBSD bootloader likes its root partition on slice <em>a<\/em> of the first hard disk, so we create the layout that way.<\/p>\n<pre>\r\n# Check the current partition\r\n&gt; p M\r\nOpenBSD area: 1024-31999937; size: 15624.5M; free: 15624.5M\r\n#                size           offset  fstype [fsize bsize   cpg]\r\n  c:         15625.0M                0  unused                    \r\n  i:             0.5M               64   MSDOS \r\n\r\n# Start with the root partition.\r\n# Again, the bootloader likes it that way.\r\n&gt; a\r\n...\r\nsize: {your-root-partition-size}M\r\nFS type: 4.2BSD\r\nmount point: \/\r\n\r\n# Now the swap partition\r\n&gt; a\r\n...\r\nFS type: swap\r\n\r\n# Check again\r\n> p M\r\nOpenBSD area: 1024-31999937; size: 15624.5M; free: 0.0M\r\n#                size           offset  fstype [fsize bsize   cpg]\r\n  a:         15493.9M             1024  4.2BSD   2048 16384     1 # \/\r\n  b:           130.5M         31732576    swap               \r\n  c:         15625.0M                0  unused                 \r\n  i:             0.5M               64   MSDOS\r\n\r\n# Quit and save\r\n&gt; q\r\nWrite new label?: y\r\n<\/pre>\n<p>Proceed with the installation and the file sets and once you are done, reboot in your new system. Remove the <em>Raw File<\/em> device from the VM and on the VM itself, use <em>syspatch<\/em> to patch the base system. Finally reboot and you are done!<\/p>\n<h2>Relevant bits of documentation<\/h2>\n<ul>\n<li><a href=\"https:\/\/www.openbsd.org\/faq\/faq4.html\">OpenBSD install guide<\/a><\/li>\n<li><a href=\"https:\/\/blog.jasper.la\/openbsd-uefi-bootloader-howto.html\">UEFI OpenBSD install<\/a><\/li>\n<li><a href=\"https:\/\/www.romanzolotarev.com\/openbsd\/install.html\">Another UEFI OpenBSD install<\/a><\/li>\n<li><a href=\"https:\/\/gist.github.com\/afresh1\/804fc0a315ee41e88a24f1aa5e2d3552\">OpenBSD VM under FreeNAS<\/a><\/li>\n<li><a href=\"https:\/\/www.ixsystems.com\/documentation\/freenas\/11.2\/virtualmachines.html\">FreeNAS Virtual Machines<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Lately I&#8217;ve been playing with bhyve on FreeBSD and FreeNAS in the prospect of spinning up small VMs for a mini compile farm (and just as an excuse to play around). In this post I will share my experience in &hellip; <a href=\"https:\/\/hauweele.net\/~gawen\/blog\/?p=2367\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[1059,881,579,1060,486],"class_list":["post-2367","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-bhyve","tag-freenas","tag-openbsd","tag-virtual-machine","tag-vm"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2367","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2367"}],"version-history":[{"count":0,"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2367\/revisions"}],"wp:attachment":[{"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hauweele.net\/~gawen\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}