On Redhat systems
Create the configuration,
vi /etc/exports
for example,
/path/to *(ro,no_root_squash)
Apply,
service nfs start
Defenitely if you like,
chkconfig portmap on
chkconfig nfs on
################################################################################
HowTo configure NFS
1. Introduction
The Network File System is certainly one of the most widely used network services. Network file system (NFS) is based on the Remote procedure call. It allows the client to automount and therefore, transparently access the remote file systems on the network.2. Scenario
In this scenario we are going to export the file system from the linuxconfig.org (IP address 10.1.1.200) host and mount it on linuxconfig.local(IP address 10.1.1.100).3. Prerequisites
At this point, we assume that the NFS service daemon is already installed on your system, including portmap daemon on which NFS depends on. Moreover, your system needs to support the NFS file system.$ cat /proc/filesystems
NFS daemon should be listening on both standard ports 2049 and portmap on port 111.
Another way to check if NFS is functioning, is to use the rpcinfo command.
# rpcinfo -p
You should get a response/output similar to one below:
4. Server export file
All NFS server exports need to be defined in /etc/exports file.4.1. Most common exports options
Here are a couple of the most common export techniques and options:/home/nfs/ 10.1.1.100(rw,sync) | export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, and synchronized mode |
/home/nfs/ 10.1.1.0/24(ro,sync) | export /home/nfs directory for network 10.1.1.0 netmask 255.255.255.0 with read only permissions and synchronized mode |
/home/nfs/ 10.1.1.100(rw,sync) 10.1.1.10(ro,sync) | export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, synchronized mode, and also export /home/nfs directory for hosts with IP 10.1.1.10 with read only permissions and synchronized mode |
/home/nfs/ 10.1.1.100(rw,sync,no_root_squash) | export /home/nfs directory for host with IP 10.1.1.100 with read, write permissions, synchronized mode and the remote root user will not be treated as a root but as a default nfs user. |
/home/nfs/ *(ro,sync) | export /home/nfs directory for any host with a read only permission and synchronized mode |
/home/nfs/ *.linuxconfig.org(ro,sync) | export /home/nfs directory for any host within linuxconfig.org domain with a read only permission and synchronized mode |
/home/nfs/ foobar(rw,sync) | export /home/nfs directory for hostname foobar with read, write permissions and synchronized mode |
4.2. Edit exports file
Open up your favorite text editor, for example, vim and edit /etc/exports file and add line /home/nfs/ *(ro,sync) to export /home/nfs directory for any host with read only permissions. Be sure that the directory you export by NFS exists. You can also create a file inside the /home/nfs directory which will help you troubleshoot once you mount this file system remotely.# touch /home/nfs/test_file
4.3. Restart NFS daemon
Once you edit /etc/exports file you need to restart NFS daemon to apply changes in the /etc/exports file. Depending on your Linux distribution, the restarting of NFS may differ. Debian users:# /etc/init.d/nfs-kernel-server restartRedhat users
# /etc/init.d/nfs restartIf you would, later, decide to add more NFS exports to the /etc/exports file, you will need to either restart NFS daemon or run command exportfs:
# exportfs -ra
5. Mount remote file system on client
First we need to create a mount point:# mkdir /home/nfs_localIf you are sure that the NFS client and mount point are ready, you can run the mount command to the mount exported NFS remote file system:
# mount 10.1.1.200:/home/nfs /home/nfs_localIn case that you need to specify a type of the filesystem you can do this:
# mount -t nfs 10.1.1.200:/home/nfs /home/nfs_localYou may get error message
mount: mount to NFS server failed: timed out (retrying).This may mean that your server supports higher versions of nfs you need to pass tone extra argument to you nfs client. In this example we use nfs version 3:
# mount -t nfs -o nfsvers=3 10.1.1.200:/home/nfs /home/nfs_local
Now you should be able to see that the file system is mounted. Notice that the mount command reports that the filesystem is mounted as "read and write", although you can see that it provides a "read only" permission.
6. Configure automount
To make this completely transparent to end users, you can automount the NFS file system every time a user boots a PC, or you can also use PAM modules to mount, once a user logs in with a proper username and password. In this situation just edit /etc/fstab to mount system automatically during a system boot. You can use your favorite editor and create new line like this:10.1.1.200:/home/nfs /home/nfs_local/ nfs defaults 0 0in /etc/fstab or
# echo "10.1.1.200:/home/nfs /home/nfs_local/ nfs defaults 0 0" >> /etc/fstab