How to clone a Linux Physical server or workstation to Hyper-V
So at one particular company, they use Hyper-V (on 2012 R1) to drive their virtualization platform. I used to have problems with Hyper-V since it had poor Linux and BSD support, but that is coming along now. Major Linux distros are embraced by Microsoft and the Linux Kernel has support, but the tools to convert are lagging. A little Googling will find that there are some guides using outdated tools that aren’t made by Microsoft. So here is an easier way to do that and save your day:
1. Download Clonezilla and copy the Physical Linux computer to an img file on an external drive of some sort. No special options are required if you do disk to image.
2. Create a DYNAMIC partition on Hyper-V that is big enough to absorb the source partition. If the machine was a 500GB machine, make a 550GB partition and thin provision it.
3. Restore the image file by booting up Clonezilla from the guest host you build in Hyper-V.
4. When done, download GParted and shrink the partition down to whatever size you want. If you were only using 200GB from my example above, you can shrink down to 300GB if you would like.
5. With the guest machine off, make sure your drive in Hyper-V is a vhdx format, not vhd. If it is vhd, convert it to vhdx and then, only then, can you shrink the virtual disk down to your Gparted size.
6. As of this posting, Linux and Hyper-V can’t get along with dynamic MAC addresses for nic adapters, set a static MAC to your NICs in your guest linux machine, be ready to setup your nics again on the distro of your choice. Also, do not use Time-Sync from the hyper-v vitualization tools, as of this posting, it isn’t the most stable and I use ntpupdate rather than tweaking config files, time.nist.gov is a great NTP server to use.
That’s really it, I’m running Kali Linux and CentOS on a Hyper-V advanced cluster