Can I clone my Proxmox VM? I want multiple VMs like my existing Proxmox VM.
That was a recent support ticket received at our Infrastructure Management Services department where we monitor and manage our customer servers.
When you need to setup many individual VMs all of a sudden, it becomes a tiresome task. That’s where you can use the cloning process in Proxmox.
Today, we’ll discuss how our Support Engineers efficiently clone a Proxmox VM.
Why you need a Clone?
Before going into the details, let’s first see the need of cloning a Proxmox VM.
For server providers, installing guest operating system and applications is a time consuming task. With clones, servers owners can create VMs from a single installation and configuration process.
And, this becomes really helpful when you need to install VMs to a group or create identically configured VMs in Proxmox clusters.
Similarly, on VMs running critical websites, cloning brings in redundancy, because it creates an exact copy of the live servers.
However, one downside is that cloning is applicable only for KVM based VMs, not for OpenVZ containers.
Clone VM in Proxmox – How to do it?
Now, let’s see how our Dedicated Support Engineers clone a VM in Proxmox.
1) Prepare Proxmox VM
We usually do the cloning process from Proxmox GUI. So, we make sure we’ve the root logins to GUI or other user has the privilege to create VM.
Secondly, we ensure that the existing VM has all the required configuration such as memory, disk space, CPU, etc. Because, all clones created from this VM will have identical configurations.
In addition to that, we check the versions of all software running on the Proxmox VM prior to the cloning process.
2) Clone the VM
The actual cloning process happens in this step. We follow the below series of steps to clone the Proxmox VM,
- Select the VM from the Proxmox GUI and right click on it.
- Click Clone to open a cloning dialogue box.
- Select the options such as target node, new VM ID, VM name, cloning mode, etc.
- Click on Clone to start the cloning process.
We can select the cloning mode as either Linked Clone or Full Clone.
A Full clone VM is a complete and independent copy of the original VM. So, it requires the same disk space as original.
On the other hand, Linked clone VM is a copy of the VM and shares the disks with the parent virtual machine. So, it requires less disk space.
3) Changes after Cloning
There are some issues that can pop up after the cloning process. That’s why, our Support Engineers maintain a checklist of problems that may occur after cloning and fix it.
We mainly see that duplicate VMs have the same hostname, MAC address, SSH keys, etc. of the original VM. So, if the original VM and the clones are running on the same network, it can create problems.
Let’s see how our Support Experts take care of these issues.
i) Correct hostname
We login to the cloned VM terminal as root user and change the hostname of the server. On Linux VMs, we change the hostname from /etc/hostname file. In addition to that, we make sure that the new hostname reflects in the files /etc/hosts and /etc/network/interfaces.
Further, we reboot the server to reflect these changes.
ii) Change MAC address
When we duplicate an existing VM, the MAC address also gets duplicated. This may create serious problems. In such cases, our Support Experts remove the virtual NIC(eth0) and create a new one. This will create a new MAC address for the VM. Further, we restart the VM and confirm if everything works fine.
iii) Change SSH keys
The SSH host keys should be identical for each VM to ensure security. So, it’s important to regenerate the SSH keys after cloning a virtual machine. For example, on a Linux VM, we regenerate the SSH keys using the following steps.
- Login to VM via terminal as root user.
- Remove the previous SSH keys from the location “/etc/ssh/“.
- Reconfigure Openssh. For example, see the below command.
Considering the above problems that can happen while cloning an existing VM, our Support Engineers sometimes opt the option of creating the VMs from a template. Let’s discuss that case too.
A template is a pre-configured operating system image that can be used to deploy KVM virtual machines. However, a VM that’s converted to a template can’t be powered on or roll back to functioning state.
We follow the below steps to convert a VM to a template.
- Install the VM with all the drivers and software packages.
- Remove the user data, password and keys and power off the VM.
- Right click on the VM and click Convert to template.
Then, we can go ahead with creating a new VM from this template. These steps are identical to the VM cloning process without a template. But. it prevents the overhead of changing the hostname, MAC address, etc. of the new VM.
[Need an expert to clone your Proxmox VM? Our experienced Server Experts can do it for you.]
In short, the process of cloning a VM in Proxmox involves a series of steps. Today, we’ve discussed how our Dedicated Support Engineers effectively clone a Proxmox VM.