3.1. Creating Virtual Environments

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

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

Guest OS

OS variant

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*

SUSE Linux Enterprise Server 12

sles12

sles-12-x86_64

SUSE Linux Enterprise Server 15

sles-15-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

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

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 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=/vz/CentOS-7-x86_64-LiveCD-1503.iso,device=cdrom,bus=scsi,boot_order=2' \
--boot cdrom \
--graphics vnc,port=5901,listen=0.0.0.0
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:

    # vzpkg create image centos-7-x86_64 /vz/mylinuxct/mylinuxct.hdd
    Creating Container root image at /vz/mylinuxct/mylinuxct.hdd (centos-7-x86_64)
    Mount image: /vz/mylinuxct/mylinuxct.hdd
    e2fsck 1.45.6 (20-Mar-2020)
    tune2fs 1.45.6 (20-Mar-2020)
    Warning: The kernel is still using the old partition table.
    The new table will be used at the next reboot or after you
    run partprobe(8) or kpartx(8)
    The operation has completed successfully.
    Unmount image: /vz/mylinuxct/mylinuxct.hdd (190)
    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
    WARNING  Graphics requested but DISPLAY is not set. Not running virt-viewer.
    WARNING  No console to launch for the guest, defaulting to --wait -1
    
    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.