Skip to content

ZFS FAQ

Lucas Holt edited this page Jul 12, 2023 · 14 revisions

How do I remount a filesystem in read/write mode? zfs set readonly=off zroot

How do I mount all filesystems? zfs mount -a

Recovering EFI boot partition

If your boot loader gets corrupted, you can boot off of MidnightBSD install media for your release and do the following from the live cd functionality.

(replace nvd0 with your disk. EFI should be on the first partition)

(more destructive, can wipe custom configurations here) gpart bootcode -p /boot/boot1.efifat -i 1 nvd0

In some cases, you can simply copy the loader.efi (after mounting it) mount_msdosfs /dev/nvd0p1 /mnt cp /boot/loader.efi /mnt/efi/boot/BOOTx64.efi

NFS

Setup NFS shares

zfs set sharenfs="-maproot=0 -network 192.168.0.0/24" zroot/my/path

service mountd restart

Verify configuration

zfs get sharenfs zroot/my/path

Note that any entries from sharenfs commands get placed in /etc/zfs/exports

Setting up multiple subnets

note the new lines INSIDE the quotes

zfs set sharenfs="-maproot=root -network 10.0.0.0/24 
> /path/to/mountpoint -maproot=root -network 192.168.0.0/24 
> /path/to/mountpoint -maproot=root -network 172.16.0.0/24" pool0/space

Tuning for PostgreSQL

many guides recommend 8K or 16K for recordsize with postgresql. There are some benchmarks showing better results with 16K, but most favor 8k as that aligns with default block sizes in PG.

zfs set recordsize=8K tank/usr/local/pgsql

zfs set primarycache=metadata  tank/usr/local/pgsql

zfs set logbias=throughput  tank/usr/local/pgsql

zfs set redundant_metadata=most  tank/usr/local/pgsql

Tuning for large files

Setting a larger recordsize can be quite beneficial for large files such as videos.

zfs set recordsize=1M tank/media/video