Root file system startup and Configuration

Source: Internet
Author: User
Article Title: Start and configure the root file system. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

Related Files are described in sequence of startup:

1. Run/linuxrc first after the kernel is started.

/Linuxrc content:

--------------------------------------------------------------------------------

#! /Bin/sh

Echo "mount/etc as ramfs"

/Bin/mount-n-t ramfs/etc

/Bin/cp-a/mnt/yaffs/etc/*/etc // when shutdown, we will save the/etc content to/mnt/yaffs/etc.

Echo "re-create the/etc/mtab entries"

# Re-create the/etc/mtab entries

/Bin/mount-f-t cramfs-o remount, ro/dev/mtdblock/2/

/Bin/mount-f-t ramfs/etc

Exec/sbin/init

--------------------------------------------------------------------------------

First, you need to understand this linuxrc,

1./bin/mount-n-t ramfs/etc

Load a ramfs as the/etc directory. In this way,/etc is a writable directory.

Check this script to find that your root file system is a cramfs, a read-only file system, and/etc is used as the storage location of the system running configuration file, some running states may be written here. The first thing in linuxrc is to mount a ramfs to the/etc read-only directory so that the/etc/directory can be writable, the purpose of specifying the-n parameter is to tell mount not to write/etc/mtab. This file is stored in all the file systems mounted by the current system. Because the/etc/directory is still read-only, do not write this file for this mount, otherwise it will fail.

Where is the ramfs you asked? There should be a ramfs in your/etc/fstab file. mount will find this option. If not, mount will fail. It cannot be executed later.

2./bin/cp-a/mnt/yaffs/etc/*/etc

After/etc becomes a writable directory, copy all configuration files in/mnt/yaffs/etc to/etc/. This indicates that your ramfs may be an empty ramfs, there is no configuration file, or the configuration file is old. It also indicates that your system is a read-only system, and the configurations written in each system operation will not be retained.

Re-write the previously mounted information to the/etc/mtab. The command is as follows.

3./bin/mount-f-t cramfs-o remount, ro/dev/mtdblock/2/

/Bin/mount-f-t ramfs/etc

These commands only write the mount information to/etc/mtab and do not actually mount these block devices. It means that your root file system is still the previous one/dev/bon/2.

4. exec/sbin/init

Execute the init execution program in the root file system to make it process 1. Shell is officially run.

######################################## ######################################## ###

/Etc/mtab introduction:

Mtab is in the same format as/etc/fstab. It is used to record information about mounted partitions.

Note:

If you do not have the/linuxrc file, the system first runs/sbin/init by default.

######################################## ######################################## ###

2. We can see from the/linuxrc file that it finally runs/sbin/init, and init will run according to/etc/inittab.

Inittab file entry format:

Id: runlevels: action: process

Id:

The unique identifier of entries in the inittab file, which must be 1-4 characters long (if the sysvinit program is compiled using a library with a version number less than 5.2.18 or a. out, it must be 2 characters long ).

Note: For getty or other registration processes, the id must be the tty Suffix of the response terminal line, for example, 1 responds to tty1. Otherwise, the registration process cannot work normally.

Runlevels:

#0-halt (Do NOT set initdefault to this)

#1-Single user mode

#2-Multiuser, without NFS (The same as 3, if you do not have networking)

#3-Full multiuser mode

#4-unused

#5-X11

#6-reboot (Do NOT set initdefault to this)

Action

Describes the action to take.

Process

The process to be executed. if the process field starts with a '+', init does not charge for this process in the utmp and wtmp files. this is because getty needs to host utmp/wtmp accounting by itself, and it is also a legacy vulnerability.

The runlevels field can contain multiple characters that indicate different running levels. For example, 123 indicates that the process must be started when the running level is 1, 2, and 3. the runlevels domain used for the ondemand entry can contain A, B, or C. the runlevels fields used for sysinit, boot, and bootwait entries are ignored.

When the running level is changed, the processes that are not given in the new operation level are killed. Use the SIGTERM signal first, and then the SIGKILL.

The following actions can be used in the action field:

Respawn:

Restart the process as long as it is terminated (such as getty ).

Wait

Start this process as long as you enter the specified running level, and init waits for the end of the process.

Once

This process is started once at the specified running level.

Boot

This process is executed during system boot. The runlevels domain is ignored.

Bootwait

Execute this process during system boot. and init waits for the process to end (such as/etc/rc). The runlevels domain is ignored.

Off

Do nothing.

Ondemand

Only processes marked as ondemand will be executed at the ondemand running level. in any case, the running level is not actually changed (ondemand running level is 'A', 'B', and 'C ').

[1] [2] Next page

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.