Linux NFS detailed configuration method Network File System (NFS, NetworkFileSystem) is a mechanism to mount the partitions (directories) on the remote host to the local system through the network, with support for the network file system, you can operate on the local system like a local partition... linux NFS detailed configuration method Network File System (NFS, Network File System) is a mechanism to mount the partitions (directories) on the remote host to the local System through the Network, with support for the network file system, you can operate on the shared partition (directory) of the remote host on the local system just like operating on the local partition. During the development process of www.2cto.com in embedded Linux, developers need to develop all the software on the Linux server. after cross-compilation, the general FTP Mode Downloads executable files to the embedded system for running, however, this method is not only inefficient, but cannot be used for online debugging. Therefore, you can create NFS to share specific partitions on the Linux server to the embedded target system to be debugged, and then operate the Linux server directly on the embedded target system, at the same time, you can debug and modify the program online, greatly facilitating software development. Therefore, NFS is an important part of embedded Linux development. This section details how to configure the NFS development environment of embedded Linux. The implementation of the NFS development environment for embedded Linux on www.2cto.com includes two aspects: one is the support of the NFS server on the Linux server, and the other is the support of the NFS client on the embedded target system. Therefore, to establish an NFS development environment, you must configure the Linux server and embedded target system. 1. configure the NFS server on the Linux server to log on to the Linux server as root, edit the exports shared directory configuration file under the/etc directory, and specify the shared directory and permissions. Run the following command to edit the file/etc/exports: # vi/etc/exports and add the following content to the File:/home/work 192.168.0. * (rw, sync, no_root_squash) save and exit. The added content indicates that the computer with the ip address range of 192.168.0. * can access the/home/work directory with the read/write permission. /Home/work is also called the server output shared directory. The parameter meanings in the brackets are described as follows: rw: read/write permission. the parameter of read-only permission is ro; sync: data synchronization writes to memory and hard disk, or async, at this time, the data is saved in the memory, instead of immediately written to the hard disk. No_root_squash: attributes of the NFS server shared Directory user. if the user is root, the shared directory has root permissions. Run the following command to start Port ing: #/etc/rc. d/init. d/portmap start run the following command to start the NFS service. at this time, NFS will activate the daemon and then start listening to Client requests: #/etc/rc. d/init. d/NFS start users can also restart the Linux server to automatically start the NFS service. After the NFS server is started, you also need to check the firewall and other settings of the Linux server (usually you need to disable the firewall service) to ensure that the ports used by NFS and the hosts that allow communication are not blocked, check the settings of iptables, ipchains, and other options on the Linux server, as well as/etc/hosts. deny,/etc/hosts. allow file. We first perform a loop test on the NFS server on the Linux server to verify whether the shared directory can be accessed. Run the following command on the Linux server: # mount-t NFS 192.168.0.20: the/home/work/mnt # ls/mnt Command mounts the NFS output shared directory of the Linux server to the/mnt Directory. Therefore, if NFS works properly, you should be able to see the content in the/home/work shared directory in the/mnt directory. 2. configure the NFS client of the embedded target system after the Linux server is configured. When configuring the kernel, select Load an Alternate Configuration File and enter the path and File name of the Configuration File to add kernel support for NFS: select networking options-"IP address: select the root file system on NFS and NFS file system support under file systems-> network file systems-> kernel level aulow.alion to recompile the kernel and download bootloader and kernel to the embedded target system on the development board. in Linux Shell, run the following command to mount the NFS shared directory: # mkdir/mnt/NFS // Create a mount point for the Linux server to output the shared directory; # mount-t NFS 192.168.0.20: /home/work/mnt/NFS-o nolock # cd/mnt/N FS # ls at this time, the content displayed on the embedded target system is the content of the output Directory of the Linux server, that is, the output Directory of the Linux server. /Home/work is mapped to the/mnt/NFS Directory of the embedded target system through NFS. You can use the add/delete/modify method to verify the actual effect. In the mount command, 192.168.0.20 is the IP address of the Linux server,/home/work is the shared output directory configured on the Linux server, and/mnt/NFS is the local directory on the embedded device. During the development process, it is very annoying to input commands back and forth. I wrote two simple scripts to start and Mount NFS. Host starts NFS: sNFS #! /Bin/bash ifconfig eth0 192.168.0.20/etc/rc. d/init. d/portmap start/etc/rc. d/init. d/NFS start mounting NFS: mNFS: #! on the embedded target machine :#! /Bin/sh mount-t NFS 192.168.0.20:/home/work/NFS/mnt/NFS-o nolock echo "NFS OK !"
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