The blog.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

128 lines
3.9 KiB

  1. ---
  2. title: Installing and running NetBSD and OpenBSD under bhyve
  3. description: >
  4. Installing and running NetBSD and OpenBSD under bhyve
  5. posted: !!timestamp '2015-07-28'
  6. created: !!timestamp '2015-07-28'
  7. time: 8:37 PM
  8. tags:
  9. - NetBSD
  10. - OpenBSD
  11. - bhyve
  12. - FreeBSD
  13. ---
  14. These instructions assume that you have downloaded the install ISO from
  15. the respective sources. These were doing with specific versions, and
  16. there may be minor changes with older and newer versions.
  17. These instructions could possibly be more simple, such as not using
  18. separate device maps for `grub-bhyve`. These were testing on a month
  19. old HEAD.
  20. There are other guides that cover most of this, and probably in more
  21. detail. The issue that I had was the exact commands to grub to load
  22. kernels was not well documented. Both of the images boot and are able
  23. to get DHCP leases and pass basic traffic.
  24. Hope this helps others!
  25. ## NetBSD
  26. 1. Install `grub2-bhyve`:
  27. <pre class="fullwidth"><code>
  28. pkg install grub2-bhyve
  29. </code></pre>
  30. 2. Create a file called `instdev.map` containing:
  31. <pre class="fullwidth"><code>
  32. (cd0) NetBSD-6.1.5-amd64.iso
  33. (hd1) netbsd.img
  34. </code></pre>
  35. 3. Create the file `netbsd.img` with the correct size:
  36. <pre class="fullwidth"><code>
  37. truncate -s 3g netbsd.img
  38. </code></pre>
  39. 4. Run the following commands (or put into a script file) under `sh`:
  40. <pre class="fullwidth"><code>
  41. MEM=512M
  42. VM=nbsd615
  43. bhyvectl --destroy --vm=$VM
  44. grub-bhyve -r cd0 -M $MEM -m instdev.map $VM &lt;&lt;EOF
  45. knetbsd -h -r cd0a
  46. (cd0)/netbsdboot
  47. EOF
  48. bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc \
  49. -s 2:0,virtio-net,tap3 -s 3:0,virtio-blk,./netbsd.img \
  50. -s 4:0,ahci-cd,./NetBSD-6.1.5-amd64.iso \
  51. -l com1,stdio -c 2 -m $MEM $VM
  52. </code></pre>
  53. 5. This will run the installer, complete the installation.
  54. 6. Create a file called `dev.map` containing:
  55. <pre class="fullwidth"><code>
  56. (hd1) netbsd.img
  57. </code></pre>
  58. 7. Now in the future, to run NetBSD from the image, run the following commands:
  59. <pre class="fullwidth"><code>
  60. MEM=512M
  61. VM=nbsd615
  62. bhyvectl --destroy --vm=$VM
  63. grub-bhyve -r cd0 -M $MEM -m dev.map $VM &lt;&lt;EOF
  64. knetbsd -h -r ld0a
  65. (hd1,msdos1)/netbsdboot
  66. EOF
  67. bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc \
  68. -s 2:0,virtio-net,tap3 -s 3:0,virtio-blk,./netbsd.img \
  69. -l com1,stdio -c 2 -m $MEM $VM
  70. </code></pre>
  71. 8. Profit!
  72. ## OpenBSD
  73. 1. Install `grub2-bhyve`:
  74. <pre class="fullwidth"><code>
  75. pkg install grub2-bhyve
  76. </code></pre>
  77. 2. Create a file called `instdev.map` containing:
  78. <pre class="fullwidth"><code>
  79. (cd0) install57.iso
  80. (hd1) openbsd.img
  81. </code></pre>
  82. 3. Create the file `openbsd.img` with the correct size:
  83. <pre class="fullwidth"><code>
  84. truncate -s 3g openbsd.img
  85. </code></pre>
  86. 4. Run the following commands (or put into a script file) under `sh`:
  87. <pre class="fullwidth"><code>
  88. MEM=512M
  89. VM=obsd57
  90. bhyvectl --destroy --vm=$VM
  91. grub-bhyve -r cd0 -M $MEM -m instdev.map $VM &lt;&lt;EOF
  92. kopenbsd -h com0
  93. (cd0)/5.7/amd64/bsd.rdboot
  94. EOF
  95. bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc \
  96. -s 2:0,virtio-net,tap3 -s 3:0,virtio-blk,./openbsd.img \
  97. -s 4:0,ahci-cd,./install57.iso \
  98. -l com1,stdio -c 2 -m $MEM $VM
  99. </code></pre>
  100. 5. This will run the installer, complete the installation.
  101. 6. Create a file called `dev.map` containing:
  102. <pre class="fullwidth"><code>
  103. (hd1) netbsd.img
  104. </code></pre>
  105. 7. Now in the future, to run OpenBSD from the image, run the following commands:
  106. <pre class="fullwidth"><code>
  107. MEM=512M
  108. VM=obsd57
  109. bhyvectl --destroy --vm=$VM
  110. grub-bhyve -r hd1 -M $MEM -m dev.map $VM &lt;&lt;EOF
  111. kopenbsd -h com0 -r sd0a
  112. (hd1,openbsd1)/bsdboot
  113. EOF
  114. bhyve -A -H -P -s 0:0,hostbridge -s 1:0,lpc \
  115. -s 2:0,virtio-net,tap3 -s 3:0,virtio-blk,./openbsd.img \
  116. -s 4:0,ahci-cd,./install57.iso \
  117. -l com1,stdio -c 2 -m $MEM $VM
  118. </code></pre>
  119. 8. Profit!