Академический Документы
Профессиональный Документы
Культура Документы
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 accesses 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 setupt depends. 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
/home/nfs/ 10.1.1.100(rw,sync)
/home/nfs/ 10.1.1.0/24(ro,sync)
/home/nfs/ 10.1.1.100(rw,sync)
10.1.1.10(ro,sync)
/home/nfs/ *(ro,sync)
/home/nfs/
*.linuxconfig.org(ro,sync)
/home/nfs/ foobar(rw,sync)
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
Redhat users
# /etc/init.d/nfs restart
If you 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
If you are sure that the NFS client and mount point are ready, you can run the mount command to
mount exported NFS remote file system:
# mount 10.1.1.200:/home/nfs /home/nfs_local
In case that you need to specify a type of the filesystem you can do this by:
# mount -t nfs 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 0
in /etc/fstab or
# echo "10.1.1.200:/home/nfs /home/nfs_local/ nfs defaults 0 0" >> /etc/fstab
7. Conclusion
The Network File System comes with tons of export options. What has been shown here, just
barely scratches the surface of NFS. Please visit Linux NFS-HOWTO hosted by linux
documentation project or NFS homepage for more details.
8. Appendix A
Following section of this NFS tutorial is going to be devoted to RedHat like Linux systems
which by default block all incoming traffic to a NFS server by engaging firewall using iptables
rules. For this reason when the firewall is running on your NFS server, you might get this error
when mounting NFS filesytem: mount.nfs: mount to NFS server '10.1.1.13' failed: System
Error: No route to host. This error message has nothing to do with your NFS configuration, all
what needs to be done is either turn off the firewall or add iptables rules to allow traffic on
portmap port 111, nfs port 2049 and random ports for other nfs services.
There are two solutions to this problem: easy solution is to turn off the firewall completely and
the right solution to add appropriate iptables rules.
NOTE:
This will create a new set of iptables rules. If you have already defined some iptables rules
previously, you may want to edit iptables-rules-orig.txt and use it with iptables-restore command
instead.
# iptables-restore iptables-nfs-rules.txt
Save these new rules, so you do not have to apply new rules for nfs daemon next time you restart
your server: