You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lucas Holt edited this page Nov 3, 2025
·
19 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
What can cause some filesystems not to mount at startup?
There are a few possibilities.
canmount=off property is set on the filesystem
The parent directory has an empty folder in it. e.g. tank/foo/bar where tank/foo/ has a folder called bar in it when tank/foo is mouunted. This would block tank/foo/bar to mount.
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)
Effectively, you need to replicate the partition table using gpart backup / restore, add the zfs partition to the pool, and set it up as bootable either with the mnbsd-boot partition or the efi partition (assumes gpt) as necessary.
MidnightBSD partition types are mnbsd-boot and mnbsd-zfs on GPT.
Tuning
i386 Tuning
Typically, you need to increase vm.kmem_size_max and vm.kmem_size (with vm.kmem_size_max >= vm.kmem_size) to avoid kernel panics. If you need to extend them beyond 512M, you need to recompile your kernel with increased KVA_PAGES in kernel config for vm.kmem_size beyond 1 GB:
options KVA_PAGES=512
By default, the kernel receives 1 GB of the 4 GB of address space available on the i386 architecture, and this is used for all of the kernel address space needs, not just the kmem map. By increasing KVA_PAGES, you can allocate a larger proportion of the 4 GB address space to the kernel (2 GB in the above example), allowing more room to increase vm.kmem_size. The trade-off is that user applications have less address space, and some programs may no longer run. If you change KVA_PAGES and the system reboots (no panic) after running for a while, this may be because the address space for userland applications is too small.
No tuning should be necessary when the system has more than 2GB of RAM.
General ARC advice
The value for vfs.zfs.arc_max needs to be smaller than the value for vm.kmem_size.
To improve the random read performance, a separate L2ARC device can be used (zpool add cache ). A cheap solution is to add a USB memory stick (see http://www.leidinger.net/blog/2010/02/10/making-zfs-faster/). Be sure to use a high-quality drive. The high-performance solution is to add an SSD, preferably an NVMe drive. Optane is particularly useful for this workload due to its high write endurance and performance characteristics. L2ARC devices should be faster and/or have less latency than the storage pool.
By default, the L2ARC does not attempt to cache prefetched or streaming workloads. Most data of this type is sequential. The combined throughput of your pool disks exceeds the throughput of the L2ARC devices. If you believe otherwise (number of L2ARC devices X their max throughput > number of pool disks X their max throughput), then this can be changed with the following sysctl:
vfs.zfs.l2arc_noprefetch
The default value of 1 does not allow caching of streaming and/or sequential workloads and will not read from L2ARC when prefetching blocks. Switching it to 0 will allow prefetched/streaming reads to be cached. This may significantly improve performance if you store many small files in a large directory hierarchy (since many metadata blocks are read via the prefetcher and would ordinarily always be read from pool disks).
Tuning for PostgreSQL
Many guides recommend 8K or 16K for record size with PostgreSQL. Some benchmarks show 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 benefit large files such as videos.
zfs set recordsize=1M tank/media/video
Tuning for Virtual Machine storage
For Virtual machines, it's important to write data reliably to prevent damage during power off or panics. (e.g. with bhyve VMs) Set the sync property on the file system in question.
zfs set sync=always tank/filesystem
A zil slog will not help much with this configuration. Further, it's essential to make sure that there is a lot of free space in your pool to improve write performance. You're better off with a much larger, slow disk than a fast, small one for writing large files like VMs.
Additionally, using primarycache=metadata property can help with performance, but only if the zfs blocksize matches what the VM is using. Otherwise, there can be a performance penalty due to alignment issues and writes.
It's usually a bad idea to use deduplication unless you have a lot of RAM or a very small file system. The minimum is usually around 5GB of RAM per 1TB of disk.