First thing we have to do is shutdown the VM machine from which we have to create the template. We can shutdown the machine either internally or externally. To perform the shutdown internally issue the command: #shutdown -h now
To shutdown externally from the node we can use the command: virsh shutdown kvm101
where the kvm101 is the virtual machine identifier.
To create the template we can use the KVM script /scripts/kvmtemplate
KVM templates can be created in two generations generation1 and generation2. Generation 1 templates are fixed size byte by byte images it should be used when the vps image contains a partition or file system that can't be manipulated from the node. Generation2 templates are very flexible as this supports resizing and configuration.
Creating Genaration1 Template
/scripts/kvmtemplate --mode=package --vmid=kvm101 --generation=1
Replace the kvm101 with your vpsID. This will take some time after completion you will get an output like this
Template: /home/solusvm/kvm/template/template-149fee4.gz. Next we can rename the template if we want.
Creating Generation2 Template
/scripts/kvmtemplate --mode=prescan --vmid=kvm101 --generation=2
/scripts/kvmtemplate --mode=prepare --vmid=kvm101 --generation=2
/scripts/kvmtemplate --mode=package --vmid=kvm101 --generation=2
Replace the kvm101 with your VM id.
We will get an output like the following:
Template: /home/solusvm/kvm/template/template-149fee.gz
We can rename the template if we want.