THIS PAGE NEEDS AN UPDATE BECAUSE the fs ramdisk-zfsroot.fs in boot.cfg(5) obviates the need for a custom kernel module with the ramdisk embedded

NetBSD-9 gained much improved ZFS support. However, one feature it's still missing is the ability to have your system root on ZFS. For that, we need to teach our boot loader about ZFS,xi but until then we can work around this limitation by using a FFS boot partition and a ZFS root ramdisk. You'll also need to use NetBSD-9.99.48 or newer.

The idea is simple - the boot loader loads the NetBSD kernel and the required modules (solaris and zfs) from FFS and the ZFS root ramdisk. The ramdisk then imports the ZFS root pool called rpool, mounts rpool/ROOT to /altroot and finally instructs the kernel to chroot to it. Because the initial root is on a ramdisk, we can then load the boot partition from inside the ZFS chroot to maintain it; for example to update the kernel and modules.


The ramdisk does make some assumptions as there is no way to pass variables from boot.cfg:

Once inside the chroot the kernel will load modules from the ZFS filesystem because there is a symlink to it from the ramdisk. The same is true for any firmware needed after boot.

Generic setup

Until the NetBSD installer can be updated, here are the manual steps from fresh:

ZFS Setup

So far, so good. Now we need to make the needed adjustments to change root:

And done! You can now reboot and enjoy your root on ZFS and all the benefits it brings. When updating the kernel, remember to mount /altroot and update it there as well as the modules.

Future work

All these steps could be done in the installer. This is probably an easier task than adding ZFS support to the bootloader. But don't let that stop you if you are stuck for something to do!