-
Notifications
You must be signed in to change notification settings - Fork 0
How to launch different guest OS
First we need to load the following modules.
root@bhyve# kldload vmm nmdm if_tap if_bridge
You can install the pre-built package or via ports sysutils/uefi-edk2-bhyve.
root@bhyve# pkg install uefi-edk2-bhyve
Create a tap(4) interface.
root@bhyve# ifconfig tap0 create
Create a bridge(4) interface.
root@bhyve# ifconfig bridge0 create
The igb0 interface is my physical NIC where I want to attach the bridge and tap interface, also via igb0 my guest VM will be able to obtain an IPv4 via dhcp
root@bhyve# ifconfig bridge0 addm igb0 addm tap0
By default, tap(4) interfaces doesn't comes UP, or we need to ifconfig tap0 up or set this sysctl(8).
root@bhyve# sysctl net.link.tap.up_on_open=1
root@bhyve# truncate -s 20G /<path>/disk.raw
Usually these are the guests I use in my testbed.
- FreeBSD HEAD
- Ubuntu
- Fedora
- Windows 2016
- NetBSD or OpenBSD
Note: NetBSD or OpenBSD is good to test legacy MSI interrupt.
For FreeBSD on AMD64 is suggested to use -A to generate ACPI tables.
root@bhyve# bhyve -A -H -P -c 4 -m 8096M -s 0:0,hostbridge -s 31,lpc -l com1,/dev/nmdm1A -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd -s 29,fbuf,tcp=10.20.21.2:6032,w=800,h=600 -s 30,xhci,tablet -s 4,virtio-blk,/<path>/disk.raw -s 5,virtio-net,tap0,mac=00:a0:98:2c:d5:9f -s 6,ahci-cd,/z/isos/FreeBSD-12.0-CURRENT-amd64-20180329-r331740-disc1.iso FreeBSD
root@bhyve# bhyve -H -P -c 4 -m 8096M -s 0:0,hostbridge -s 31,lpc -l com1,/dev/nmdm1A -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd -s 29,fbuf,tcp=10.20.21.2:6032,w=800,h=600 -s 30,xhci,tablet -s 4,virtio-blk,/<path>/disk.raw -s 5,virtio-net,tap0,mac=00:a0:98:2c:d5:9f -s 6,ahci-cd,/z/isos/Fedora-Workstation-Live-x86_64-27-1.6.iso Fedora
NOTE: After install and shutdown the VM, you should remove the slot 6 ahci-cd and you will be able to boot from raw disk.
This is an example how I organize my test environment. For each VM you must have a different raw disk as well as an unique tap(4) interface in case you want to run multiple VM at same time. Usually I organize my test environment with different sub-directories and scripts to launch each flavor of guest.
root@bhyve#: tree /z/vms/
/z/vms/
|-- freebsd
| |-- destroy.sh
| |-- disk.img
| |-- restore.sh
| `-- vm.sh
|-- freenas
| |-- destroy.sh
| |-- disk.img
| |-- restore.sh
| `-- vm.sh
|-- linux
| |-- destroy.sh
| |-- disk.img
| |-- restore.sh
| `-- vm.sh
`-- windows
|-- destroy.sh
|-- disk.img
|-- restore.sh
`-- vm.sh
I always test on Intel and AMD64 CPU types. I have these two CPU's in my testbed.
- Intel(R) Xeon(R) CPU E5-2609 v2 @ 2.50GHz
- AMD Ryzen Threadripper 1950X 16-Core Processor