Install zfs native (or zfs-fuse):
sudo add-apt-repository ppa:dajhorn/zfs sudo apt-get update sudo apt-get install ubuntu-zfs
By default NFS sharing is off. To export a zfs filesystem, say zfs/home:
#Setup shared FS zfs create -o compression=on -o atime=off -o sharesmb=on zfs/home #export RO zfs set sharenfs=ro zfs/home #stop exporting. Also for next command to take effect zfs set sharenfs=off zfs/home # export RW, fsid needs to be unique per filesystem zfs set \ sharenfs=10.1.1.0/24:rw,fsid=100,no_subtree_check,async,no_root_squash zfs/home # add this to /etc/rc.local zfs share -a #To mount from OSX use the following command. -P option is for secure (<1024) ports mount_nfs -P 10.1.1.1:/zfs/home/${USER} /mnt/home
Later invocations override earlier, so to export RW to only one host and RO to others:
zfs set sharenfs=off zfs/backup zfs set sharenfs=10.0.0.0/8:ro,no_subtree_check,async,no_root_squash zfs/backup zfs set sharenfs=10.1.1.1:rw,no_subtree_check,async,no_root_squash zfs/backup
The host writing the backup is 10.1.1.1 and will get read/write access. The rest will get read only access.
Note: Setting the mountpoint property of a ZFS dataset to anything other than the default pool/dataset will cause it to be exported with all_squash. Do not change the mountpoint if you want to NFS share a dataset
If you are getting a lot of stale NFS handles, the IO requests are timing out before they can be serviced due to heavy IO load. Mount your NFS shares using these options (example fstab entry):
server:/zfs/dataset /mnt nfs defaults,timeo=20,retrans=5,rsize=8192,wsize=8192,intr 0 0
The timeo to 2 seconds from default of 0.7 seconds is the most important attribute.
2 comments:
Hi,
I have create a pool on my fileserver mounted under /storage with a zfs folder called private
If I follow your guide and enter:
sudo zfs set sharenfs=10.0.0.0/24:rw,no_subtree_check,async,no_root_squash storage/private
I get this error:
cannot set property for 'storage/private': 'sharenfs' cannot be set to invalid options
I can share /storage/private if I enter:
sudo zfs set sharenfs=on storage/private
and I can mount this share on a remote ubuntu machine but I lose this share when the fileserver is rebooted.
Any idea how I can get the share to survive a reboot?
without the 10.0.0.0/24 your share is probably exported read only. Try 10.0.0.0/8.
To survive reboots, you need to add the following line to /etc/rc.local
zfs share -a
Post a Comment