Simple additions to the root file

Source: Internet
Author: User

File system: An application of kernel management files when mapping a file system to a local kernel mount file system by Bootargs or NFS, you first need to locate the mount, use Bootargs to mount the file via NFS, and then execute the INIT process when the mount file is found. BusyBox inside there is the INIT process, compiled and configured to run after the configuration of the _install file below the sub-file is basically a link to-->/bin/busybox, in the busybox-1.17.3/coreutils/ There are various commands in the implementation of the program, such as: Ls,cat, etc., these programs can be learned, improve their programming skills, training programming methods and programming style, in init/init.c is to implement the INIT process program. After running the INIT.C program will eventually run the Parse_inittab () function Parsing command, this time need to open the Etc/inittab file, so we need to create a inittab file under etc, so what's in this inittab? , there are some explanatory files under Busybox/examples/inittab, which is a script for init initialization, format: format for etch entry: : :: ID: That terminal run, do not write is the default terminal, the basic omission of runlevels: basic omission of the action: to indicate in what way to run, is to run once or like to kill the cockroach as the process: the script inside of what to run for example:;; askfirst;/bin /sh means to ask before running/bin/sh and running. If there is no inittab, INIT.C will go to the default execution of some things, if opened, go to the default parsing of your face, parsing the object, the program will be four above the domain of a structure, and then do the relevant operation resolution operation, when the file runs, at this time if we want to run Ps,ls Dev and other commands will prompt the need to/proc file system, this file is to describe the kernel up when the process running in the relevant state, when the kernel up when this file has been generated, but we do not mount, we can be mounted on the Development Board terminal to see the effect: MOUNT-T proc Proc. /proc/; But we can't always manually mount it, we need the system to automatically mount, so we can write it into a file, we usually create init.d/rcs under etc, put the command into the RcS script inside, write mount-a on the line, But after writing, how does the kernel know to do this? Do we still need to instruct, because the kernel is just starting to run when the Inittab file is running, so I can put the path into the inittab inside, add:: Respawn:/etc/init.d/rcs, indicating that if not found or not running, it runs all the time. , or:: Sysinit:/etc/init.d/rcs, this writing needs to manually modify the RcS permissions, indicating that only run once, this time to run again can be mounted successfully, but there are too many file systems, we can not be mounted each time a write up, So we create a fstab table below the etc, and write the files that need to be mounted in advance in the table. This way the terminal input mount-a is available. In front of the RCS we have already written, will automatically mount the completion, we can see the attached file directly after the effect of the mount, after the kernel boot there will be a lot of file status node, Run command mdev-s and then ls/dev/can see the device node, but we do not always enter this command every time , we can write the Mdev-s command to the front of the etc/init.c/rcs inside, so the system up when the mount of the mount, the run run. Also, at this point, the Development Board Terminal command Prompt is bare, there are some environment variables that need to be set, and a default file will be executed when executing the/bin/sh script, the footThis is etc/profile, what's in this script? The following content is for reference: add profile under etc, the file content is: #!/bin/shexport hostname=farsightexport user=rootexport home=rootexport ps1= "[[ Email protected] $HOSTNAME \w]\# "Path=/bin:/sbin:/usr/bin:/usr/sbinld_library_path=/lib:/usr/lib: $LD _ Library_pathexport PATH Ld_library_path to this time, the environment is almost finished, this time if we run their own application on it you will find that can not run up, this is why? Because the application needs to rely on a number of dynamic libraries, this time we need to prepare the dynamic library lib, finally, there is a device node in the file system is necessary, the console node is created under Dev, Mknod dev/console C 5 1 After everything is complete can be done after the final test. The following is the creation of the above so the file of an example, can refer to: First, the root file system production 1, the source download we choose the version is busybox-1.17.3.tar.bz2 download path: HTTP://BUSYBOX.NET/DOWNLOADS/2, decompression source $ Tar xvf busybox-1.17.3.tar.bz23, enter source directory $ cd busybox-1.17.34, configure source code $ make Menuconfigbusybox Settings---> Build Options-- ->[*] Build BusyBox as a static binary (no shared libs) [] Force Nommu build[] build with Large File support (for ACCE ssing files > 2 GB) (arm-none-linux-gnueabi-) The contents of the cross Compiler prefix parentheses are newly added () Additional CFLAGS5, compiling $ make6, installing BUSYB Ox default installation path is _install$ make install 7 under the source directory, enter the installation directory $ cd _install$ lsbin LINUXRCSbin USR8, create other required directories $ mkdir dev etc mnt proc var tmp sys Root 9, add library, copy Library from tool chain to _install directory $ cp/home/linux/toolchain/arm-non E-linux-gnueabi/libc/lib./-A or: CP ~/arm-cortex_a8/arm-cortex_a8-linux-gnueabi/sysroot/lib$./-A This is the library on my own computer Delete _ All directories,. o files, and. A files under Install/lib to reduce the size of the file system $ Arm-none-linux-gnueabi-strip lib/*10, add the system boot file under etc to add the file Inittab, The contents of the file are as follows: #this is run first except while booting in Single-user mode.::sysinit:/etc/init.d/rcs#/bin/sh invocations on select Ed ttys# start an "Askfirst" shell on the console (whatever, May is):: askfirst:-/bin/sh# stuff to doing when restarting T He init process::restart:/sbin/init# stuff to do before rebooting::ctrlaltdel:/sbin/reboot add file Fstab under etc, the file content is as follows: # Device mount-point type options dump fsck orderproc/proc proc defaults 0 0tmpfs/tmp tmpfs defaults 0 0sysfs/sys Sysfs D Efaults 0 0tmpfs/dev tmpfs Defaults 0 0 Here we mount the file system with three proc, Sysfs, and Tmpfs. In the kernel proc and SYSFS are supported by default, and TMPFS is not supported, we need to add TMPFS support to modify kernel configuration: File Systems--->pseudo filesystems---> [*] VIrtual Memory File system support (former SHM FS) [*] Tmpfs POSIX Access Control lists recompile kernel create INIT.D directory under etc, and create RCS text under INIT.D The contents of the RCS file are: #!/bin/sh# the first script called by init process/bin/mount-a Add executable permissions for RCS: $ chmod +x Init.d/rcs add under etc Profile file with the contents of: #!/bin/shexport hostname=farsightexport user=rootexport home=rootexport ps1= "[[email  Protected] $HOSTNAME \w]\# "Path=/bin:/sbin:/usr/bin:/usr/sbinld_library_path=/lib:/usr/lib: $LD _library_ Pathexport PATH ld_library_path11, device file creation root file system There is a device node that is required to create the console node under dev $ mknod dev/console C 5 1 Important: The newly crafted file system size exceeds 8M , delete unwanted library files II, NFS Test 1, backup/source/rootfs$ sudo mv/source/rootfs/source/rootfs_bak 2, copy our new root filesystem to the/source directory $ sudo cp _ INSTALL/SOURCE/ROOTFS-A3, set uboot environment variable # setenv bootcmd tftp 20008000 zimage\; Go 20008000# setenv bootargs root=nfs nfsroot=192.168.1.100:/source/rootfs init=/linuxrc console=ttysac0,115200 ip= 192.168.1.200# saveenv Restart the Development Board to see if it is properly mounted and functioning properly **************************************************************** ************************************************************************************************************************* *************************************************************************************************************** *************************************************************************************************************** *************************************************************************************************************** *************************************************************************************************************** *******

Simple additions to the root file

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.