3.1. Creating Virtual Environments

You can create virtual machines and containers using virt-install.

Note

The default file system in containers is XFS.

The following guest operating systems are supported in the alpha build:

Guest OS

VM OS variant

Container EZ template

AlmaLinux 8

almalinux8

almalinux-8-x86_64

CentOS 7 (VM preset default)

centos7.0

centos-7-x86_64

Debian 10

debian10

debian-10.0-x86_64

Red Hat Enterprise Linux 7

rhel7.9

rhel-7-x86_64

Red Hat Enterprise Linux 8

rhel8.4

rhel-8-x86_64

Ubuntu 18.04 LTS

ubuntu18.04

ubuntu-18.04-x86_64

Ubuntu 20.04 LTS

ubuntu20.04

ubuntu-20.04-x86_64

Virtuozzo Linux 7

vzlinux7

vzlinux-7-x86_64

Virtuozzo Linux 8

vzlinux8

vzlinux-8-x86_64

Microsoft Windows Server 2016

win2k16

n/a

Microsoft Windows Server 2019

win2k19

n/a

Microsoft Windows Server 2022

win2k22

n/a

Note

  1. Creating Red Hat Enterprise Linux containers requires additional steps. See Prerequisites for Creating Red Hat Enterprise Linux Containers.

  2. VHS 9 utilizes the SCSI controllers (drivers) for QEMU Q35 machines. IDE controllers are not supported.

Use the OS variant with the --os-variant option of virt-install. You can also replace the default centos7.0 in the Linux VM preset /etc/virt-manager/presets/vz_vm_linux. Use the EZ template when creating container hard disks with vzpkg. If the EZ template is not installed, it will be downloaded from the repository.

To create a Linux virtual machine, it is recommended to use the vz_vm_linux preset. For example:

# mkdir -p /vz/mylinuxvm
# virt-install \
--name mylinuxvm \
--preset vz_vm_linux \
--ram 2048 \
--vcpus 'sockets=1,cores=2' \
--disk 'path=/vz/mylinuxvm/harddisk1.hdd,bus=scsi,startup_policy=optional,boot_order=1,size=64' \
--disk 'path=<linux_dist>.iso,device=cdrom,bus=scsi,boot_order=2' \
--boot cdrom \
--graphics vnc,port=5901,listen=0.0.0.0 \
--import
Starting install...
Allocating 'harddisk1.hdd'                                           |  64 GB  00:00:08
Domain creation completed.

To create a Microsoft Windows virtual machine, it is recommended to use the vz_vm_windows preset. For example:

# mkdir -p /vz/mywindowsvm
# virt-install \
--name mywindowsvm \
--os-variant win2k19 \
--preset vz_vm_windows \
--ram 2048 \
--vcpus 'sockets=1,cores=2' \
--disk 'path=/vz/mywindowsvm/harddisk1.hdd,bus=scsi,startup_policy=optional,boot_order=1,size=64' \
--disk 'path=<windows_dist>.iso,device=cdrom,bus=scsi,boot_order=2' \
--graphics vnc,port=5902,listen=0.0.0.0 \
--import
Starting install...
Allocating 'harddisk1.hdd'                                           |  64 GB  00:00:08
Domain creation completed.

To create a container (except Red Hat Enterprise Linux, see further), do the following:

  1. Create a disk image with vzpkg. For example:

    # mkdir -p /vz/mylinuxct
    # vzpkg create image centos-7-x86_64 /vz/mylinuxct/mylinuxct.hdd
    Creating Container root image at /vz/mylinuxct/mylinuxct.hdd (centos-7-x86_64)
    <...>
    Image was succesfully created at /vz/mylinuxct/mylinuxct.hdd
    
  2. Create the container based on the disk image. For example:

    # virt-install \
    --connect vzct:///system \
    --name mylinuxct \
    --memory 2048 \
    --disk 'path=/vz/mylinuxct/mylinuxct.hdd,boot_order=1,size=64' \
    --graphics vnc,port=5903,listen=0.0.0.0 \
    <...>
    Starting install...
    Domain creation completed.
    You can restart your domain by running:
      virsh --connect vzct:///system start mylinuxct
    

3.1.1. Prerequisites for Creating Red Hat Enterprise Linux Containers

Creating Red Hat Enterprise Linux containers requires certificates being present on the host. You will need a working Red Hat Enterprise Linux 7 or 8 installation. The same certificates can be used for both versions.

Do the following before creating such containers:

  1. In the repository file, e.g., /etc/yum.repos.d/redhat.repo, find the certificate paths. For example:

    sslcacert = /etc/rhsm/ca/redhat-uep.pem
    sslclientkey = /etc/pki/entitlement/4662537897317115958-key.pem
    sslclientcert = /etc/pki/entitlement/4662537897317115958.pem
    
  2. Copy these certificates to /etc/rhel/ on the host where you will be creating Red Hat Enterprise Linux containers.