|
- ---
- title: Installing and running NetBSD and OpenBSD under bhyve
- description: >
- Installing and running NetBSD and OpenBSD under bhyve
- created: !!timestamp '2015-07-28'
- time: 8:37 PM
- tags:
- - NetBSD
- - OpenBSD
- - bhyve
- - FreeBSD
- ---
-
- These instructions assume that you have downloaded the install ISO from
- the respective sources. These were doing with specific versions, and
- there may be minor changes with older and newer versions.
-
- These instructions could possibly be more simple, such as not using
- separate device maps for `grub-bhyve`. These were testing on a month
- old HEAD.
-
- There are other guides that cover most of this, and probably in more
- detail. The issue that I had was the exact commands to grub to load
- kernels was not well documented. Both of the images boot and are able
- to get DHCP leases and pass basic traffic.
-
- Hope this helps others!
-
- ## NetBSD
-
- 1. Install `grub2-bhyve`:
- <pre class="fullwidth"><code>
- pkg install grub2-bhyve
- </code></pre>
- 2. Create a file called `instdev.map` containing:
- <pre class="fullwidth"><code>
- (cd0) NetBSD-6.1.5-amd64.iso
- (hd1) netbsd.img
- </code></pre>
- 3. Create the file `netbsd.img` with the correct size:
- <pre class="fullwidth"><code>
- truncate -s 3g netbsd.img
- </code></pre>
- 4. Run the following commands (or put into a script file) under `sh`:
- <pre class="fullwidth"><code>
- MEM=512M
- VM=nbsd615
- bhyvectl --destroy --vm=$VM
- grub-bhyve -r cd0 -M $MEM -m instdev.map $VM <<EOF
- knetbsd -h -r cd0a
- (cd0)/netbsdboot
- EOF
- bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc \
- -s 2:0,virtio-net,tap3 -s 3:0,virtio-blk,./netbsd.img \
- -s 4:0,ahci-cd,./NetBSD-6.1.5-amd64.iso \
- -l com1,stdio -c 2 -m $MEM $VM
- </code></pre>
- 5. This will run the installer, complete the installation.
- 6. Create a file called `dev.map` containing:
- <pre class="fullwidth"><code>
- (hd1) netbsd.img
- </code></pre>
- 7. Now in the future, to run NetBSD from the image, run the following commands:
- <pre class="fullwidth"><code>
- MEM=512M
- VM=nbsd615
- bhyvectl --destroy --vm=$VM
- grub-bhyve -r cd0 -M $MEM -m dev.map $VM <<EOF
- knetbsd -h -r ld0a
- (hd1,msdos1)/netbsdboot
- EOF
- bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc \
- -s 2:0,virtio-net,tap3 -s 3:0,virtio-blk,./netbsd.img \
- -l com1,stdio -c 2 -m $MEM $VM
- </code></pre>
- 8. Profit!
-
- ## OpenBSD
-
- 1. Install `grub2-bhyve`:
- <pre class="fullwidth"><code>
- pkg install grub2-bhyve
- </code></pre>
- 2. Create a file called `instdev.map` containing:
- <pre class="fullwidth"><code>
- (cd0) install57.iso
- (hd1) openbsd.img
- </code></pre>
- 3. Create the file `openbsd.img` with the correct size:
- <pre class="fullwidth"><code>
- truncate -s 3g openbsd.img
- </code></pre>
- 4. Run the following commands (or put into a script file) under `sh`:
- <pre class="fullwidth"><code>
- MEM=512M
- VM=obsd57
- bhyvectl --destroy --vm=$VM
- grub-bhyve -r cd0 -M $MEM -m instdev.map $VM <<EOF
- kopenbsd -h com0
- (cd0)/5.7/amd64/bsd.rdboot
- EOF
- bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc \
- -s 2:0,virtio-net,tap3 -s 3:0,virtio-blk,./openbsd.img \
- -s 4:0,ahci-cd,./install57.iso \
- -l com1,stdio -c 2 -m $MEM $VM
- </code></pre>
- 5. This will run the installer, complete the installation.
- 6. Create a file called `dev.map` containing:
- <pre class="fullwidth"><code>
- (hd1) netbsd.img
- </code></pre>
- 7. Now in the future, to run OpenBSD from the image, run the following commands:
- <pre class="fullwidth"><code>
- MEM=512M
- VM=obsd57
- bhyvectl --destroy --vm=$VM
- grub-bhyve -r hd1 -M $MEM -m dev.map $VM <<EOF
- kopenbsd -h com0 -r sd0a
- (hd1,openbsd1)/bsdboot
- EOF
- bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc \
- -s 2:0,virtio-net,tap3 -s 3:0,virtio-blk,./openbsd.img \
- -s 4:0,ahci-cd,./install57.iso \
- -l com1,stdio -c 2 -m $MEM $VM
- </code></pre>
- 8. Profit!
|