Start Linux__linux from NFS

Source: Internet
Author: User

embedded, do not know NFS, it is absolutely a tragedy. If you even debug a normal Linux C program, you have to go through the "Compile-> package-> burn Write-> Restart" These processes, then you are not a day away from the formal product, is not a product, you have tired of this job. I have seen a baby, in a memory only 512MB machine, installed a VMware virtual machine, ran a red Hat 9来 compiled debugging his arm Linux program-I asked him why not use NFS. He answered, somehow--and decided to share the debugging methods of sharing joy and joy. Linux startup process review

Someone is going to have a big mouth, I've talked about this process in a bunch of articles before, and here I repeat. In fact, understand the Linux startup process, and then understand something else, it is not difficult, such as live CD, installed on a U disk Linux and so on. the working principle of Linux

Talk less, first figure.


It's very simple. The computer is to run the program, the operating system is (not only) responsible for multiple programs on a CPU running. Linux is no exception, is also the operating system after the start of the kernel, the natural turn to the operating system for our own programs to serve the time.

This is the basic principle of it. But we need to consider some details for it, the first, is also the core of this article, where the operating system to find programs to run .

First we want to make clear that we refer to the program, is placed in a directory-level structure of the file system, in order to find the desired operating system to run the program, we have to tell it, which file system. In general, the PC files are stored on the hard disk, and for the live CD, the file system is hidden on the CD. In other words, as long as the operating system can find and correctly understand the file system, you can execute the inside of the program. Set NFS startup on the target machine

After reading the first section, do you understand the initiation process? Simply put, the kernel is loaded , the kernel finds a file system , and the kernel executes a program in the file system . This is the process, whether it is starting from NFS or booting from a hard disk. Only NFS is started and its file system is on the network. As long as we tell the kernel where it is, and we set it up at the other end of the network, we can naturally start from NFS. enable the kernel to identify NFS and boot from NFS compiling the kernel

Under the kernel source code directory tree, configure the kernel:

$make Menuconfig

Turn to file Systems-> Network File system to select NFS Client Support and Root File System on NFS. If the root file system on NFS option is not found, open the Networking support-> networking options-> TCP/IP networking-> Ip:ke on the first level menu Rnel level Autoconfiguration. If NFS is to use DHCP, you have to choose IP:DHCP support.

Save the configuration and recompile. Configuring Kernel Parameters

Enter the linux_cmd_line where the arm Development Board is set (mini2440 then press S, enter the Linux_cmd_line, and enter the parameters with quotes), or enter the PC's grub and set similar parameters

Root=/dev/nfs RW Nfsroot=192.168.1.1:/linux Ip=192.168.1.5:::255.255.255.0:linux::off

The configuration is static IP settings. The meaning of each parameter is as follows:
Root=/dev/nfs: Specifies that the root file system is/dev/nfs, that is, NFS. This does not have anything to do with the directory of/Dev, which is only one name.
rw: The root file system is mounted as writable. You can also have the RO that is read-only option.
nfsroot=192.168.1.1:/linux : Indicates which of the directories on which NFS is mounted. This refers to the/linux directory that is exported on a computer that is mounted with IP as 192.168.1.1.
Ip=192.168.1.5:::255.255.255.0:linux::off: Set the IP for this computer. This is to connect the IP that you just set up. Here is a static configuration, configured in the format of ip= native IP address:: Gateway address: Network mask: The host name: network interface name: OFF. Under normal circumstances, the gateway, network interface names do not need to be set. If it is DHCP to obtain IP, it is very simple, direct ip=dhcp can be. set up server for NFS

Server for NFS can be any operating system, as long as you can provide NFS services (Windows can use Wsu--windows Services for UNIX to implement, please refer to the following article to be published in this site). In this case, fedora, for example, would like to analogy users of other distributions.

For Fedora, a graphical interface tool is set up to add a share to the admin-"Server Settings-" NFS.
The more common practice is to modify the/etc/exports file before you start the NFS server.

The/etc/exports file format is as follows

Exported Network segment for folder exported (options for this exported network segment)

The so-called exported network segment is only to which network segment to export, to ensure security. One example is:

/linux 192.168.1.0/24 (Rw,sync,no_root_squash)

is to export the/linux to a network segment of 192.168.1.0, the subnet mask being 255.255.255.0 (that is, 24). The options available are (translated from the Man Document):

secure and insecure: Under Secure option, all connected ports are less than 1024. Opens by default.
rw and Ro: Read/write and Read only
Async and Sync async will use asynchronous data access, and the data is not written to the server immediately. Sync is the opposite. Using async you need to be aware that the server cannot be shut down randomly, or it may cause data loss.
no_wdelay: Do not use deferred writes. Server for NFS will buffer write write requests to improve performance. This option is not valid if Async is already open.
no_subtree_check: No subtree checks (use this option to cause security issues)
Root_squash and No_root_squash, All_squash: Root_squash option enables clients to convert to the server-side anonymous user when accessing the file system with root privileges. This option opens the server's permissions must be set properly.

Then restart the NFS service. Fedora under the use of/etc/init.d/nfs restart
Use exports to view exported files.

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.