Booting from the Initramfs root file system Linux__linux

Source: Internet
Author: User
Origin:http://blog.chinaunix.net/uid-26969690-id-3207803.html

Development environment: Fedora 9

Cross-compilation tool chain: ARM-LINUX-GCC 4.3.2 with Eabi
Embedded Linux kernel version: 2.6.29.4-friendlyarm. This article is based on the Config_mini2440_t35 kernel of the 2.6.29.4-friendlyarm version of the friendly arm. Other versions should be similar, for informational purposes only.
Development Board: mini2440-128m Nand Flash
bootloader:u-boot-2009.11


The main differences:
Step 2. Modify Kernel configuration options
Access to the kernel source directory linux-2.6.29 directory
#cp config_mini2440_t35. config
#make Menuconfig Arch=arm
To open the configuration menu and configure two options to start the system using RAMDisk, you need to configure only one configuration item:
General setup--> Select Initial RAM filesystem and RAM disk ... Item
The reason is simple, we are using Initramfs instead of RAMDisk, so we do not have to configure RAMDisk driver support items device Drivers-->block Devices-->ram block device support Item The corresponding default configuration options, such as the subsequent (4096) default RAM disk size Kbytes, are no longer present.

Another important difference between INITRAMFS technology and RAMDisk technology is that INITRAMFS does not simulate a disk in memory, so there is no ext2 driver support required for RAMDisk. Therefore, the ext2 filesystem support < > Second Extended FS Support option under the File Systems menu can be canceled.

Another important difference in this step is the need for general Setup-->initial RAM filesystem and RAM disk ... Item (/WORK/ROOTFS) Initramfs source file (s) fill in the root filesystem directory you want to make into INITRAMFS format, where I'm going to do the directory of the root file system is/work/rootfs.

Step 6: Make Initramfs root file system
h) Making Initramfs root file system mirroring
The steps to make a minimal system root file system are basically consistent with the previous steps for making the RAMDisk root file system, which only explains how the last step is different.
Because the first program that executes when the INITRAMFS root file system starts is init, not linuxrc, so the root file system we produced needs to add an init file, and the corresponding LINUXRC file is no longer needed.
Modify the root file system as follows
#cd/work/rootfs
#ln-S Bin/busybox Init
This creates a soft link init for BusyBox, which is the init file we want to create.

In addition, we use the GENEXT2FS tool when we make RAMDisk root file system mirroring, when we make Initramfs root file system mirroring, we do not need extra steps, but when you compile the Linux kernel, it is generated automatically. The automatically generated Initramfs root file system is mirrored in the USR directory of the Linux source tree. Named Initramfs_data.cpio.gz, it is a compressed file in GZ format.

This has the problem that when compiling a kernel that can use the Initramfs boot, its configuration options have a dependency on (/work/rootfs) Initramfs source file (s) Fill in the root file system directory you want to make into INITRAMFS format. This requires us to compile the kernel, first the root file system to do a good job. It's important to note that the kernel image we created in this way is actually a lot bigger than it was, because when we do this, we actually merge the Initramfs root file system directly into the kernel image. In this way, the mirror of a single will no longer need to burn the root file system image alone, accordingly, the parameter that starts the kernel does not need to add initrd= ... To specify the location of the Initramfs. Of course if you don't want to merge Initramfs into the kernel, start the system directly with the RAMDisk kernel, but you'll have to use initrd= ... To specify the location of the Initramfs, and the second parameter Initramfs the size of the root file system image must be specified as the actual size, otherwise prompting for an image checksum error and unable to start the system.

The rest is no different.

-------------------------------------------------------------------
All the work is done, uimage and initramfs_data.cpio.gz have been compiled.
Using u-boot to download kernel mirrors and Initramfs root file system mirroring, start the system at this time, the final kernel panic kernel panic startup failed.
The following error appears on the last line of HyperTerminal:
Unpacking Initramfs...<0>kernel Panic-not Syncing:bad gzip Magic Numbers

Check the relevant errors on the Internet, the solution is as follows:
"This problem has been settled;


is because, I pass to the kernel in the U-boot initrd=bufptr,size;
The size of this parameter is larger than the actual INITRAMFS size;
Cause unpack_to_rootfs in the call Gunzip Initramfs compression package for decompression, gunzip can not determine the end of the Initramfs compressed packet address; (Gunzip this dongdong really not intelligent ah, hehe)

The size setting is consistent with the INITRAMFS compression package, OK;

The system starts successfully.

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.