Get a Quote   (408) 943-4100               TrueNAS Discord      VendOp_Icon_15x15px   Commercial Support Toggle between Light and Dark mode

Creating and Managing VMs

  8 minute read.

Last Modified 2022-04-07 16:08 EDT

A Virtual Machine (VM) is an environment on a host computer that you can use as if it were a separate, physical computer. Users can use VMs to run multiple operating systems simultaneously on a single computer. Operating systems running inside a VM see emulated virtual hardware rather than the host computer physical hardware. VMs provide more isolation than Jails but also consumes more system resources.

TrueNAS assigns a portion of system RAM and a new zvol to each VM. While a VM is running, these resources are not available to the host computer or other VMs.

TrueNAS VMs use the KVM virtual machine software. This type of virtualization requires an x86 machine running a recent Linux kernel on an Intel processor with VT (virtualization technology) extensions or an AMD processor with SVM extensions (also called AMD-V). Users cannot create VMs unless the host system supports these features.

To verify that you have Intel VT or AMD-V, open the Shell and run egrep '^flags.*(vmx|svm)' /proc/cpuinfo. If device information appears, your system has VT. You can also check the processor model name (in /proc/cpuinfo) on the vendor’s website.

Creating a Virtual Machine

Before creating a virtual machine, you need an installer .iso or image file for the OS you intend to install, and a storage pool available for both the virtual disk and OS install file.

To create a new VM, go to Virtualization and click Add (or Add Virtual Machines). Configure each category of the VM according to your specifications, starting with the Operating System.

AddVMOperatingSystemSCALE

Operating System

FieldDescription
Guest Operating SystemChoose the VM operating system type.
NameEnter an alphanumeric name for the virtual machine.
DescriptionEnter a description (optional).
System Clock *The VM system time. Default is Local.
Boot MethodSelect UEFI for newer operating systems or Legacy BIOS for older operating systems that only support BIOS booting.
Shutdown TimeoutThe time in seconds the system waits for the VM to cleanly shut down. During system shutdown, the system initiates poweroff for the VM after the shutdown timeout has expired.
Start on BootSet to start this VM when the system boots.
Enable DisplayEnable a Display (Virtual Network Computing) remote connection. Requires UEFI booting.
Display TypeSelect either VNC or SPICE
BindDisplay network interface IP address. The primary interface IP address is the default. A different interface IP address can be chosen.

CPU and Memory

FieldDescription
Virtual CPUsThe number of virtual CPUs to allocate to the virtual machine. The maximum is 16, or fewer if the host CPU limits the maximum. The VM operating system might also have operational or licensing restrictions on the number of CPUs.
CoresSpecify the number of cores per virtual CPU socket. The product of vCPUs, cores, and threads must not exceed 16.
ThreadsSpecify the number of threads per core. The product of vCPUs, cores, and threads must not exceed 16.
CPU ModeChoose between Custom, Model, and Passthrough modes.
CPU ModelSelect a CPU model to emulate.
Memory SizeAllocate RAM for the VM. Minimum value is 256 MiB. This field accepts human-readable input (Ex. 50 GiB, 500M, 2 TB). If units are not specified, the value defaults to bytes.

Disks

FieldDescription
Create new disk imageCreate a new zvol on an existing dataset to use as a virtual hard drive for the VM.
Use existing disk imageUse an existing zvol or file for the VM.
Select Disk TypeSelect desired disk type (AHCI or VirtIO).
Zvol LocationSelect a dataset for the new zvol.
SizeAllocate space for the new zvol. (Examples: 500 KiB, 500M, 2 TB) MiB. Units smaller than MiB are not allowed.

Network Interface

FieldDescription
Adapter TypeIntel e82545 (e1000) emulates the same Intel Ethernet card and provides compatibility with most operating systems. VirtIO provides better performance when the operating system installed in the VM supports VirtIO paravirtualized network drivers.
Mac AddressEnter the desired address into the field to override the randomized MAC address.
Attach NICSelect the physical interface to associate with the VM.

Installation Media

FieldDescription
Choose Installation Media ImageBrowse to the operating system installer image file.
Upload an Installer Image FileSet to display image upload options.

GPU

FieldDescription
Hide from MSREnable to hide the GPU from the Microsoft Reserved Partition (MSR)
GPU’sSelect a physical GPU on your system to use for the VM.

Additional notes:

Compare the recommended specifications for your guest operating system with the available host system resources when allocating virtual CPUs, cores, threads, and memory size.

Don’t allocate too much memory to a VM.

Activating a VM with all available memory allocated to it can slow the host system or prevent other VMs from starting.

We recommend using the AHCI Disk Type for Windows VMs.

The VirtIO network interface requires a guest OS that supports VirtIO paravirtualized network drivers.

Adding and Removing Devices

