KVM | Cloning a Guest VM

Опубликовано: 28 Октябрь 2024
на канале: Yogesh Mehta
4,967
44

When working in enterprise setups its not advisable to create the VMs from scratch and configure every time as it will make the build lengthy and chance of mistakes. Instead build engineers create a VM , perform the SOE configuration and save it as SOE. For any future build , they just clone from the SOE VM.

In this exercise we will create a VM from template or in other works : we are going to clone a VM.


Shutdown the Source VM , if running
virsh shutdown source_vm


Clone the VM ( Create a new VM from source vm)
virt-clone --original source_vm --name target_vm -f /var/lib/libvirt/images/target_vm.qcow2

With the aforementioned command , a new VM will be created with all settings. disk size and compute similar to source VM. Later you can perform the resource/disk size upgrade as per the requirements.

Power on on and Test the Target VM
virsh start target_vm

Watch the video for details :