Building FreeNAS with Xen PVHVM support

Ok, this took a long time to build, but it works, and the end result was ISO and img files for both i386 and x64.

Update: By popular request, I’ve uploaded the iso for those unable/unwilling to build it.. see this latest post for the link to the iso.

For the more intrepid who want to do this themselves, read on.. 🙂

I haven’t tested the i386 build as I’m not really interested in 32-bit, given I’m running FreeNAS and want gobs of memory for that VM, but the 64-bit version installed just fine, and I’e got it running with a Dell Perc H310 flashed with LSI HBA firmware.

First off, you need to go fetch a copy of FreeBSD 9.2 to create the build environment.

If you’re doing this in a VM like I was, you want to give it a lot of cores, 4GB of RAM, and at least 15GB of free disk space to build in.  Yes, building FreeNAS isn’t trivial – its a loooong build process.

The good news is that starting the build process is pretty straightforward.  Once you’ve got FreeBSD installed and running to your satisfaction, then go ahead and kick off the FreeNAS build process like so:

Start by installing git and the crdtools package (for building the ISO) – a fair few dependencies for this, but just accept the defaults as it goes and you’ll be right.

cd /usr/ports/devel/git && make depends install
cd /usr/ports/sysutils/cdrtools  && make depends install
cd /usr/ports/archivers/pxz && make depends install
mkdir /home
cd /home

Then its time to check out the 9.2 release:

git clone -b 9.2.0-RELEASE git://github.com/freenas/freenas.git
cd freenas
make git-external

Ok, we’re all set to run the build, except for.. adding the PVHVM support. For this, I pinched the lines from the FreeBSD XENHVM kernel conf. TO make it easy for you, here they are:

vi nanobsd/FREENAS.amd64

Add these lines at the end:

options         NO_ADAPTIVE_MUTEXES
options         NO_ADAPTIVE_RWLOCKS
options         NO_ADAPTIVE_SX

# Xen HVM support
options         XENHVM
device          xenpci

Do the same for the i386 build process too if you want:

vi nanobsd/FREENAS.i386

And finally, lets edit the Makefile to change the version number, so that the filename produced clearly indicates that this is a Xen-supporting version of the build

vi Makefile

At the top it sets the variable VERSION – change it to something like this:

VERSION?=9.2.0-RELEASE-xen

Then save the file, and its time to:  (drum roll!)

make release

Now just walk away and find something to do for the hours this will take 🙂  At the end of the process, you should be able to:

cd /home/freenas/release_stage/x64
ls
FreeNAS-9.2.0-RELEASE-xen-x64.GUI_Upgrade.txz
FreeNAS-9.2.0-RELEASE-xen-x64.GUI_Upgrade.txz.sha256.txt
FreeNAS-9.2.0-RELEASE-xen-x64.img.xz
FreeNAS-9.2.0-RELEASE-xen-x64.img.xz.sha256.txt
FreeNAS-9.2.0-RELEASE-xen-x64.iso
FreeNAS-9.2.0-RELEASE-xen-x64.iso.sha256.txt

From here, you can go install FreeNAS directly into a PVHVM virtual machine.  Here’s the conf file I used to install:

name = 'freenas'
builder = 'hvm'
maxmem = 8192
memory = 8192
vcpus=2
acpi=1
apic=1
vif = [ 'bridge=xenbr0, mac=00:aa:0a:14:01:99' ]
disk = [ 'phy:/dev/vg_ssd/vm_freenas,xvda,w',
 'file:/mnt/isos/bsd/FreeNAS-9.2.0-RELEASE-xen-x64.iso,hdb:cdrom,r' ]
# Boot from the cdrom device
boot='d'
vnc=1
vncunused=0
vnclisten = '0.0.0.0'
vncdisplay=3
vncconsole=1
serial='pty'
on_poweroff = 'destroy'
on_reboot = 'restart'
on_crash = 'destroy'
#pci = ['01:00.0']

 

Note that you really want to use the serial console – so after the first boot, use the web admin pages to enable the serial console, and set a baud rate of 115200.  After that, you can use the default xen console without having to use a vnc viewer.

Lastly – if you’re passing in a PCIe device such as an LSI HBA, go check out my next post on making an LSI HBA adapter work with PCI passthrough and Xen using the xen_pciback modules. Here’s the post about getting the LSI HBA card working.

I’m also investigating adding the iso and img files directly to this site for download – but for now the instructions above will get you the same result, just slower 🙂

Ooroo!

9 thoughts on “Building FreeNAS with Xen PVHVM support

  1. Great article my friend, just a wee glitch… you need to run make checkout before make release 🙂 Thanks, helped a lot!

  2. Pingback: FreeNAS 9.2.1.5 with Xen PVHVM support | My Wired House

  3. Pingback: freeNAS 9.2 ISO with Xen PVHVM support | My Wired House

    • Hi, your error looks like a problem with the ports tree for FreeBSD 9.2.

      I’ll upload the iso file tonight (its early morning here) – its only 165 megs, and I’ll make a post about it here once its up.

  4. Pingback: FreeNAS LSI Host Bus Adapter setup | My Wired House

Leave a Reply

Your email address will not be published. Required fields are marked *