How to Virtualize a Linux Server using Only Microsoft Hyper-V

There are many ways to virtualize a Linux server. In this blog post, I will show you how to convert a Linux hard drive with many partitions to a VHD file in order to virtualize it in Microsoft Hyper-V. I have a Linux system with RAID-1 configuration (Hardware RAID). I would like to virtualize it but I learn that the dd process in Linux is a bit time consuming and error prone. I decided to take one of the hard drives in the array, connect it to my Windows 10 Technical Preview box via a USB3 cradle. My Windows 10 TP recognizes this drive in disk management but it cannot present the data because this is a Linux drive with Linux partitions. The following step by step guide will show you how to convert the drive to a VHD (or VHDX) file for Hyper-V support.

On the Windows 10 (or even Windows 8, 8.1, Windows 7), launch the Control Panel. Click Programs and Features.

Click on Turn Windows features on or off on the left hand side

Now select Hyper-V and all of its features in the subtree. Click OK when done.

Once completed, restart the computer.

Hyper-V Manager main interface.

Insert the Linux Disk to a USB3 connection. On your computer, click Start, type

diskmgmt.msc

You should see the disk available with many Linux partitions. Note that on my system, it is called Disk 7. Please note this carefully; otherwise you could be working on the wrong disk!

In Hyper-V manager, click the computer name, in this case it is WIN10TP, then click New. Choose Hard Disk.

Click Next at the Welcoming screen.

Choose VHD and click Next.

Choose Dynamically expanding and click Next.

Enter the file name and choose the location to store the file. Click Next.

Choose the “Copy the contents of the specified physical disk” and select the disk that you noted above. Click Next.

Click Finish.

Now we should wait for the process to complete. This entire process could take several hours so it is recommended that we perform this conversion overnight.

After the conversion is completed, you will see the content of the destination directory as follows:

We need to go back to Hyper-V Manager, click New, choose Virtual Machine…

Click Next.

Note that since we do not have a Virtual Switch configured yet, so the connection is set to “Not Connected

Choose Use an existing virtual hard disk and browse for the VHD file that we created earlier. Click Next.

Click Finish.

As we can see, a new VM has been created for us.

Now we will create a Virtual Switch for network connectivity. Click Virtual Switch Manager.

Click New Virtual Network Switch. Choose External, and click the Create Virtual Switch button.

Name the virtual switch MyVS and click OK.

Click Yes at this warning about network disruption.

Back to the Hyper-V Manager, click Settings…

Click Network Adapter, select MyVS from the virtual switch drop down list, then click OK.

Click Start to turn on the VM.

Click the Connect… button to connect to the server’s console.

Wait for the server to boot up. You will see that the login screen is presented.

This means we have successfully virtualized our Linux Server to host it on the Microsoft Hyper-V server.