Introduction and production of Linux inird

Source: Internet
Author: User

Linux Kernel since 2.6 version, it is strongly recommended CPIO-INITRD.


Currently, initrd of major Linux releases are in the cpio format.

How to Make CPIO-INITRD.

First, let's assume that we have used busybox, klibc, or anything else to prepare the root file system ~ /Rootfs.

As mentioned in IBM developerworks, you can use the following command to make a CPIO-INITRD:

Cd ~ /Rootfs
Find. | cpio-c-o> ../initrd. img
Gzip ../initrd. img

In fact, this is not correct.

I use these commands to make a CPIO-INITRD and the results are all kernel panic.

Refer to the script code of the mkinitcpio command of my archlinux release, it should be to use gen_init_cpio command to make CPIO-INITRD.

The source code of the gen_init_cpio command is usually packaged together with the Linux kernel source code, which is located in the usr/directory of the kernel source code.

Compile the source code to obtain the gen_init_cpio executable file, which is not enough.

The parameter of gen_init_cpio is a text file whose content is similar to this format:

DIR/sbin 755 0 0
Slink/sbin/makedevs ../bin/busybox 777 0 0
Slink/sbin/modprobe ../bin/busybox 777 0 0
Slink/sbin/switch_root ../bin/busybox 777 0 0
Slink/sbin/sysctl ../bin/busybox 777 0 0
Slink/sbin/lsmod ../bin/busybox 777 0 0
Slink/sbin/Getty ../bin/busybox 777 0 0
Slink/sbin/ifconfig ../bin/busybox 777 0 0
......

Obviously, this is a file list.

It is unrealistic to manually create this file list. The usr/directory contains gen_initramfs_list.sh, which is used to automatically generate the file list.

Well, we can come up with the complete steps to generate a CPIO-INITRD:

Cd ~
Gen_initramfs_list.sh rootfs/> filelist
Gen_init_cpio filelist> rootfs. cpio
Gzip rootfs. cpio

The last rootfs.cpio.gz is our CPIO-INITRD.

Modify the following parameters in Bootloader:

Append initrd1_rootfs.cpio.gz ramdisk_size = 8192 VGA = 792

What are the results?

(Full text)

==============================================

The initrd. IMG In the 2.6 kernel adopts cpio compression and is no longer in the ext2 format used by the 2.4 kernel. 1. Decompress initrd ***. IMG:
# Cp/boot/initrd-***. IMG initrd.img.gz
# Gunzip initrd.img.gz
# Mkdir initrd
# Mv initrd. IMG initrd
# Cd initrd
# Cpio-ivmd <initrd. IMG 2. Modify initrd
Modify the unzipped initrd file system. 3. generate a new initrd
# Find. | cpio-o-h NEWC | gzip>/mnt/sda1/boot/initrd. img-2.6.18-4-686

(Note:-h newc is required; otherwise, the kernel will consider it as ramdisk rather than initramfs)

 

Reference link:

Linux initial RAM disk (initrd) Overview

Http://www.ibm.com/developerworks/cn/linux/l-initrd.html
Analysis of initrd mechanism in linux2.6 Kernel

Http://www.ibm.com/developerworks/cn/linux/l-k26initrd/index.html

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.