Cloning a Linux guest comes with its own challenges as it doesn’t include an out-of-the-box tool like SysPrep to generalise OS unique settings like Windows.
This scenario is composed of:
- Microsoft Windows Server 2012 R2
- Hyper-V Manager
- Red Hat Enterprise Linux Server Release 6.6
In Hyper-V Manager:
- Right click an existing VM you would like to clone from and click Export.
- Select a location to export current VM. I suggest a generic folder called export located in the same directory storing existing VM files.
- Right click Hyper-V node on the left hand pane and select Import Virtual Machine…
- Follow the Wizard selecting the newly exported folder to import from (the sub-folder created within export).
- In the Wizard, change Import Type to Copy the virtual machine (create a new unique ID).
- In the wizard, change store locations to a new location. Ideally into a folder corresponding to new server hostname, removing subfolder structures such as snapshots and machineconfig. (ie. C:\HyperV\NewHostname).
- Ensure storage folders is also pointing to the same folder as above step.
- Complete the Wizard.
- Modify newly imported VM Settings:
- Change VM name to correspond.
- Disable or Disconnect network interface card from Virtual Switch.
- Start VM (This is required to bring VM from Saved state to normal).
- Modify /etc/sysconfig/network updating the hostname.
- Modify /etc/sysconfig/network-scripts/ifcfg-eth0 updating the IP address
- Power VM off.
- Modify VM settings, connect network adapter and alocate static MAC address.
- Power VM on.
- Modify /etc/sysconfig/network-scripts/ifcfg-eth0 updating HWADDR to match new static MAC address.
- Delete /etc/udev/rules.d/70-persistent-net.rules file reboot. This will enable the auto-detection of the NIC at reboot.
- Reboot server.