Kernel options for static ZFS?

I've been looking several places (man pages, handbook, forums, mailing lists, etc.) for what options (or devices) are needed in the kernel configuration to statically compile in ZFS support. Currently I'm on 9.0-RELEASE, and loading ZFS at boot time (root is ZFS), and I see two modules are loaded, zfs.ko and opensolaris.ko.

Is it possible to compile these in so I don't need to load the modules? And if so, what do I need in my kernel config?

Edit: Seems a kldstat -v gives some clues to what might be needed.
Code:
zfs.ko (/boot/kernel/zfs.ko)
        Contains modules:
                Id Name
                 3 zfsctrl
                 4 zfs
                 6 zfs_vdev
                 5 zfs_zvol
opensolaris.ko (/boot/kernel/opensolaris.ko)
        Contains modules:
                Id Name
                 1 opensolaris
So, do I need device entries for all of these?
 
Last edited by a moderator:
I believe it's licensing-based, but don't know for sure. For a definitive answer, you may need to post the question on the freebsd-fs@ mailing list.
 
For anyone looking at this in 2018, the answer is still no. It is due to licensing reasons, so harass Oracle. The only operating systems currently in production that have native ZFS built-in to the kernel are those based on Solaris. (OS/Net, Ilumos, etc)
 
No, it is not possible to compile ZFS into the kernel.

For anyone looking at this in 2018, the answer is still no.

Beg You pardon?
ZFS is normally compiled into the kernel. Only if one wants to get dtrace and drm2 and linux etc. also compiled in, then one has to twiddle with /usr/src/sys/conf/ a bit. (I don't know if this is "allowed". I probably didn't ask.)
 
Beg You pardon?
ZFS is normally compiled into the kernel.
It's not. This is also why you need to edit /boot/loader.conf in order to make things work:
Code:
zfs_load="YES"
...and why kernel modules such as zfs.ko and opensolaris.ko exist in GENERIC.

Only if one wants to get dtrace and drm2 and linux etc. also compiled in, then one has to twiddle with /usr/src/sys/conf/ a bit.
Uhm, no?

Not every feature which is provided as a kernel module can be build statically into the kernel. In fact, most features cannot and fully rely on kernel modules, eventually there really isn't much difference between a kernel module or an embedded feature on FreeBSD.

Also note that /usr/src/sys/conf isn't the right location to configure your kernel, config(8) isn't really used anymore to build / configure. Instead use /usr/src/sys/<arch>/conf as also explained in Chapter 8.4 of the FreeBSD handbook.
 
It's not. This is also why you need to edit /boot/loader.conf in order to make things work:
Code:
zfs_load="YES"
...and why kernel modules such as zfs.ko and opensolaris.ko exist in GENERIC.

Well, then:

Code:
root # zpool list
NAME   SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
bm     804G   564G   240G        -         -    34%    70%  1.00x  ONLINE  -
gr    50.5G  19.5G  31.0G        -         -    36%    38%  1.00x  ONLINE  -
root # kldstat
Id Refs Address    Size     Name
1    1 0x80400000 d4297c   kernel
root # grep zfs /boot/loader.conf
vfs.zfs.trim.enabled="0"
vfs.zfs.arc_max="800M"
vfs.zfs.arc_min="200M"
vfs.zfs.prefetch_disable="1"
root # uname -r
11.2-RELEASE
root #

Uhm, no?

Not every feature which is provided as a kernel module can be build statically into the kernel. In fact, most features cannot and fully rely on kernel modules, eventually there really isn't much difference between a kernel module or an embedded feature on FreeBSD.

Well, there may be some difference as soon as you try to backtrace a kernel crash and it doesn't find the proper files...

And yes, this is not a GENERIC kernel; its a custom build.
 
And yes, this is not a GENERIC kernel; its a custom build.
As such my point stands; ZFS isn't normally build into the kernel.

In fact most options within FreeBSD are usually provided through kernel modules. One of the reasons being that there eventually isn't much difference between linking in a module or loading it afterwards. If you run kldstat -v you'll notice that it mentions "Contains modules:" and eventually lists zfs again. It never stopped being a module.
 
As such my point stands; ZFS isn't normally build into the kernel.

In fact most options within FreeBSD are usually provided through kernel modules. One of the reasons being that there eventually isn't much difference between linking in a module or loading it afterwards. If you run kldstat -v you'll notice that it mentions "Contains modules:" and eventually lists zfs again. It never stopped being a module.

Sure it does, it reports zfs as "contained in the kernel" - which is exactly the point of the exercise: there are no modules loaded via kldload.
I just checked my logs: i have this in the kernel-configs since Rel .11.1:
options ZFS
And this seems to work out of the box.

I also have these in the kernel-config:
device dtrace
device dtraceall
device drm2
device i915drm

But these probably don't work without modifying some files.
 
At some time I had to debug some issues, and I found that the debugger would not always find the source files from loaded modules.
Instead of searching the flaw in the debugger, I decided to simply not have loaded modules.
 
I'm intrigued. What are the reasons behind wanting to compile ZFS into the kernel?
So as not to, when switching kernels at boot-time, worry about compatibility of modules. That is, your kernel may be from /boot/kernel.old, but the modules will still be from /boot/kernel -- and not necessarily compatible.

Using modules makes sense, when they are for a rarely-used feature -- such as, mounting a FAT-formatted storage. For everything, that you use all the time -- such as, usually, ZFS -- you'll want to have it in kernel...
 
So as not to, when switching kernels at boot-time, worry about compatibility of modules. That is, your kernel may be from /boot/kernel.old, but the modules will still be from /boot/kernel -- and not necessarily compatible.

Using modules makes sense, when they are for a rarely-used feature -- such as, mounting a FAT-formatted storage. For everything, that you use all the time -- such as, usually, ZFS -- you'll want to have it in kernel...
This seems to be a very old thread, but now with 13.0 I can see that there is a short note in /usr/src/sys/amd64/conf/NOTES
Code:
#####################################################################
# ZFS support

# NB: This depends on crypto, cryptodev and ZSTDIO
options         ZFS

#####################################################################

I have not tried this yet, but hope it works...
 
I'm intrigued. What are the reasons behind wanting to compile ZFS into the kernel?
The main reason would be improving security by being able to totally disable kernel modules. To do so, ZFS needs to be compiled into the kernel.

Disabling module loading or even removing kernel modules altogether like OpenBSD did removes one major attack vector for security breaches.
 
Back
Top