Article Title: proficient in building initramfs stepbystep (3 ). 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.
7. What is busybox
Busybox is known as the Swiss army knife in Embedded Linux-small and fully functional. It integrates many common Linux commands into a single executable program. It can build a basic Linux system with only this executable program (busybox) and the Linux kernel. The busybox program is very small and contains only 750 KB of executable files. Busybox is fully modular and can easily add or delete commands contained in it during compilation.
Because of these features of busybox, it is widely used in LiveCD, Emergency Repair Disk, installation disk and other systems. We also build init ramfs based on it.
8. Configure, compile, and install busybox
(1) Go To The http://busybox.net to download the latest source code, unzip it.
(2) Use
Make menuconfig
Command to start the configuration interface configuration, configure the features of busybox, and select the command to be included in busybox (busybox is called applet );
You can also use
Make defconfig
Command to do the default configuration, including all the applet.
The other two configuration commands are:
Make allyesconfig -- maximum configuration
Make allnoconfig -- minimum configuration
Both the "make defconfig" and "make defconfig" commands can be used as the initial configuration of custom configurations, and then use the "make menuconfing" command for customized configuration.
For simplicity, we use make defconfig for default configuration.
(3) Use
Make
Command to compile the busybox software.
(4) use
Make CONFIG_PREFIX = <安装目录> Install
Command to install. If the value assignment of the CONFIG_PREFIX variable is omitted in the command line, the default value./_ install directory will be installed. CONFIG_PREFIX can be modified on the make menuconfig configuration page.
We use make CONFIG_PREFIX = ~ The/initramfs-test/image command installs busybox In the build directory of init ramfs.
(5) in the default configuration, busybox dynamically links to glibc, So copy the dynamic library it uses to the init ramfs build directory. Run the ldd command to check which dynamic library files and corresponding file paths are used in busybox, and copy them to the corresponding directory.
We need to copy the compiled busybox to the image/lib directory.
Ld-linux.so.2
Libc. so.6
Libcrypt. so.1
Libm. so.6
Dynamic library file.
9. create necessary directories and device files under the image
(1) create in the imgae directory
Proc, sys, etc, mnt
Four Directories
(2) hello world has created a console device file. We can use it again.
Mknod-m 600 dev/null c 1 3
Command to create another basic device file.
10. Experiment
The construction and preparation of busybox have been completed. Let's test it:
Use root user permission in the image directory --
(1) Use
Mount-vt proc = proc
Mount-vt sysfs = sys
Command to install the kernel Virtual File System
(2) Use
Mount-v-o bind/dev
Command to bind the/dev device file to image/dev
(3) Use
Chroot./bin/sh
Command to enter the busybox environment. If a shell command prompt is displayed, enter several commands to view the execution result. For example, enter the fdisk-l command to check whether the partition of the hard disk can be displayed.