Network File System (NFS) is a mechanism for attaching partitions (directories) on remote hosts to local systems 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 of embedded Linux, developers need to develop all the software on the Linux server. After cross-compilation, the executable files can be downloaded to the embedded system in the FTP mode, 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 describes how to configure the NFS development environment of embedded Linux.
The implementation of the NFS development environment in Embedded Linux 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.
I. configuration of NFS servers on Linux servers
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:
# Gedit/etc/exports
Or use
# Sudo gedit/etc/exports
Add the following content to the file:
/Nfsboot * (rw, sync, no_root_squash)
Save and exit.
The added content indicates that the ip address range is allowed for computers with all ip addresses to access the/nfsboot directory with read and write permissions.
/Nfsboot is also called the server output shared directory.
The meanings of parameters in parentheses are described as follows:
Rw: read/write permission. the read-only permission parameter is ro;
Sync: data is written to the memory and hard disk synchronously. You can also use async. Data is saved in the memory before being written to the hard disk immediately.
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
Finally, 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
You 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 a Linux Server:
# Mount-t NFS 192.168.1.20:/home/work/mnt
# Ls/mnt
Command to mount 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. Add NFS support to the Linux Kernel
3. Set the startup parameters in UBOOT as follows:
Setenv bootargs noinitrd root =/dev/nfs console = ttySAC0 init =/init nfsroot = 192.168.1.103:/nfsboot ip = 192.168.1.20: 192.168.1.103: 192.168.1.1: 255.255.255.0: eth0: on
Through the above parameter settings, you can avoid the FLASH burning process, directly use the directory in the computer host as a file system, so that you can easily modify and test any program. After the complete debugging is complete, you can download it to FLASH to load and run it.