NFS configuration in Embedded Linux

Source: Internet
Author: User
Tags nfsd

Install and Configure NFS on fedora 17:

Http://www.server-world.info/en/note? OS = fedora_17 & P = NFS

Original article:

Http://cabbage812.blog.163.com/blog/static/922814382009287020395/

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 details how to configure embedded Linux
NFS development environment.

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:

# Vi/etc/exports

Add the following content to the file:

/Home/work 192.168.0. * (RW, sync, no_root_squash) (do not add spaces after the comma)

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 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
(F17 use # systemctl start nfs-server.service)

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.0.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.

Ii. configurations of NFS clients in the Embedded Target System

After the Linux server is configured, you also need to configure the client. 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: kernel level aulow.alion.

Select the root file system on NFS under file systems-network file systems-

And NFS file system support re-compile the kernel to download Bootloader and kernel to the Development Board.

In the Linux Shell of the embedded target system, 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/nfs

# Ls

In this case, 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
Mount NFS on an Embedded Target machine:
Mnfs:

#! /Bin/sh

Mount-t nfs 192.168.0.20:/home/work/nfs/mnt/nfs-O nolock

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

Problems on my PC

# Systemctl status nfs-server.service
Nfs-server.service-NFS server
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; Enabled)
Active: Failed (Result: Exit-code) Since Thu, 14 mar 2013 10:07:58 + 0800; 6 s ago
Process: 2677 execstoppost =/usr/sbin/exportfs-F (code = exited, status = 0/success)
Process: 2674 execstop =/usr/sbin/rpc. nfsd 0 (code = exited, status = 0/success)
Process: 2655 execstartpost =/usr/lib/nfs-utils/scripts/nfs-server.postconfig (code = exited, status = 0/success)
Process: 2642 execstart =/usr/sbin/rpc. nfsd $ rpcnfsdargs $ rpcnfsdcount (code = exited, status = 0/success)
Process: 2683 execstartpre =/usr/sbin/exportfs-R (code = exited, status = 22)
Process: 2680 execstartpre =/usr/lib/nfs-utils/scripts/nfs-server.preconfig (code = exited, status = 0/success)
Cgroup: Name = systemd:/system/nfs-server.service

Mar 14 10:07:58 huntinux exportfs [2683]: exportfs:/etc/exports: 2: syntax error: Bad... st


Check the running status of NFS here, but there is an error in/etc/exports. The reason is ',' in (RW, sync, no_root_squash). I added a space after, remove the space. (RW, sync, no_root_squash)

Similar question post: http://forums.fedoraforum.org/showthread.php? T = 287427

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

Problems with NFS mounting on the Development Board:

1) # Mount-t nfs 192.168.1.131:/nfs/busybox/mini_fs/nfs/fs

Error message: Mount: RPC: unable to receive; errno = No route to host

Solution: # systemctl stop iptables. Service (temporarily disable the firewall)

Permanently disable the firewall: # systemctl disable iptables. Service

2)Shut down the firewall and run it again # Mount
-T nfs 192.168.1.131:/nfs/busybox/mini_fs/nfs/fs

Error message: rpcbind: Server localhost not responding, timed out

Press Ctrl + Z to exit

Solution: # Mount-T NFS-O nolock192.168.1.131:/nfs/busybox/mini_fs/nfs/fs
Some information about-O nolock: http://wb127.blog.51cto.com/2232662/401732


3) Enable the Development Board to automatically mount the NFS file system at startup.

Http://www.cnblogs.com/cornflower/archive/2010/03/27/1698279.html

======================================== Remember to close the firewall ======== ====================================

systemctl stop iptables.servicesystemctl disable iptables.service

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.