From 9e9efba5c3d286b6c7ec1d39106293e6431091c3 Mon Sep 17 00:00:00 2001 From: Ludwig Mey Date: Sun, 7 Dec 2025 13:29:48 +1300 Subject: [PATCH] Notes completed for kvm cloning --- KVM-Notes/Cloning.md | 80 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/KVM-Notes/Cloning.md b/KVM-Notes/Cloning.md index 92a04eb..a7967f8 100644 --- a/KVM-Notes/Cloning.md +++ b/KVM-Notes/Cloning.md @@ -3,4 +3,82 @@ *Prep* Install the base OS. Install all required apps -Install all required updates \ No newline at end of file + * openssh-server +Install all required updates + +Shutdown guest + * virsh shotdown $guest-vm + + +On the VM Host server make sure you have libgustsfs-tools + +``` +apt list --installed |grep -i libguestfs-tools +``` + +if its not there, install it. + +``` +sudo apt install libguestfs-tools +``` + + +This step strips stuff that must be unique per VM (machine-id, SSH keys, etc.) from the *template*. + +``` +sudo virt-sysprep -d $guest-vm \ + --operations machine-id,ssh-hostkeys,udev-persistent-net,logfiles,tmp-files +``` + +Your output should be similiar to the following: + +``` +sudo virt-sysprep -d Debian-Base --operations machine-id,ssh-hostkeys,udev-persistent-net,logfiles,tmp-files +[ 0.0] Examining the guest ... +[ 17.4] Performing "logfiles" ... +[ 17.6] Performing "machine-id" ... +[ 17.6] Performing "ssh-hostkeys" ... +[ 17.6] Performing "tmp-files" ... +[ 17.6] Performing "udev-persistent-net" ... +``` + +The base is now ready to go. + +**Create Clone** + +sudo virt-clone --original $guest-vm \ + --name guest-01 \ + --auto-clone + +example + +``` +sudo virt-clone --original Debian-Base \ + --name Node01 \ + --auto-clone +Allocating 'Node01.qcow2' | 1.6 GB 00:00:03 ... + +Clone 'Node01' created successfully +``` + +Confirm your clones have been made + +``` +virsh list --all + Id Name State +--------------------------------- + 1 downloads running + - Debian-Base shut off + - k8s-node1 shut off + - k8s-node2 shut off + - k8s-node3 shut off + - k8s-node4 shut off + - k8s-node5 shut off + - Node01 shut off + - Node02 shut off + - Node03 shut off + - Node04 shut off + - Node05 shut off + - Ubuntu_Default shut off + +``` \ No newline at end of file