Archive

Archive for the ‘Hyper-V’ Category

How to perform a P2V conversion for FreeBSD to run on Hyper-V

November 29th, 2009 Justin James 4 comments

One of my big projects with my personal server setup, was to turn my current physical FreeBSD server into a Hyper-V VM. Why would I do this? Don’t ask, because I don’t want to start a religous war here… let’s just say that as much as I like FreeBSD for a lot of purposes, I do not like living with it as a sys admin without a paycheck attached.

So, here’s how I went from FreeBSD on a physical machine (garbage x64 hardware) to a Hyper-V VM (Windows 2008 R2 on garbage x64 hardware).

  1. Upgrade the FreeBSD machine to version 8.0-RELEASE. This is mandatory.
  2. Get Hyper-V installed and configured, including enabling Intel VT in the BIOS.
  3. Shut down both machines. Transfer the physical hard drive from the FreeBSD machine to the Windows 2008 R2 machine. Turn on the 2008 R2 machine, and verify in Disk Management that the transferred drive is visible.
  4. Create a new Hyper-V VM for the machine, but do not specify a hard disk. Go back into the settings, and remove the NIC that was put into the VM. Do “Add new hardware” and select “Legacy Network Adapter”, and connect the new NIC to the network of choice.
  5. Create a new virtual disk. Select “Fixed” type, and on the next page in the wizard, tell it to copy the contents of a physical disk. Choose the disk you transferred from the FreeBSD machine.
  6. Go eat dinner, walk the dog, read a magazine. You’ll be here a while during the disk copy. To be on the safe side, go download the “Live FS” FreeBSD ISO appropriate for your installed FreeBSD version.
  7. Once the new virtual disk has been created, go back into the VM settings, move the optical drive to postion 1 on the IDE chain, and then add the newly created disk to the VM on position 0 on the IDE chain.
  8. Start the VM. If you receive errors like “Invalid slice”, you need to do the following:
    1. Insert the Live FS ISO into the virtual DVD drive and reboot the VM.
    2. Go to “Configure” and then “Fdisk”. Set the main drive slice (the big one) to be bootable, and then press “W” to write the information to disk. Before it writes, it will ask about a boot loader; choose the standard one, unless you have a good reason not to and know what you are doing.
    3. Exit the Live FS system, eject the ISO, and reboot the VM.

    This should take care of the “bad” boot loader.

  9. If the physical disk in the original server was not device “ad0″ (for example, it was a SCSI drive or a RAID 1 member), then the system will spaz when you boot and drop to single user mode. Not to worry! In single user mode, do the following: (note: if you can’t even get into single user mode, boot off of the Live FS CD and use the “Fixit” shell)
    1. Re-mount the root partition as writeable with:mount -u /
      mount -a
      Likewise, mount /usr and /tmp with:
      mount /dev/ad0s1f /usr
      mount /dev/ad0s1e /tmp
    2. Now you can actually use your text editor of choice to edit /etc/fstab and set the references to the old drive to be references to the new drive as ad0. Do that and reboot.
  10. You are in the home stretch now! You should be booted into FreeBSD, albeit a crippled one, because the NIC isn’t configured. Go edit /etc/rc.conf and change the reference to your old NIC to be a reference to de0 (the NIC that Hyper-V provides). Reboot again, and you should be done!

This is what I did… it might not work 100% for you, for better or for worse.

J.Ja

Hyper-V in Server 2008 R2 has one super new feature

October 1st, 2009 Justin James 4 comments

I put together a Windows Server 2008 R2 box over the weekend (my old Vista machine is now the server). I spent part of today working on trying to do a P2V conversion of my FreeBSD server to bring it onto the box in Hyper-V. At first, I tried using Acronis Home 2009 to clone the disk, then re-clone into the VM, like I’ve done before. For whatever reason, it did not like the RAID in the FreeBSD box, and wouldn’t read the data from it. Along the way, I decided to prep the new Hyper-V VM, and lo and behold, I discovered it’s super new feature: when creating a new virtual hard drive, you can copy an existing physical drive (not “file system”, the entire drive!) as the contents of the virtual drive. This means that you can take the disk out of the old system, hook it up to the new system, clone it into the VM really quick, and be on your merry way. The only real drawbacks are that you cannot do a dynamically expanding disk like this, so the new VHD is the same size as the physical disk it was clone from (although it will be fast), and that it takes forever because it does a sector-by-sector copy of the disk. While this is still not a proper substitute for a true P2V agent-based conversion, this is pretty darned close, especially for OS’s that are not mainstream enough to justify someone writing the conversion agent.

J.Ja

Categories: FreeBSD, Hyper-V, Windows Server 2008 Tags: