After I got Xen installed on Ubuntu Server 8.04, I wanted to install FreeBSD 7.0, too. But this was in no regards as easy as installing Ubuntu Server 8.04 as a domU! To run a domU you have to possibilities with Xen: either with a modified kernel or using the so-called HVM (Hardware Virtual Machine) possibility. The latter has to be used when using operating systems on which the kernel cannot be changed, e.g. Windows. To be able to use the HVM-method, a compatible processor is required (please refer to http://wiki.xensource.com/xenwiki/HVM_Compatible_Processors for a list of these, but generally speaking Intel VT or AMD-V is required). The downside with HVM is that it doesn't yield as high performance as a modified kernel - generally speaking (optimized device drivers for some operating systems, e.g. Windows 2003 Server, should be available). On the other hand, the fact that you're able to use operating systems as domU without modifying the kernel is rather applicable! In general, please refer to http://wiki.xensource.com/xenwiki/OSCompatibility in order to review operating system compatibility.
I, of course, prefer the use a modified kernel given the performance difference. In Ubuntu the same Xen-enabled kernel can be used for both dom0 and for domUs (and often is, too). It can be a bit tough to understand how it works, but don't mind about that.
Well, as said I wanted to use FreeBSD 7.0 as domU, so I needed to find an appropriate Xen-enabled kernel to use. As a starting point, I consulted section 21.2.2.2 in the Handbook at http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/virtualization-guest.html. Here it was possible to download a kernel for Xen 3.0, but I have Xen 3.2 - and the link to the kernel has broken anyway. Well, not much success here. And after several hours of search the web I hadn't find anything usable. Not besides noticing the fact that it didn't seemed like a task with high priority for the FreeBSD-folks to maintain a usable kernel for the newest version of Xen. Sad but true, apparently.
I accepted that fact, although it's laborious. So instead I used the HVM-method. As mentioned, you can use this method to install other operating systems with a unmodified kernel like Windows, too.
Firsty download the iso-file you want to use as a installation source. I did this on dom0:
mkdir iso cd iso wget ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/7.0/7.0-RELEASE-i386-bootonly.iso
As with other domUs you have to decide whether to use a file, partition or whatever as a disk. Again I use a LV (logical volume) as the root file system, i.e. /dev/lvmstore/lv2, and a partition as swap, i.e. /dev/sda7. First create a configuration file /etc/xen/domU2.cfg:
name = 'domU2' builder = 'hvm' device_model = '/usr/lib/xen/bin/qemu-dm' kernel = '/usr/lib/xen/boot/hvmloader' acpi = '0' memory = '512' maxmem = '1536' disk = ['phy:/dev/lvmstore/lv2,hda,w','phy:/dev/sda7,hdb,w','file:/root/iso/7.0-RELEASE-i386-bootonly.iso,hdc:cdrom,r'] vif = ['type=ioemu,bridge=eth0'] boot = 'd' vnc = '1' serial = 'pty' on_poweroff = 'destroy' on_reboot = 'restart' on_crash = 'restart' vcpus = '2' extra = 'xencons=tty1'
If you want a 64 bit domU, you can instead use this:
device_model = "/usr/lib64/xen/bin/qemu-dm"And then start the machine:
xm create /etc/xen/domU2.cfg
If you get an error like losetup -r /dev/loop17 /root/iso/7.0-RELEASE-i386-bootonly.iso failed, you can try run the command manually and use the newly create loop-device instead of the iso. First setup the device:
losetup -r /dev/loop17 /root/iso/7.0-RELEASE-i386-bootonly.iso
And then change the cfg-file accordingly:
#disk = ['phy:/dev/lvmstore/lv2,hda,w','phy:/dev/sda7,hdb,w','file:/root/iso/7.0-RELEASE-i386-bootonly.iso,hdc:cdrom,r'] disk = ['phy:/dev/lvmstore/lv2,hda,w','phy:/dev/sda7,hdb,w','phy:/dev/loop17,hdc:cdrom,r']
Now verify that the machine is running - and destroy it afterwards (we need to setup some things before actually installing FreeBSD):
xm list xm destroy domU2
Please notice that with HVM we don't attach the console with the -c-parameter with xm create - instead we use VNC to connect to it until the system is installed. Because there's no X on dom0, we use X11-forwarding. From your workstation log into dom0 like this:
ssh -X root@dom0
Now add this line to /etc/xen/xend-config.sxp:
(vnc-listen '0.0.0.0')
And restart the service:
/etc/init.d/xend restart
On your own workstation, you now use vncviewer to connect - just enter the address of your dom0-server and you'll automatically get connected to the FreeBSD-installation! This is of course a security issue, but you can deal with this in several ways, e.g. restrict which host that are able to connect to VNC. No matter what I highly recommend to disable VNC-access after the installation is done - at that time you can just connect with ssh to the domU. This is simply done by deleting (vnc-listen '0.0.0.0') in /etc/xen/xend-config.sxp.
When you have installed FreeBSD (or whatever system you've just installed), please remember to modify the config-file in order to unmount the iso-file and boot from the disk, i.e. on the parameters:
disk = ['phy:/dev/lvmstore/lv2,hda,w','phy:/dev/sda7,hdb,w'] boot = 'c'

(1 votes, average: 4.00 out of 5)