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.
 
 
 
 

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