Uncategorized

Automatically Mount to NFS Server


This is a simple bash script to automatically install nfs-common so you can mount to a remote NFS server. Insert your own variables on the top of the script, and run it as root. This script will install the NFS mount to the /etc/fstab file so your NFS server will mount on restart.

1
2
3
4
5
6
7
8
9
10
11
12
13
#!/bin/sh
 
# local mount directory
MOUNTDIR=/nfsmount
# NFS server
NFSSERVER=nfs.server.com
# NFS server directory
NFSDIR=/nfsmount
 
apt-get install nfs-common -y
mount $NFSSERVER:$NFSDIR $MOUNTDIR
 
echo "$NFSSERVER:$NFSDIR    $MOUNTDIR   nfs auto,noatime,nolock,bg,nfsvers=4,intr,tcp,actimeo=1800 0 0" >> /etc/fstab

Be sure to chmod +x nfsmount.sh to make it executable. You can custom your NFS mount configs by editing line #13.


View Comments
There are currently no comments.