After creating the VM, add and remove virtual devices by expanding the VM entry in Virtualization and clicking Devices.

VirtualMachinesDevicesSCALE

Device notes:

  • Virtual machine attempt to boot from devices according to the Device Order, starting with 1000, then ascending.
  • CD-ROM devices allow booting a VM from a CD-ROM image like an installation CD. The CD image must be available in the system storage.

Managing the Virtual Machine

After creating the VM and configuring any devices for it, manage the VM by expanding its entry in Virtualization.

VirtualMachinesOptionsSCALE

When the VM is active, it displays options for Display and Serial connections.

If the display connection screen appears distorted, try adjusting the display device resolution.

Use the State toggle or click Stop to follow a standard shut down procedure to do a clean shut down of the running VM. Click Power Off halts and deactivates the VM, similar to unplugging a computer.

If the VM you created has no Guest OS installed, The VM State toggle and Stop button might not function as expected. The State toggle and Stop button send an ACPI power down command to the VM operating system, but since an OS is not installed, the commands time out. Use the Power Off button instead.

Installing an OS

When the VM is configured in TrueNAS and has an OS .iso file attached, you can start the VM and begin installing the operating system.

Some operating systems can require specific settings to function properly in a virtual machine. For example, vanilla Debian can require advanced partitioning when installing the OS. Refer to the documentation for your chosen operating system for tips and configuration instructions.

Here is an example of installing a Debian OS in a TrueNAS VM. The Debian .iso was uploaded to the TrueNAS system and attached to the VM as a CD-ROM device.

  • Click on the Virtualization menu then click ADD to start the VM creation process using the wizard.

SCALEDebianVMOperatingSystem

Operating System:

  • Guest Operating System: Linux
  • Name: debianVM
  • Description: Debian VM

CPU and Memory:

  • Change the memory size to 1024 MiB.

Disks:

  • Select Create new disk image.
  • Select the Zvol Location.
  • Change the size to 30 GiB.

Network Interface:

  • Attach NIC: Select the physical interface to associate with the VM.

Installation Media:

  • In this case the installation ISO is uploaded to /mnt/tank2/isostorage/. Click on the installation ISO, debian-11.0.0-amd64-netinst.iso.
  • If the ISO is or was not uploaded, you need to set Upload an installer image file, select a dataset to store the ISO, click Choose file, then click Upload. Wait for the upload to complete (this can take some time).

GPU:

  • Leave the default values.

Confirm Options

  • Verify the information is correct and then click Submit.
  • After the VM is created, start it by expanding the VM entry (select the down-pointing arrow to the right of the VM name) and click Start.

  • Click Display to open a virtual monitor to the VM and see the Debian Graphical Installation screens.

Debian Graphical Install

  • Press Return to start the Debian Graphical Install.
  • Language: English
  • Location: United States
  • Keymap: American English

Installation begins

  • Continue if the network configuration fails.
  • Do not configure the network at this time.
  • Enter a name in Hostname.
  • Enter the root password and re-enter the root password.
  • Enter a name in New User.
  • Select the username for your account (it should already be filled in).
  • Enter and re-enter the password for the user account.
  • Choose the time zone, Eastern in this case.

Disk Detection should begin

  • Partition disks: select Guided - use entire disk.
  • Select the available disk.
  • Select All files in one partition (recommended for new users).
  • Select Finish partitioning and write changes to disk.
  • Select Yes to Write the changes to disks?.

Installing the base system

  • Select No to the question Scan extra installation media.
  • Select Yes when asked Continue without a network mirror.

Installing Software

  • Select No when asked Participate in the package usage survey.
  • Select Standard system utilities.
  • Click Continue when the installation finishes.
  • After the Debian installation finishes, close the display window.

  • In the VM’s expanded section click Power Off to stop the new VM.

  • Click Devices.

  • Remove the CD-ROM from the devices by clicking the   and selecting Delete. Click Delete Device.

  • Click Virtualization and expand the new VM by selecting the down-pointing arrow to the right.

  • Click Start.

  • Click Display.

The grub file does not run when you start the VM. This can be done manually after each start. At the shell prompt:

  • Type FS0: Return.
  • Type cd EFI Return.
  • Type cd Debian Return.
  • Type grubx64.efi Return.

To insure it starts automatically, you need to create the startup.nsh file at the root directory on the vm. At the shell prompt type edit startup.nsh. In the editor type:

  • Type FS0: Return.
  • Type cd EFI Return.
  • Type cd Debian Return.
  • Type grubx64.efi Return.
  • Type the Control+s keys(Command+s for Mac OS) Return.
  • Type the Control+q keys to quit.

Close the display window

To test if it now boots up on startup:

  • Power off the VM.
  • Click Start.
  • Click Display.
  • Log into your Debian VM.