# 10.0-BETA3: how to build kernel with ZFS?



## Max_nl (Nov 7, 2013)

What does one have to do to get a kernel with zfs.ko build these days?

I am trying to build my own kernel, as the NKPT value of the stock kernel is too low to be suitable for PXE network booting a mfsroot ramdisk image.
However I noticed that when I build my own kernel, it does not have ZFS support.

- based on another forum post I added WITH_ZFS=YES to /etc/make.conf and did  buildkernel/installkernel again, but no difference. There is no zfs.ko and calling the `zfs` command line tools results in internal error: failed to initialize ZFS library
- my kernel configuration is just a copy of GENERIC with options NKPT=100 added.


----------



## wblock@ (Nov 7, 2013)

make.conf is the wrong place, that would normally be /etc/src.conf.  Check the contents of that file first, building of ZFS may be disabled in there.


----------



## SirDice (Nov 7, 2013)

As far as I know you cannot build ZFS into the kernel yet. And src.conf only supports WITHOUT_ZFS. A normal build should produce the correct modules.


----------



## kpa (Nov 7, 2013)

It's certainly there on my system, GENERIC kernel and nothing in make.conf or src.conf.

```
freebsd10 ~ % uname -a
FreeBSD freebsd10.rdnzl.info 10.0-BETA3 FreeBSD 10.0-BETA3 #0 r257735: Wed Nov  6 17:31:33 EET 2013     toor@freebsd10.rdnzl.info:/usr/obj/usr/src/sys/GENERIC  i386
freebsd10 ~ % ls -l /boot/kernel/zfs.ko
-r-xr-xr-x  1 root  wheel  1737081 Nov  6 19:37 /boot/kernel/zfs.ko
freebsd10 ~ %
```


----------



## Max_nl (Nov 7, 2013)

SirDice said:
			
		

> As far as I know you cannot build ZFS into the kernel yet. And src.conf only supports WITHOUT_ZFS. A normal build should produce the correct modules.



Do not have a /etc/src.conf, so did not exclude it there.

It does not produce the correct modules with FreeBSD 10.0 beta 3 when I do a build like this:


```
make buildkernel KERNCONF=MYKERNCONF
make installkernel KERNCONF=MYKERNCONF
```


```
# find /boot |grep zfs.ko
#
```

Stock kernel/installation CD does have a zfs.ko.


```
# find /mnt/cd |grep zfs.ko
/mnt/cd/boot/kernel/zfs.ko
```


----------



## ShelLuser (Nov 7, 2013)

Since ZFS support can only be provided using a kernel module (at the time of writing obviously) you should check how you've configured your kernel modules to be build. Check make.conf and look for any module build parameters.

Something in the likes of MODULES_OVERRIDE or maybe you even have something like NO_MODULES or WITHOUT_MODULES in place.

If so then it could explain something, see make.conf(5) for more details on this.


----------



## zennybsd (Nov 11, 2013)

Max_nl said:
			
		

> What does one have to do to get a kernel with zfs.ko build these days?
> 
> I am trying to build my own kernel, as the NKPT value of the stock kernel is too low to be suitable for PXE network booting a mfsroot ramdisk image.
> However I noticed that when I build my own kernel, it does not have ZFS support.
> ...



What I usually do is:

1) pull source from SVN and update it
2) create a new kernel configuration file (say MYCUSTOMKERNEL) in related arch like /usr/src/sys/amd64/conf/MYCUSTOMKERNEL for amd64
3) In the above file, start with:


```
include GENERIC
ident MYCUSTOMKERNEL

options NKPT=100
```

and add whateeer you need to include in the kernel.

4) Compile:

```
#make -s -j8 buildworld; make -s -j8 buildkernel KERNCONF=MYCUSTOMKERNEL
#make installkernel KERNCONF=MYCUSTOMKERNEL
#reboot
```


----------

