14. VMs

A Virtual Machine (VM) is an environment on a host computer that can be used as if it were a separate physical computer. VMs can be used to run multiple operating systems simultaneously. Operating systems running inside a VM see emulated virtual hardware rather than the actual hardware of the host computer. This provides more isolation than Jails, although there is additional overhead. A portion of system RAM is assigned to each VM, and each VM uses a zvol for storage. While a VM is running, these resources are not available to the host computer or other VMs.

FreeNAS® VMs use the bhyve(8) virtual machine software. This type of virtualization requires an Intel processor with Extended Page Tables (EPT) or an AMD processor with Rapid Virtualization Indexing (RVI) or Nested Page Tables (NPT).

To verify that an Intel processor has the required features, use Shell to run grep VT-x /var/run/dmesg.boot. If the EPT and UG features are shown, this processor can be used with bhyve.

To verify that an AMD processor has the required features, use Shell to run grep POPCNT /var/run/dmesg.boot. If the output shows the POPCNT feature, this processor can be used with bhyve.

14.1. Creating VMs

Select VMs Add VM for the Add VM dialog shown in Figure 14.1.1:

_images/vms-add.png

Fig. 14.1.1 Add VM

VM configuration options are described in Table 14.1.1.

Table 14.1.1 Options When Adding a VM
Setting Value Description
Name string a name to identify the VM
Description string a short description of the VM or its purpose
Virtual CPUs integer quantity of virtual CPUs allocated to the VM
Memory Size (MiB) integer megabytes of RAM allocated to the VM
Boot Method drop-down menu UEFI for newer operating systems, or UEFI-CSM (Compatibility Support Mode) for older operating systems that only understand BIOS booting

14.2. Adding Devices to a VM

After creating the VM, click it to select it, then click the Devices button at the bottom of the screen to add virtual hardware to it:

_images/vms-devices.png

Fig. 14.2.1 Add Devices to a VM

VMs are given a NIC (Network Interface Card) by default. This interface emulates an Intel E1000 (82545) Ethernet card for compatibility with most operating systems:

_images/vms-nic.png

Fig. 14.2.2 VM Network Interface Device

The Adapter Type can be changed to VirtIO to provide better performance when the operating system installed in the VM supports VirtIO paravirtualized network drivers.

VMs set to UEFI booting are also given a VNC (Virtual Network Computing) remote connection:

_images/vms-vnc.png

Fig. 14.2.3 VM VNC Device

A standard VNC client can connect to the VM to provide screen output and keyboard and mouse input. The VNC port number can be set to 0 or left empty for FreeNAS® to assign a port when the VM is started, or set to a fixed, preferred port number.

Zvols are used as virtual hard drives. After creating a zvol, select Add device, choose the VM, select a Type of Disk, select the zvol, then set the Mode:

_images/vms-disk.png

Fig. 14.2.4 VM Disk Device

AHCI emulates an AHCI hard disk for best software compatibility. VirtIO uses paravirtualized drivers and can provide better performance, but requires the operating system installed in the VM to support VirtIO disk devices.

Adding a CD-ROM device makes it possible to boot the VM from a CD-ROM image, typically an installation CD. The image must be present on an accessible portion of the FreeNAS® storage. In this example, a FreeBSD installation image is shown:

_images/vms-cdrom.png

Fig. 14.2.5 VM CD-ROM Device

14.3. Running VMs

Select VMs to see a list of configured VMs. Configuration and control buttons appear at the bottom of the screen when an individual VM is selected with a mouse click:

_images/vms-control.png

Fig. 14.3.1 VM Configuration and Control Buttons

The name, description, running state, VNC port (if present), and other configuration values are shown. A Start button is shown when the VM is not running. Click this to start the VM. If a VNC port is present, use VNC client software to connect to that port for screen output and keyboard and mouse input.

On running VMs, the button is shown as Stop, and used, unsurprisingly, to stop them.