Pages

Monday, October 22, 2012

Migrate Physical Linux to Hyper-V

This past weekend, I had successfully moved a physical Linux box to a Windows Server 2008 R2 Hyper-V.

I thought this might have been a long and very difficult process, but is wasn't with the help of Clonezilla. I will walk you through the process that I did below.

Items Needed:
Portable USB Hard Drive (I used a 1TB Drive)
CloneZilla ISO/CD

The first step in the process was to make sure that no one was using the server and then to shut the server down.

I then booted up the computer with CloneZilla and followed the on-screen instruction  under "Beginner". (I have a bootable flash with CloneZilla, if any one would like directions on how to do that, please let me know and I will post some.)

While Clonezilla was working on backing up the server, I created a Hyper-V virtual server.

Once I had an image file of the physical machine from CloneZilla, I plugged it in to the Server 2008 box.

Now, this was a tricky part for me: How do I get a Hyper-V guest to "see" a physical usb drive. This turned out to be simpler than I thought. If you go into "Disk Management" and right click on the usb drive and select "Offline", you can add it to a Hyper-V guest.

Once I added the usb drive to the guest, I booted the guest using Clonezilla ISO. From here, I followed the directions to restore the image. Once it finished, I ejected the ISO from the guest and booted the server.

Once the server finished booting, I made sure that the users could access it. The users have not noticed any difference.

I repeated this process on another server that had a raid card in it and CloneZilla had no problem with it.


2 comments:

  1. Based on this post, I thought I would try this procedure out, but I got stuck on mounting the USB drive on the new host, as it's a Hyper-V Server (not Hyper-V on Win 2012 Server), so it doesn't have a Disk Management console -- you have to do it all with diskpart. I've never gotten diskpart to mount a USB stick -- maybe I'm just doing it wrong, but I found an even easier solution that doesn't use any removable media at all (except a clonezilla live CD).

    1. Download and burn Clonezilla.
    2. If you don't already have one, create a network share on any other machine in your network (this can be either a Windows share or Samba on a Linux box: it needs enough free space for the linux image, but the image is sparse, so it only includes the data, not free space).
    3. Run Clonezilla using the default backup options, select backup to network share (i.e. Samba).
    4. Create the new VM with an empty .vhd drive (not sure if this can be smaller than the original drive).
    5. Attach the host's physical CD drive to the new VM, put the Clonezilla CD in the drive, and start the VM.
    6. Accessing the VM's desktop through the Hyper-V manager, restore the image from the network share to the empty .vhd using the default Clonezilla settings.
    7. Remove the CD and restart the VM. Tada!

    It was really simple actually. Thanks, Spencer, for blogging about this -- I don't think I would have realized it was so easy without your post.

    ReplyDelete
  2. From what I have found if the drive shows as "removable" in explorer then you can only access it from a hyper-v VM by using RDP local devices and resources.

    ReplyDelete