How to Create Virtual Machine Template in oVirt Environment

A template is a pre-installed and pre-configured virtual machine and Templates become beneficial where we need to deploy large number similar virtual machines.Templates help us to reduce the time to deploy virtual machine and also  reduce the amount of disk space needed.A template does not require to be cloned. Instead a small overlay can be put on top of the base image to store just the changes for one particular instance.

To Convert a virtual machine into a template we need to generalize the virtual machine or in other words sealing virtual machine.

In our previous articles we have already discuss the following topics.

I am assuming either CentOS 7 or RHEL 7 Virtual is already deployed in oVirt environment. We will be using this virtual machine and will convert it into a template. Refer the following steps :

Step:1 Login to Virtual Machine Console

SSH the virtual  machine as a root user.

Step:2 Remove SSH host keys  using rm command.

[root@linuxtechi ~]# rm -f /etc/ssh/ssh_host_*

Step:3 Remove the hostname and set it as local host

[root@linuxtechi ~]# hostnamectl set-hostname 'localhost'

Step:4 Remove the host specific information

Remove the followings :

  • udev rules
  • MAC Address & UUID
[root@linuxtechi ~]# rm -f /etc/udev/rules.d/*-persistent-*.rules
[root@linuxtechi ~]# sed -i '/^HWADDR=/d' /etc/sysconfig/network-scripts/ifcfg-*
[root@linuxtechi ~]# sed -i '/^UUID=/d' /etc/sysconfig/network-scripts/ifcfg-*

Step:5 Remove RHN systemid associated with virtual machine

[root@linuxtechi ~]# rm -f /etc/sysconfig/rhn/systemid

Step:6 Run the command sys-unconfig

Run the command sys-unconfig to complete the process and it will also shutdown the virtual machine.

[root@linuxtechi ~]# sys-unconfig

Now our Virtual Machine is ready for template.

Do the right click on the Machine and select the “Make Template” option


Specify the Name and Description of the template and click on OK


It will take couple of minutes to create template from the virtual machine. Once Done go to templates Tab and verify whether the newly created template is there or not.


Now start deploying virtual machine from template.

Got to the Virtual Machine Tab , click on “New VM“, Select the template that we have created in above steps. Specify the VM name and Description


When we click on OK , it will start creating the virtual machine from template. Example is shown below :


As we can see that after couple of minutes Virtual Machine “test_server1” has been successfully launched from template.

That’s all, hope you got an idea how to create a template from a Virtual machine.Please share your feedback and comments.

Share on:

I am a Cloud Consultant with over 15 years of experience in Linux, Kubernetes, cloud technologies (AWS, Azure, OpenStack), automation (Ansible, Terraform), and DevOps. I hold certifications like RHCA, CKA, CKAD, CKS, AWS, and Azure.

1 thought on “How to Create Virtual Machine Template in oVirt Environment”

  1. This is a great series of articles. Well done!

    I do have a question about SSH access to the newly created VM from a template.
    For example, in the AWS EC2 launch; the user gets an option to use an existing key pair or create a new pair. In the latter case, you then download and save the “private” (.pem) file.

    Likewise, it should be possible to install the RSA public key via a ‘cloudinit’ directive when the VM instance is created.

    It would be helpful to highlight both these methods in this article.


Leave a Comment