Article Title: proficient in building initramfs stepbystep (9 ). 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.
27. Directly compile the cpio package file into the kernel
If we have an init ramfs in the cpio format, we can directly compile it into the kernel during kernel compilation. Recall the content in section 1. Enter the directory path for building the init ramfs under the init ramfs sources configuration item in the Kernel configuration parameters. In fact, we can also directly output the ready-made init ramfs file name, so that during kernel compilation, We can compile it into the kernel.
Note the following two points when using this method:
(1) cpio files cannot be compressed. Cpio files used as initrd are compressed. Therefore, you must decompress the compressed files before compiling.
(2) The suffix of the cpio file must be. cpio. The kernel is compiled. the extension of cpio to identify this file as a cpio package file, while the extension of other files will be considered as a description file built by init ramfs (the description file is described in detail below ).
. Build init ramfs with the description file
The third way to build init ramfs using the kernel compilation tool is to use the description file. Under the init ramfs sources configuration item in the Kernel configuration parameter, you can enter the name of the init ramfs build description file. The kernel compilation tool builds the init ramfs according to the description file.
The syntax format of the description file is described as follows:
Example:
We use the description file to construct the init ramfs of hello world in section 1.
Hello-init.desp:
Dir/dev 0755 0 0
Nod/dev/console 0600 0 0 c 5 1
File/init/home/wyk/init ramfs-test/hello_static 0755 0 0
Specify the description file hello-init.desp In the Kernel configuration item init ramfs sources, the init ramfs of hello world will be generated during kernel compilation, the running effect is exactly the same as that of the init ramfs built by using the method of specifying the build directory in section 1.
Note: In the kernel help file, the init ramfs sources configuration item can specify multiple directories or description files. The kernel will collect these directories or files to generate an init ramfs. However, in my experiment, init ramfs sources only accepts a single directory name or file name, and outputs multiple directory names or file names (separated by spaces), causing an error during kernel compilation. Maybe my method is incorrect. I hope readers can correct me.