Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Creating Template From an Existing VM in KVM  (Read 7505 times)

0 Members and 1 Guest are viewing this topic.

jominj

  • Guest
Creating Template From an Existing VM in KVM
« on: March 24, 2014, 02:08:31 pm »
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:
Code: [Select]
#shutdown -h nowTo shutdown externally from the node we can use the command:
Code: [Select]
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
Code: [Select]
/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
Code: [Select]
/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:
Code: [Select]
Template: /home/solusvm/kvm/template/template-149fee.gzWe can rename the template if we want.