How to perform a P2V conversion for FreeBSD to run on Hyper-V
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).
- Upgrade the FreeBSD machine to version 8.0-RELEASE. This is mandatory.
- Get Hyper-V installed and configured, including enabling Intel VT in the BIOS.
- 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.
- 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.
- 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.
- 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.
- 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.
- Start the VM. If you receive errors like “Invalid slice”, you need to do the following:
- Insert the Live FS ISO into the virtual DVD drive and reboot the VM.
- 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.
- Exit the Live FS system, eject the ISO, and reboot the VM.
This should take care of the “bad” boot loader.
- 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)
- Re-mount the root partition as writeable with:
mount -u /Likewise, mount /usr and /tmp with:
mount -a
mount /dev/ad0s1f /usr
mount /dev/ad0s1e /tmp - 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.
- Re-mount the root partition as writeable with:
- 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
Categories: FreeBSD, Hyper-V, Virtualization, Windows Server 2008
Oh, no problem. Piece o’ cake. Yeh, I can do that. Sure. Yep.
I was breaking out in a cold sweat just reading that….sheesh….
Glad it worked out.
But it won’t be anything but kvm for me.
@Dietrich Schmitz
It actually wasn’t bad compared to a P2V of a Windows 2000 Server to Hyper-V machine that I participated in a few months ago. Hyper-V rocks for recent Windows installs, particularly server OS’s (the toolset doesn’t lend itself well to day-to-day desktop style usage), basically 2003 on up. They are making progress with Linux, since that’s the big dog in the non-Windows server room right now. But for anything else, it really isn’t so hot.
J.Ja
Hi,
I tried FreBSD 8.0 on a Hyper-V R2 erlier this week and it did not work … then I googled and found this post and tried again … now it worked. Erliar I got a panic something and I guess I just thought they havent fixed it in R2. Maybe I tried the x64 … and not the x86 … so I’m almost a happy man, as I can change the Linux boxes I have in the virtuel environment.
But I have one problem … dont know if it has happend to you … the NIC just stop working … only way to get it up again it to “ifconfig de0 down” and then “up” it again … and there are network connection again.
I also got some other errors like they talks about in this post:
http://forums.freebsd.org/archive/index.php/t-2805.html
So … have you experienced that the network connection disapears ?
@Mikael Syska
Glad this worked for you! Sorry, the NIC has been rock solid for me in mine, so i can’t comment on that particular issue.
J.Ja