Configuring Server for NFS under Linux

Source: Internet
Author: User

The Network File system (NFS) is a mechanism for mounting a partition (directory) on a remote host to a local system through Network file system support, Users can manipulate the shared partition (directory) of a remote host on the local system as if it were a local partition.


In the development process of embedded Linux, developers need to do all the software development on the Linux server, after cross-compiling, the general FTP method will download the executable files to the embedded system, but this method is not only inefficient, and can not realize the online debugging. Therefore, through the establishment of NFS, a specific partition on the Linux server to be debugged on the embedded target system, you can directly on the embedded target system operation of the Linux server, while the program can be online debugging and modification, greatly facilitates the development of software. Therefore,NFS is an important part of embedded Linux development, and this section will detail how to configure an NFS development environment for Embedded Linux.


The implementation of NFS development environment of embedded Linux includes two aspects: one is server support for NFS on Linux server and the other is support of NFS client of embedded target system. Therefore, the establishment of theNFS development environment requires the configuration of the Linux server side and the embedded target system side.


NFS was developed and developed by Sun to share files with each other through the network across different machines and operating systems. NFS Server can also be thought of as a file SERVER that can be used to share files between Unix class systems, easily mount (mount) to a directory, and operate as easily as a local file.


Type: System v-launched Service


Package:NFS-utils


Process:NFSd,lockd,rpciod,rpc. {MOUNTED,RQUOTAD,STATD}


Script:NFS,NFSLock


Port: Port assigned by Portmap Service (111)


Configuration file:/etc/exports


Auxiliary tools: Portmap (Required)


Related commands: Rpcinfo-p [Ipadd]: View RPC services provided by the server


SHOWMOUNT-E: Viewing the directory of service shares


Server side:


1./etc/exports format:


Directory options


Example: Sharing the/share directory to 192.168.0.x users


/share 192.168.0.0/24 (rw)


/home/haiouc/haioucshare * (Rw,sync,all_squash)


/mnt/cdrom 192.168.0.* (RO)


====> * refers to allowing all IP access;


To the directory/home/haiouc/haioucshare to give a certain permission;


You can load a local disc and share it with NFS to others


2. Start the Portmap service:


Service Portmap Start[restart]


3. Start the NFS service:


Service NFS Start[restart]


Client side:


1. Start the Portmap service:


Service Portmap Start[restart]


2. Mount the shared directory on the server side (assuming server-side 192.168.0.1):


Mkdir/mnt/localshare


Mount-t NFS 192.168.0.1:/share/mnt/localshare


=========================================================================


Showmount//Display information about NFS Server file system mounts


SHOWMOUNT-E//Display output list for NFS Server


=========================================================================


Chkconfig--level NFS on//Set NFS Auto-start mode;


=========================================================================


Automatically mount NFS directory on boot by modifying the/etc/fstab file


[[email protected] NFS1]# cat/etc/fstab


# This file was edited by Fstab-sync-see ' Man Fstab-sync ' for details


label=//ext3 Defaults 1 1


None/dev/pts devpts gid=5,mode=620 0 0


NONE/DEV/SHM TMPFS Defaults 0 0


NONE/PROC proc Defaults 0 0


None/sys Sysfs Defaults 0 0


LABEL=SWAP-HDC2 swap swap defaults 0 0


192.168.1.10:/home/haiouc/haioucshare/mnt/NFS1 NFS defaults 0 0


=========================================================================


NFS parameter information:


Access Permissions Options


. Set output directory read-only RO


. Set output directory read-write RW


User mapping Options


. All_squash maps all normal users and groups that are accessed remotely to anonymous users or groups of users (NFSnobody);


. No_all_squash and All_squash (default setting);


. Root_squash the root user and the owning group are mapped to anonymous users or groups of users (default setting);


. No_root_squash and Rootsquash take the reverse;


. ANONUID=XXX maps All remote access users to anonymous users and specifies that the user is a local user (uid=xxx);


. Anongid=xxx maps All user groups that are accessed remotely to the anonymous user group account and specifies that the anonymous user group account is a local user group account (GID=XXX);


Other options


. Secure restricts clients from connecting to server for NFS (the default setting) only from TCP/IP ports less than 1024;


. Insecure allows clients to connect to servers from TCP/IP ports greater than 1024;


. Sync writes data synchronously to the memory buffer and disk, but it is inefficient, but it can guarantee the consistency of data;


. Async saves the data in the memory buffer and writes the disk if necessary;


. Wdelay Check if there is a related write operation, if any, then perform these writes together, which can improve the efficiency (default setting);


. No_wdelay If a write operation is performed immediately, should be used in conjunction with sync;


. Subtree If the output directory is a subdirectory, the NFS Server will check the permissions of its parent directory (default setting);


. No_subtree theNFS server does not check the permissions of its parent directory even if the output directory is a subdirectory, which can improve efficiency.

Configuring Server for NFS under Linux

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.