Use busybox to build the root file system and summarize errors

Source: Internet
Author: User

To sum up the problems that have occurred in building the root file system using busybox over the past few days, the most important thing in general is the process of configuring busybox. You must know what is needed and what must be loaded, otherwise, when the kernel is started and the file system is loaded, there will be issues beyond human understanding. Therefore, as long as we know which basic configuration items are necessary and ensure that our file system can be loaded normally, other commands can be added as needed. To put it bluntly, let's start configuring busybox. I am using the latest busybox1.16.2 version.

 

1. Correctly configure busybox (I may understand it incorrectly, and some may or may not be required, but this configuration is only implemented from the perspective of solving the problem)

 

Input: # Make menuconfig
The page similar to Linux Kernel configuration appears, and you can configure it according to the following options.

 

Init utilities --->

Init

This init item must be selected. Use busybox to initialize the system.

 

Login/password management utilities --->

Use internal password and group functions rather than system functions

If this option is not selected, busybox cannot identify libness under Lib, And then it cannot parse uid... the consequence is very serious.


Shell ---> lower

Select Ash

Job Control

This must be selected; otherwise, CTRL + C is unavailable.

 

Busybox settings-> build options -->

Build busybox as a static binary (no shared libs)

I don't know why, everyone chooses to compile it into a static form. It is said that if it is compiled into a dynamic state, sometimes loading will be troublesome (to be confirmed, Let me know)

 

General Configuration

Show verbose applet usage messages

Support for SUID/SGID handling

Runtime SUID/SGID configuration via/etc/busybox. conf

 

 

Installation Options

Don't use/usr
(./_ Install) busybox installation prefix

This option must also be selected. Otherwise, after make install, busybox will be installed in the/usr of the original system, which will overwrite the original command of the system. After this option is selected, make
After install, a directory named _ install will be generated under the busybox Directory, which contains busybox and the link to it.

 

After the preceding configuration items are complete, you can add the required commands according to your actual configuration.

 

2 compile busybox 1.16.2

After the above basic configuration items and other options are configured, the compilation is quite simple. Perform the following steps:

Make

Make config_prefix = ../install

Note: config_prefix specifies the path for storing the file system generated after compilation.

 

3. Add other folders and files required by the system.

Create a folder: # mkdir
Dev etc lib MNT proc var TMP

 


Create an executable script file:

Go to the _ install/etc directory and create the inittab file. The script content is as follows:

# This is
Run first excep when booting in single-user mode.

: Sysinit:/etc/init. d/RCS

#/Bin/sh
Invocatioins on selected TTYs

# Start
"Askfirst" shell on the console (whatever that may be)


: Askfirst:-/bin/sh

# Stuff
Do when restarting the INIT process

: Restart:/sbin/init

# Stuff
Do Before rebooting


: Ctrlaltdel:/sbin/reboot

 

Go to the _ install/etc directory, create the init. d directory, enter the init. d directory, and create the RFM file.
The content is as follows:


#! /Bin/sh

# This is
The first script called by INIT process


/Bin/Mount-


Exec/usr/etc/rc. Local


Save and exit, run


# Chmod 777 RCS

// Change the File Permission

 


Go to the _ install/etc directory and create the fstab file. The content is as follows:


None
/Proc
Proc
Defaults 0 0


Tmpfs/dev/SHM
Tmpfs
Defaults 0 0

 


Go to the _ install/etc directory and create the profile file. The file content is as follows:


#/Etc/profile


Path =/bin:/sbin:/usr/bin:/usr/sbin


LD_LIBRARY_PATH =/lib:/usr/lib: $ LD_LIBRARY_PATH


Export path LD_LIBRARY_PATH


Note:
Profile is used to set the shell environment variables. When the shell starts, it reads/etc/profile to set the environment variables.

 


Go to the _ install/usr directory and create the etc directory.

Go to the _ install/usr/etc directory and create the RC. Local file. Where is the content:


#! /Bin/sh

# Add User
Specified script

CD
/Dev

Ln-S
/Dev/FB/0 fb0

Ln-S
VC/0 tty0

Ln-S
VC/1 tty1

Ln-S
VC/2 tty2

 

Mknod
-M 660 mtd0 C 90 0

# An even number of 0/2/4 in red indicates readable and writable. mtd0/1/2 indicates 1f00/01/02.

Mknod-m
660 mtd1 C 90 2
# Mtd0/0/1/2 Operations = 1f00/01/02 Operations

Mknod-m
660 mtd2 C 90 4

Mknod-m
660 1f00 B 310

Mknod-m
660 1f01 B 311

Mknod-m
660 1f02 B 312


(Depending on the nandflash partition)



Save and exit. Run # chmod 777
RC. Local
// Change the File Execution permission

 


Create an embedded system Library:


# Cp
/Home/Linux/crosstool/gcc-3.4.5-glibc-2.3.6/ARM-softfloat-Linux-GNU/ARM-softfloat-


Linux-GNU/lib _ install/-

# Cd
_ Install/lib


Delete all directories and static libraries (. A files)


To reduce the size of the library, run:


# Arm = softfloat-Linux-GNU-strip *. So

---------------------------------------------------------------- Configuration is completed ---------------------------------------------------------------------

 

 

After the above configuration and the remaining files are created, the root file system is created successfully. Then copy the file system created above to the main directory of the NFS file system. The subsequent task is to automatically load it when the kernel is started, the premise is that the PC must have configured the TFTP server and the NFS Network File System, and then run the bootargs parameter set for the kernel to load the root file system, if the Mount succeeds, you can access our root file system.

 

1. Set bootargs kernel startup parameters

I set it as follows:

Set bootargs noinitrd init =/linuxrc mem = 64 m console = ttys0, 115200 root =/dev/nfs nfsroot = 192.168.0.94:/home/CPC/nfs IP = 192.168.0.100

I believe everyone knows the specific meaning, so I will not explain it! If no error occurs, the system can load normally.

 

2. Problems:

(1) when loading the root file system:

Free memory: 112 K

Request_module: runaway loop modprobe binfmt-464c

Request_module: runaway loop modprobe binfmt-464c

Request_module: runaway loop modprobe binfmt-464c

Request_module: runaway loop modprobe binfmt-464c

Request_module: runaway loop modprobe binfmt-464c

.......

This problem has plagued me for two days. My mother made me feel bad. However, the problem is solved in the end. If you don't give up, the problem will always be solved. The key is the time problem. The cause is that the system cannot execute linuxrc. The problem lies in busybox, because the first sentence of my linuxrc is #! /Bin/sh, that is, the script file is parsed by SH, but under the binfile generated by my busybox
There is no sh command at all, and of course it cannot be executed. The solution is to reconfigure busybox and choose shell ----> choose your default.
Shell (Ash) ----> select ash, then make, and add arch = arm and cross_compile = arm-to make-
Linux-(it is recommended to use absolute paths, which I always use), even if arch and cross_compile have been specified in makefile, which is created by a colleague on the network.
Otherwise there may be some problems, such as the request_module I encountered this time: runaway loop modprobe binfmt-464c

Oh, depressed !!! But the problem is finally solved. Thank you! To be honest, I am very depressed about this problem!

 

(2) when loading the root file system:

Warning: Unable to open initial
Console

 

Solution:

CD/dev

Mknod console C 5 1





 


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.