Andrea Casarin

Andrea Casarin

Published on: 1/14/2023, 1:14:04 PM - Reading time: 1 minute

Databases on NFS shares

Last week I was trying to deploy a MariaDB container to my home lab which has to use TrueNAS share as persistent storage. I'm currenly using NFS storage for my homelab docker cluster. I wasn't working right, due to some Lock errors.

So I found out that running a Sqlite db or really anything which requires files lock over NFS keep is really buggy when managed remotely via rpc.statd and rpc.lockd.

You can however opt for local locks, if the share is mount only by one user/server.

To enable local locks in TrueNAS, set a sysctl tunable in System->Tunables of vfs.nfsd.enable_locallocks=1. Then add local_lock=all to your NFS mount options.

That leads to an NFS share that can only be mounted by a single client safely, however that's usually the case with a database share.