Install VM
- https://www.truenas.com/docs/hub/tasks/advanced/virtual-machines/
- https://www.youtube.com/watch?v=8oMAEBUOPQ0
- https://www.youtube.com/watch?v=c3cVQPd37i0
- https://www.truenas.com/docs/hub/tasks/advanced/virtual-machines/
Tips
- Use VirtIO (which use semi-virtualised tech under the real NIC and thus provide higher performance, compared with
Intel e82585 (e1000)
)- Emulating an Intel e82545 (e1000) Ethernet card provides compatibility with most operating systems. Change to VirtIO to provide better performance on systems with VirtIO paravirtualized network driver support.
- CPU setting
Demo
Install Ubuntu
https://www.youtube.com/watch?v=YQ1nO9zZ5rE
Troubleshooting
I have a problem when install vritual xubuntu 20.04, the error that appear in VNC client is
Initramfs unpacking failed: write error
ACPI error: Could not enable RealTimeClock Event
Failed to execute /init (error-2)
Kernel panic - not syncing: No working init found. Try passing init= option to kernel See Linux documentation
....other information....
Solution: set the memory to be at least 1GB (previously I set to be 512MB, which leads to this error)
Manage VMs
Pre-requisition
vmm
vmm.ko – bhyve virtual machine monitor
To load the driver as module at boot, add this line to loader.conf(5):
vmm_load="YES"
The module can also be loaded manually with kldload(8):
kldload vmm
List VMs
$ ls -al /dev/vmm
total 1
dr-xr-xr-x 2 root wheel 512 Mar 12 13:55 .
dr-xr-xr-x 24 root wheel 512 Mar 12 12:41 ..
crw------- 1 root wheel 0x119 Mar 12 14:15 4_TrueNASUbuntu4
Creation
bhyveload
bhyveload – load a FreeBSD guest inside a bhyve virtual machine
To load a FreeBSD kernel from disk image vm0.img
with 256M RAM and the name vm0
:
$ /usr/sbin/bhyveload -m 256 -d ./vm0.img vm0
This will show the FreeBSD loader screen and you should see the device /dev/vmm/vm0
bhyve
To boot the VM with 2 vCPUs, the same 256M RAM and the tap0
network interface:dfd
/usr/sbin/bhyve -c 2 -m 256 -A -H -P \
-s 0:0,hostbridge \
-s 1:0,virtio-net,tap0 \
-s 2:0,ahci-hd,./vm0.img \
-s 31,lpc -l com1,stdio \
vm0
Manage VMs
bhyvectl
The bhyvectl command is a control utility for active bhyve(8) virtual machine instances, e.g., see CPU usage
$ bhyvectl --vm=<vmname>
# Retrieve statistics for the specified VM.
$ bhyvectl --vm=<vmname> --get-stats
A specified virtual machine can be destroyed using bhyvectl
:
$ bhyvectl --destroy --vm=<vmname>
vm-bhyve
Validation
Since 3.2.0 the virt-host-validate(1)
supports the bhyve host validation and could be used like this:
$ virt-host-validate bhyve
BHYVE: Checking for vmm module : PASS
BHYVE: Checking for if_tap module : PASS
BHYVE: Checking for if_bridge module : PASS
BHYVE: Checking for nmdm module : PASS
$
Reference
- https://www.ixsystems.com/documentation/truenas/11.3-U2/virtualmachines.html
- https://docs.freebsd.org/doc/10.3-RELEASE/usr/local/share/doc/freebsd/handbook/virtualization-host-bhyve.html
- https://www.truenas.com/docs/hub/tasks/advanced/virtual-machines/
- https://www.truenas.com/docs/hub/initial-setup/install/tn-vm-install/
- https://www.freebsd.org/cgi/man.cgi?query=bhyve
- https://www.freebsd.org/cgi/man.cgi?query=vmm&sektion=4&manpath=freebsd-release-ports
- https://www.freebsd.org/cgi/man.cgi?query=bhyvectl
- https://www.freebsd.org/cgi/man.cgi?query=bhyveload
Troubleshooting