Ubuntu7.10NFS (NetworkFileSystem, Network File System) Installation and setup steps

Source: Internet
Author: User
Ubuntu7.10NFS (NetworkFileSystem, Network File System) installation and configuration steps-Linux Enterprise Application-Linux server application information, the following is a detailed description. Network File System (NFS) allows you to share directories of different hosts (OS) over the Network-you can mount directories of remote hosts through NFS, accessing this directory is like accessing a local directory!

Generally, nfs can be used to easily share unix-like systems. However, to share unix-like systems with windows systems, samba must be used!

Based on SUN's Remote Procedure Call (Remote Procedure Call), RPC defines a system-independent method for inter-process communication. therefore, the NFS server can also be viewed as an RPC server.

Because NFS is an RPC service program, you must map the port before using it-set it through portmap. for example, when an NFS client initiates an NFS service request, it must first obtain a port ). therefore, it first obtains the port number through portmap. (not only NFS, but portmap needs to be set before all RPC service programs start)

Several NFS-related files and commands

1,/etc/exports
The access to the NFS volume is approved by exports, which enumerate several hostnames that have the right to access the file system on the NFS server.

2,/sbin/exportfs
Maintain NFS Resource Sharing. You can reset the shared directory of/etc/exports, unmount the shared directory of NFS Server, or share it again.

3,/usr/sbin/showmount
It is used on NFS Server, while showmount is mainly used on Client. Can it be used on showmount? Zookeeper NFS shared directory resources.

4,/var/lib/nfs/xtab
NFS record document: You can view which clients are connected to the NFS host.

The following are not directly responsible for NFS. In fact, they are responsible for all RPC
5,/etc/default/portmap
In fact, portmap maps all the RPC service ports. Its content is very simple (detailed later)

6,/etc/hosts. deny
Set the host to reject the portmap service

7,/etc/hosts. allow
Set the host that allows the portmap service
Install NFS
By default, the NFS server is not installed on Debian/Ubuntu. First, install the NFS service program:
$ Sudo apt-get install nfs-kernel-server
(When nfs-kernel-server is installed, apt will automatically install nfs-common and portmap)
In this way, the host is equivalent to the NFS Server.

Similarly, if the target system is an NFS client, you must install the NFS client program. For Debian/Ubuntu systems, nfs-common must be installed.
$ Sudo apt-get install nfs-commmon

Both nfs-common and nfs-kernel-server depend on portmap!

Configure NFS
Configure portmap

Method 1: edit/etc/default/portmap and remove-I 127.0.0.1.

Method 2: $ sudo dpkg-reconfigure portmap, shocould portmap be bound to the loopback address? Select N.

Configure/etc/hosts. deny
(Prohibit any host (host) from connecting to your NFS server), add:
### NFS DAEMONS

Portmap: ALL

Lockd: ALL

Mountd: ALL

Rquotad: ALL

Statd: ALL

Configuration/etc/hosts. allow
Allow hosts you want to establish connections with your NFS server. The following steps allow any host whose IP address starts with 192.168.2 (connected to the NFS server), or specify a specific IP address. See hosts_access (5) and hosts_options (5) on the man page ). Join:
### NFS DAEMONS

Portmap: 192.168.2.

Lockd: 192.168.2.

Rquotad: 192.168.2.

Mountd: 192.168.2.

Statd: 192.168.2.

/Etc/hosts. deny and/etc/hosts. allow sets the access to portmap. using these two configuration files is a bit similar to "mask. now/etc/hosts. deny prohibits all users from accessing portmap. then in/etc/hosts. some users are allowed to access portmap in allow.
Run $ sudo/etc/init. d/portmap restart to restart portmap daemon.

Configure/etc/exports
The NFS mount directory and permissions are defined by the/etc/exports file.

For example, to share the IP address of 192.168.2. * In the/home/zp/share directory of my home directory, add the following statement at the end of the file:
/Home/zp/share 192.168.2. * (rw, sync, no_root_squash)
Or:/home/zp/share 192.168.2.0/24 (rw, sync, no_root_squash)

192.168.2. * The NFS client in the network segment can share the contents of the NFS server/home/zp/share directory. the user has the read and write permissions, and the user's identity after entering the/home/zp/share directory is root
It is best to add sync. Otherwise, a warning will be given when $ sudo exportfs-r is used. sync is the default option of NFS.

(Run $ showmount-e to view the NFS server's export list.

If/etc/exports is changed, run $ sudo exportfs-r update.

Run $ sudo/etc/init. d/nfs-kernel-server restart to restart the nfs service)

/Etc/exports is actually the core configuration file of the nfs server. laruence's Linux private dish lists the writing of some exports files.

Test NFS
Try mounting the local disk (assuming the IP address of the local host is 192.128.2.1, Mount/home/zp/share to/mnt)
$ Sudo mount 192.168.2.1:/home/zp/share/mnt
Run $ df to check the result
$ Sudo umount/mnt

Note the read/write permissions of the copied file!
It must be the same as the first three sections of the Development Board IP address.
In addition, some parameters can be used:
Add parameters: mount-o nolock, rsize = 1024, wsize = 1024, timeo = 15 192.168.2.130:/tmp // tmp/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.