Initrd decompression and preparation

Source: Internet
Author: User

What is an initial RAM disk?
The initial RAM disk (initrd) is an initial root file system attached to the system before the actual root file system is available. Initrd is bound with the kernel and loaded as part of the kernel boot process. The kernel then loads the initrd file as part of its two-phase boot process, so that you can later use the real file system and mount the actual root file system.
Initrd contains the Directory and executable required to achieve this goal.ProgramFor example, the insmod tool used to load the kernel module to the kernel.
Initrd is a temporary file system in a desktop or Server Linux system. It has a short life cycle and can only serve as a bridge to the real file system. Initrd is a permanent root file system in an embedded system without storage devices.

Role of initrd

The purpose is to provide the most important core module required during the boot process so that the system can be successfully started.

 

View the contents of a initrd-xx-xx.img Virtual File System:

[Root @ localhost boot] #Ll initrd-2.6.18-194.el5.img

-RW ------- 1 Root 2629986 02-09 initrd-2.6.18-194.el5.img

[Root @ localhost boot] # cp initrd-2.6.18-194.el5.img/tmp/

[Root @ localhost boot] #PWD

/Boot

[Root @ localhost boot] #CD/tmp/

[Root @ localhost TMP] #Ls

Initrd-2.6.18-194.el5.img

[Root @ localhost TMP] #File initrd-2.6.18-194.el5.img

Initrd-2.6.18-194.el5.img: gzip compressed data, from UNIX, last modified: Thu Feb 9 09:52:35 2012, Max Compression

[Root @ localhost TMP] #MV initrd-2.6.18-194.el5.img initrd-2.6.18-194.el5.img.gz

[Root @ localhost TMP] #Gunzip initrd-2.6.18-194.el5.img.gz

[Root @ localhost TMP] #File initrd-2.6.18-194.el5.img

Initrd-2.6.18-194.el5.img: ascii cpi archive (svr4 with no CRC)

[Root @ localhost TMP] # mkdir initrd

[Root @ localhost TMP] #CD initrd

[Root @ localhost initrd] #Cpio-I <../initrd-2.6.18-194.el5.img

11762 Blocks

[Root @ localhost initrd] #Ls

Bin Dev etc init lib proc sbin sys sysroot

[Root @ localhost initrd] #Tree ../

../

| -- Initrd

| -- Bin

| -- Dmraid

| -- Insmod

| -- Kpartx

| -- Modprobe->/sbin/Nash

| '-- Nash

| -- Dev

| -- Console

| -- Mapper

------ Omitted ------

[Root @ localhost initrd] #

Or directly use the commandZcatInitrd-2.6.18-194.el5.img| Cpio-I

Create an initrd File

[Root @ localhost test] #Ls

[Root @ localhost test] #Mkinitrd initrd _ $ (uname-R)

// Mkinitrd [-V] [-- with = Module name] initrd file name core version

[Root @ localhost test] #Ls

Initrd_2.6.18-194.el5

[Root @ localhost test] #File initrd_2.6.18-194.el5

Initrd_2.6.18-194.el5: gzip compressed data, from UNIX, last modified: Sun Mar 25 19:49:36 2012, Max Compression

[Root @ localhost test] #Mkinitrd-V -- with = 8139too initrd _ $ (uname-R) _ test $ (uname-R) | grep 8139too

// Add module 8139, generate the initrd file, and then use it in Boot.

Looking for deps of module 8139too: MII

Using modules:/lib/modules/2.6.18-194. EL5/kernel/Drivers/USB/host/ehci-hcd.ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/USB/host/ohci-hcd.ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/USB/host/uhci-hcd.ko/lib/modules/2.6.18-194. EL5/kernel/fs/jbd. ko
/Lib/modules/2.6.18-194. EL5/kernel/fs/ext3/ext3.ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/SCSI/scsi_mod.ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/SCSI/sd_mod.ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/SCSI/scsi_transport_spi.ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/message/fusion/mptbase. ko
/Lib/modules/2.6.18-194. EL5/kernel/Drivers/message/fusion/mptscsih. ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/message/fusion/mptspi. ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/ATA/libata. ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/ATA/ata_piix.ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/MD/dm-mem-cache.ko
/Lib/modules/2.6.18-194. EL5/kernel/Drivers/MD/dm-mod.ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/MD/dm-log.ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/MD/dm-region_hash.ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/MD/dm-message.ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/MD/dm-raid45.ko
/Lib/modules/2.6.18-194. EL5/kernel/Drivers/NET/MII. Ko/lib/modules/2.6.18-194. EL5/kernel/Drivers/NET/8139too. Ko

Copy From '/lib/modules/2.6.18-194. EL5/kernel/Drivers/NET/8139too. ko '[elf32-i386] to'/tmp/initrd. md7411/lib/8139too. ko '[elf32-i386]

Adding module 8139too

[Root @ localhost test] #

Reference: http://www.ibm.com/developerworks/cn/linux/l-initrd.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.