Thursday, June 30, 2011

Exporting ZFS filesystem over NFS

First you need to install nfs-kernel-server. You also need a later kernel: 2.6.35 or better

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=,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${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=,no_subtree_check,async,no_root_squash zfs/backup
zfs set sharenfs=,no_subtree_check,async,no_root_squash zfs/backup

The host writing the backup is 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.

Friday, June 03, 2011

Minimal graphical Ubuntu install

# Minimal Ubuntu Graphical install
sudo apt-get install gnome-panel gdm gnome-terminal network-manager-gnome \
network-manager gnome-power-manager chromium-browser \
ubuntu-artwork libaudiofile0 flashplugin-installer