Duplicate Virtual Machines
Create virtual machines by copying a previous one
Virtual machine environments allow to create vm from scratch, of course, but it is also possible and sometimes useful to be able to create one vm as a perfect copy of another one you already have.
There are issues you have to take care of, anyway:
- a duplicated vm will have exactly the same hostname of the original one
- a duplicated vm will have exactly the same mac address(es) of the original one
- a duplicated vm will have exactly the same ssh keys of the original one
- a duplicated vm will have exactly the same SID keys of the original one (windows machines only)
if both the original vm and the "copy" are running together in the same network, this will cause issues and/or unsafe vm environments.
How to change vm hostname
It should be sufficient to
- On Linux guest OSes
- log into a vm terminal as root
- change the /etc/hostname file content to the new hostname
- change the /etc/hosts file content accordingly
- reboot the vm (#reboot now)
How to change the mac address(es)
Any network card has its (supposedly) unique MAC address, you know. Virtual nics are pretty much ethe same as real, but easier to manage ;-). When you duplicate an existing vm, also its MAC address gets duplicated, and that is BAD.
Supposing your vm has only one virtual nic, you can
- stop the vm
- remove the virtual nic (eg: eth0) from pve web interface,
- create a new one, this will get a new MAC, and your vm will see it always as eth0.
start the vm