Icon

Partager Envoyer

(Document)

How to share/export/mount a ZFS filesystem through NFS

These instructions have been tested on a FreeBSD 13.2 Server (OpenZFS 2.1.9) with ARCH Linux and FreeBSD clients.

Configure and enable NFS

Server-side:
We use the following configuration in '/etc/rc.conf':

    #################################### File Sharing (nfs) ######################################
    rpcbind_enable="YES"
    rpc_lockd_enable="YES"
    rpc_statd_enable="YES"
    mountd_enable="YES"
    mountd_flags="-r"
    nfs_server_enable="YES"
    nfs_server_flags="-u -t -n 8"   # Flags to nfsd (if enabled)
    nfs_client_enable="YES"


Note that the required services should always be (re)started in this order, with rpcbind coming first:

    service rpcbind restart
    service mountd restart
    service nfsd restart

The nfs_client service is only required if you plan to mount nfs shares on the server.

Export a filesystem

1) Log into ZFSManager, go to 'Access' » 'NFS' » 'New share', then select 'Share filesystem' (this can be any ZFS filesystem: we'll use 'LVL2' in our example) and set 'Access profile' to 'protected', also check 'Easy permissions'
2) Under 'Access control', add IP: 10.1.1.0, Security Mask: /24 to enable sharing on 10.1.1.0/24 network
3) Under 'Advanced', enable 'mapall'='root' and enable 'network' (this will use the entry defined under 'Access control'

Note that you'll have to execute the corresponding 'zfs set' command each time you modify an option.

In the end, this is the same as executing (based on the above options):

    zfs set sharenfs='-mapall=root,-network=10.1.1.0/24' LVL2

Mount the exported filesystem

Client-side, execute:

    mkdir /test (to create the mount point)

You may check that nfs is enabled and list the exports with:

    sudo rpcinfo -p 10.1.1.20
    sudo showmount -e 10.1.1.20

The latter will return something like:

    Export list for 10.1.1.20:
    /media/lvl2 10.1.1.0

Mount the exported /media/lvl2 share with:

    sudo mount -v -t nfs 10.1.1.20:/media/lvl2 /test

(This should automatically select the right protocol version)

Restart the service with:
    
    sudo systemctl restart nfs-mountd

Performance

NFS uses sync writes: it will benefit from the use of a SSD as Separate Intent Log Device:

    OpenZFS also includes something called the ZFS Intent Log (ZIL).
    The ZIL can be set up on a dedicated disk called a Separate Intent Log (SLOG) similar to the L2ARC,
    but it is not simply a performance boosting technology.

    (Source: https://www.truenas.com/blog/o-slog-not-slog-best-configure-zfs-intent-log/)

Server-side, you may check how well NFS performs with:

    nfsstat -d

 


Ce document a été publié le 2021-03-09 01:39:00. (Dernière mise à jour : 2024-06-10 08:39:11.)




This website uses 'cookies' to enhance user experience and provide authentification. You may change which cookies are set at any time by clicking on more info. Accept
x