VMmanager: Administrator guide

Preparing the OS Linux template

The template format depends on the type of virtualization in the cluster:

  • KVM — an .xz archive with a RAW disk image of the OS;
  • LXD — a tar.gz archive with the contents of the file system and the metadata file.

Template requirements

Disk partitioning and OS installation

Use GPT disk partitioning. For the first disk partition, specify the BIOS boot type and a size of 2 MB. For the second disk partition, specify the Linux filesystem type and the minimum possible size (for example, 4 GB). Install the OS on the second partition in the minimum configuration.

It is recommended not to allocate a separate partition for swap space, but to create a 512 MB swap file.

Installing additional software

QEMU Guest Agent

QEMU Guest Agent software is required for the platform to interact with VMs. Installation steps:

  1. Install software packages:

    ОС CentOS, AlmaLinux
    yum -y install qemu-guest-agent
    ОС Debian, Ubuntu
    apt -y install qemu-guest-agent
  2. Add QEMU Guest Agent to the autostart:

    systemctl enable --now qemu-guest-agent
  3. Check the status of QEMU Guest Agent:

    systemctl status qemu-guest-agent
  4. Check the status of the SELinux service:

    sestatus

    If the status is different from disable:

    1. Disable SELinux. Replace the below line in the /etc/selinux/config file

      SELINUX=enforcing

      with

      SELINUX=disabled
    2. Reboot the OS.
  5. If the file /etc/sysconfig/qemu-ga contains a line the below format

    BLACKLIST_RPC=guest-file-open,guest-file-close,guest-file-read,guest-file-write,guest-file-seek,guest-file-flush,guest-exec,guest-exec-status


    1. Mark this line as comment or delete it.
    2. Restart QEMU Guest Agent:

      systemctl restart qemu-guest-agent

SPICE

If you need to connect to VMs created from the template via SPICE, install the spice-vdagent and spice-webdavd software packages:

Debian, Ubuntu
apt -y install spice-vdagent spice-webdavd
CentOS, AlmaLinux
yum -y install spice-vdagent

For the CentOS template, add the software launch to the autostart:

systemctl enable spice-vdagent

System utilities

Check for the available curl and vim utilities:

curl -V
vim --version

If any of the utilities are not installed, install them:

Debian, Ubuntu
apt -y install curl vim
CentOS, AlmaLinux
yum -y install curl vim

SSH configuration

Enable SSH connection with superuser account and password authentication. To do this, specify the parameters in the /etc/ssh/sshd_config file:

PermitRootLogin yes
PasswordAuthentication yes

Clear command history

After installing and configuring all software packages, clear the command history:

rm /root/.bash_history
history -c 

Template for KVM cluster

To prepare a template:

  1. Create a virtual machine (VM) with the required OS version.
  2. Configure the operating system and install the necessary software packets.
  3. Stop the VM.
  4. Determine the format in which the VM disk is saved:

    qemu-img info <disk_path> | grep "file format"
    Comments to the command
  5. Copy the VM disk file to a separate directory. If the disk is not saved in RAW format, convert it to RAW format:

    qemu-img convert -f <disk_format> -O raw <disk_path> <image_path>
    Comments to the command
  6. Optimize the image file with virt-sparsify utility:

    LIBGUESTFS_BACKEND=direct virt-sparsify --in-place <image_path>
    Comments to the command
  7. Clear the image of personal information with virt-sysprep utility:

    LIBGUESTFS_BACKEND=direct virt-sysprep --format=raw --operations <sysprep_ops> --add <image_path> --root-password random
    Comments to the command
  8. To make the VMs created from the template have a unique machine-id parameter, run the command: 

    LIBGUESTFS_BACKEND=direct virt-sysprep --format=raw --operations machine-id --add <image_path> --root-password random
    Comments to the command


  9. Create an archive with the image in .xz format:

    xz <image_path>
    Comments to the command
  10. Copy the archive to the repository directory.
  11. Add the template information to the metadata.json repository description file. Read more in OS templates repositories.

Template for KVM cluster

To prepare a template:

  1. Create a /rootfs directory and copy the contents of the file system there. You can use the debootstrap utility for a Debian-based OS template, or the yumbootstrap utility for a Red Hat Linux-based OS template.
  2. Make the necessary changes to the OS files.
  3. Create a metadata.yaml file with the required parameters:
    1. architecture — CPU architecture. For example, x86_64 or amd64;
    2. creation_date — template creation time in Unix time.

      Example of metadata.yaml file
      architecture: amd64
      creation_date: 1600761137

      Read more about the file format in the official LXD documentation .

  4. Create a tar.gz archive with the /rootfs directory and the metadata.yaml file.
  5. Copy the archive to the repository directory.
  6. Add the template information to the metadata.json repository description file. Read more in OS templates repositories.
Useful tips