ZFS Datasets for User Home Directories

I have a mirrored ZFS pool named internal:

Code:
# zpool list
NAME       SIZE  ALLOC   FREE  CKPOINT  EXPANDSZ   FRAG    CAP  DEDUP  HEALTH  ALTROOT
internal   464G  55.5G   408G        -         -     7%    11%  1.00x  ONLINE  -

On it I have the following datasets

Code:
# zfs list
NAME             USED  AVAIL  REFER  MOUNTPOINT
internal        55.5G   394G    23K  /mnt/internal
internal/ftp    53.4G  26.6G  53.4G  /var/ftp
internal/home     34K   120G    34K  /usr/home
internal/mysql  2.03G  58.0G  2.03G  /var/db/mysql
internal/pgsql   152M  19.9G   152M  /var/db/pgsql

As seen above /usr/home is it's own data set internal/home that I created using:

Code:
zfs create -o compression=lz4 -o mountpoint=/usr/home -o casesensitivity=insensitive -o quota=120G internal/home

I would like to have each user's home directory be it's own dataset. The FreeBSD handbook mentions this briefly but doesn't give many details under 20.4.8. Dataset, User, and Group Quotas. It says:

Before adding a user to the system, make sure to create their home dataset first and set the mountpoint to /home/bob.

I can not find instructions on the correct way of doing it, so I am guessing that it wants me to do something like:

Code:
zfs create -o compression=lz4 -o mountpoint=/usr/home/bob -o casesensitivity=insensitive internal/home/bob

Is this correct?
Is the mountpoint option redundant?
 
Is the mountpoint option redundant?
Yes. When the mountpoint is not specified, it is by default relative to the mountpoint inherited from it's parent dataset(s). So creating a dataset internal/home/bob as a child of internal/home (which has /usr/home set as it's mountpoint) becomes /usr/home/bob.
 
If internal/home already has the mountpoint /usr/home you don't need (want) to set the mountpoint for every single child dataset. mountpoints (as many other properties, like compression) are inherited from the parent dataset and much easier to manage that way. So set your desired defaults on `internal/home` and don't set any on the users dataset unless you really want to deviate from the defaults (use zfs inherit to reset properties).
So a simple zfs create internal/home/username is sufficient for every new user.

If this is a system with many users, I'd highly recommend setting quotas (see quota, refquota and user/groupquota in zfs(8) ).
Also, if your users don't have anything like databases or VM-images in their home directories, I'd stay with the new default zstd compression as it is more efficient. The (minor) performance advantages of LZ4 are only meaningful for I/O-heavy operations.
 
Back
Top