Linux > Virtualization

Creating Template From an Existing VM in KVM

(1/1)

jominj:
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: ---#shutdown -h now
--- End code ---
To shutdown externally from the node we can use the command:
--- Code: ---virsh shutdown kvm101
--- End code ---
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: ---/scripts/kvmtemplate --mode=package --vmid=kvm101 --generation=1
--- End code ---
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: ---/scripts/kvmtemplate --mode=prescan --vmid=kvm101 --generation=2
/scripts/kvmtemplate --mode=prepare --vmid=kvm101 --generation=2
/scripts/kvmtemplate --mode=package --vmid=kvm101 --generation=2

--- End code ---
Replace the kvm101 with your VM id.

We will get an output like the following:

--- Code: ---Template: /home/solusvm/kvm/template/template-149fee.gz
--- End code ---
We can rename the template if we want.

Navigation

[0] Message Index

Go to full version