How to clone a VM in Hyper-V
This was kind of a mystery to me, but it turned out to be really easy.
Note: For Windows it is best to Sysprep before cloning.
Steps:
Go to Hyper-V hard disk directory - could be
D:\Virtual Hard Disks
Copy/paste .vhdx (virtual hard disk file)
Rename .vhdx - could be the new hostname (virtual hard disk file)
Create a new VM in Hyper-V as usual
Do steps as usual, but instead of creating a new HD, use existing HDD. Point it to your newly copied+renamed .vhdx-file.
Start the machine
Change the IP address of the machine for primary ethernet interface
Change the hostname of the machine
Linux only: remove persistent net rules file (
$ rm -f /etc/udev/rules.d/70-persistent-net.rules
)Reboot
Check if everything is OK