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:

  1. Go to Hyper-V hard disk directory - could be D:\Virtual Hard Disks

  2. Copy/paste .vhdx (virtual hard disk file)

  3. Rename .vhdx - could be the new hostname (virtual hard disk file)

  4. Create a new VM in Hyper-V as usual

  5. Do steps as usual, but instead of creating a new HD, use existing HDD. Point it to your newly copied+renamed .vhdx-file.

  6. Start the machine

  7. Change the IP address of the machine for primary ethernet interface

  8. Change the hostname of the machine

  9. Linux only: remove persistent net rules file ($ rm -f /etc/udev/rules.d/70-persistent-net.rules)

  10. Reboot

  11. Check if everything is OK