back to the beginning

FreeBSD 12.0 ZFS

Last updated: 2019-02-24

zfs filesystem

I love using this filesystem. I don't want to use anything else.

I suggest you do a lot of reading about it and consider the notes here as reference.

My set up is not entirely standard and came with some trial and error. Initially I installed FreeBSD on its own drive and used the zfs install. Everything went well but I could only mount the zfs drive in Linux as read-only. If you want to be able to read and write a zfs drive from both FreeBSD and Linux (NOT AT THE SAME TIME!) then you need to do some homework.

With zfs, neither FreeBSD or Linux out of the box use the same features when creating a pool. Without using the features that are exactly compatible, you will not be able to read and write to the drive from each OS. I dual boot between Linux and FreeBSD, each on their own drives, and have an additional drive for data.

In order to have the OS's be able to read zfs I needed to create the pools (I have three) with the right options.

This can be done either from FreeBSD or from Linux but you will have to turn off whatever would be on by default depending on which OS you use to create the pool.

Note the difference between -o and -O.

As of Ubuntu 18.10 and FreeBSD 12.0, the flags for compatibility are as follows for each OS in order to create the pool:

(Note: I have added additional settings for my pools.)

To create a compatible pool from FreeBSD (I highlighted the important features to disable--how you disable them in FreeBSD I don't recall; the command seems to choke on the lower case -o so that might be an issue (i.e. use -O on error); the man page says -o but the command errors unless -O (so bug?)):

zpool create -o ashift=12 \
-o device_removal=off -o obsolete_counts=off -o spacemap_v2=off -o zpool_checkpoint=off \
-O atime=off -O canmount=off -O compression=lz4 \
-O normalization=formD -O checksum=sha256 -O xattr=sa \
-O mountpoint=/zroot zroot /dev/XXX

To create a compatible pool from Linux: (This is the create command I used FROM LINUX to create the pools. I found it less complex than creating a custom pool during FreeBSD install. To do that, drop to a shell, create the pool (see above), mount it, etc.):

sudo zpool create -o ashift=12 \
-o feature@userobj_accounting=disabled -o feature@large_dnode=disabled \
-O atime=off -O canmount=off -O compression=lz4 \
-O normalization=formD -O checksum=sha256 -O xattr=sa \
-O mountpoint=/zdatapool datapool /dev/sda1

Note: sdX uses the whole disk; use sdXY for a partition.

In the end, my three drives look like this:

In my datapool I have several filesystems, most notable are these two:
datapool/linuxhome
datapool/freebsdhome

Each OS sees it's own root partition and all three zfs partitions.

There is a link from each root to the appropriate /home partition for the OS (I do not share a single /home/darren parition for both Linux and FreeBSD).

I have a script to back up both /home paritions (and other data) to the two other zfs partitions.


General zfs filesystem notes

Create a new pool without regard for Linux

This can be used on a whole drive or a partition.

zpool create [-m legacy] -o compression=lz4 -o atime=off -o checksum=sha256 POOLNAME DRIVE/dev/adaXpX

Create a new filesystem in a pool. These inherit any options on their higher 'mountpoint'. If you are not changing anything, the simply:

zfs create POOLNAME/NAME
zfs create -o mountpoint=/XXX POOLNAME/NAME

back to the beginning

Something need fixing? Contact me: