Setting up NFS sharing skills under Linux operating systems

Source: Internet
Author: User
Tags firewall

The network filesystem (nfs,network file system) is a mechanism by which partitions (directories) on a remote host are mounted over the network to the local system, which enables users to share partitions (directories) on the remote host, as if they were operating on the local system, by supporting the network file system. to operate.

In the development of embedded Linux, developers need to do all the software development on the Linux server, cross compile, the general FTP way to download the executable file to the embedded system, but this method not only inefficient, and can not achieve online debugging. Therefore, by establishing NFS, the specific partitions on the Linux server can be shared on the embedded target system to be debugged, the Linux server can be operated directly on the embedded target system, and the program can be debugged and modified online, which greatly facilitates the development of the software. Therefore, NFS is an important part of embedded Linux development, and this section details how to configure the NFS development environment for Embedded Linux.

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

A, Linux server-side NFS server configuration

Log on to the Linux server as root, edit the shared directory profile exports in the/etc directory, specify shared directories and permissions, and so on.

Perform 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)

Then save the exit.

Added: Allows a computer with an IP address range to access the/home/work directory with read-write access to the 192.168.0.*.

/home/work is also known as the server output share directory.

The parameter meanings in parentheses are described as follows:

RW: Read/write permission, read-only permission parameter is ro;

Sync: Data is written to memory and hard drives, or async, where data is temporarily stored in memory and not written to the hard disk immediately.

The NO_ROOT_SQUASH:NFS server shares the user's attributes of the directory and, if the user is root, has root permissions for the shared directory.

Then execute the following command to start the port mapping:

#/etc/rc.d/init.d/portmap Start

Finally, execute the following command to start the NFS service, at which time NFS activates the daemon and then starts listening on client side requests:

#/etc/rc.d/init.d/nfs Start

Users can also restart the Linux server and start the NFS service automatically.

After the NFS server is started, you will also need to check settings such as the firewall for the Linux server (typically shutting down the Firewall service) to ensure that the ports used for NFS and the hosts that allow traffic are not shielded, primarily by checking the settings of options such as Linux server Iptables,ipchains, and/ Etc/hosts.deny,/etc/hosts.allow files.

We first test the loopback server on the Linux server to verify that the shared directory can be accessed. Run the following command on the Linux server:

# mount–t NFS 192.168.0.20:/home/work/mnt

# LS/MNT command to mount the NFS output share directory of the Linux server to the/MNT directory, so if NFS is working properly, you should be able to see the contents of the/home/work shared directory in the/MNT directory.

Second, the embedded Target system NFS Client Configuration

After the Linux server is set up, you need to configure the client as well. When configuring the kernel select the load an alternate Configuration file input profile path and filename add kernel support for NFS:

Select Networking options-"Ip:kernel level auloconfiguralion Item

Select the root file system on NFS under File systems-"Network file systems-"

and NFS file system support to recompile the kernel download bootloader and kernel onto the Development Board

Under the embedded target system's Linux Shell, execute the following command for NFS shared directory mounts:

# MKDIR/MNT/NFS//Set up Linux server output shared directory mount point;

# mount–t NFS 192.168.0.20:/home/work/mnt/nfs–o Nolock

# Cd/mnt/nfs

# ls

At this point, the contents of the embedded target system display are the contents of the Linux server's output directory, that is, the output of the Linux server.

The recording/home/work is mapped to the/mnt/nfs directory of the embedded target system via NFS. Users can verify the actual effect by adding/deleting/modifying files. The 192.168.0.20 in the Mount command is the IP address of the Linux server,/home/work the shared output directory configured on the Linux server side,/mnt/nfs the local directory on the embedded device.

In the development process, the back and forth input commands are very annoying, I wrote two simple scripts to complete the NFS launch, Mount.

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

Embedded Target Mount NFS:

Mnfs:

#!/bin/sh

Mount-t NFS 192.168.0.20:/home/work/nfs/mnt/nfs-o Nolock

echo "NFS ok!"

Related Article

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.