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.
[[email protected] ~]# rm -f /etc/ssh/ssh_host_*
Step:3 Remove the hostname and set it as local host
[[email protected] ~]# hostnamectl set-hostname 'localhost'
Step:4 Remove the host specific information
Remove the followings :
- udev rules
- MAC Address & UUID
[[email protected] ~]# rm -f /etc/udev/rules.d/*-persistent-*.rules [[email protected] ~]# sed -i '/^HWADDR=/d' /etc/sysconfig/network-scripts/ifcfg-* [[email protected] ~]# sed -i '/^UUID=/d' /etc/sysconfig/network-scripts/ifcfg-*
Step:5 Remove RHN systemid associated with virtual machine
[[email protected] ~]# 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.
[[email protected] ~]# 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.