Skip to content

Instantly share code, notes, and snippets.

@NickWoodhams
Created October 16, 2013 07:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NickWoodhams/7003834 to your computer and use it in GitHub Desktop.
Save NickWoodhams/7003834 to your computer and use it in GitHub Desktop.
Find the best NFS rsize and wsize for performance
EXPORT="yourdomain.com:/home/shared/folder"
MNTDIR="/local/folder"
TESTFILE="remote-file.test"
NFSPROTO="udp"
if [[ -n "$1" ]]; then
NFSPROTO="tcp"
fi
echo "Testing transfer speed of $NFSPROTO on file $EXPORT/$TESTFILE"
echo
for rsize in 2048 4096 8192 16384 32768 65536 131072 262144
do
if mount | grep $MNTDIR > /dev/null; then
sudo umount $MNTDIR
fi
sudo mount -t nfs -o rsize=$rsize,$NFSPROTO,cto,noatime,intr,nfsvers=3 $EXPORT $MNTDIR
mntedrsize=$(cat /proc/mounts | grep $MNTDIR | grep -oE "rsize=[0-9]{4,6}" | grep -oE "[0-9]{4,6}")
echo $MNTDIR mounted @ rsize \($((mntedrsize/1024))K\), requested rsize \($((rsize/1024))K\)
sudo dd if=$MNTDIR/$TESTFILE of=/dev/null | grep "copied"
echo
done
sudo umount $MNTDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment