Micro-system creation process based on BusyBox and Red Hat 2.6.38.5 Kernel

Source: Internet
Author: User

Prepare the Development tool "Development Tools" "Development Libraries" before compilation and production. If you have already introduced it before, Click here for more details; this experiment uses the vm9 Virtual Machine. Therefore, we recommend that you do not perform this operation too quickly and sync more frequently (remember)

Http://pan.baidu.com/share/link for all tools in the experiment? Consumer id = 569752 & uk = 487907638

See busybox-1.20.2.tar

First, compile the Red Hat Linux2.6.38.5 kernel.

Tar xf linux-2.6.38.5.tar.bz2-C/usr/src/
Create a link
Ln-SVS linux-2.6.38.5/linux
Configure the kernel to provide the./config file (a sample is provided here, named kernel-2.6.38.1-i686.cfg)
Cd linux
Directly rename this sample as./config
Music kernel-2.6.38.1-i686.cfg./config
Make menuconfig (configure the driver, file system, and network as needed. In this case, I directly made ext3 into the kernel module during configuration)
Start Compilation
Make SUBDIR = arch/
After the compilation is complete, a new kernel of the micro-system is provided (the compilation takes some time. The order here is only for ease of reading. When you perform your own operations, perform the following steps first, wait until the compilation is complete before copying the kernel)

Provide Kernel

Cp/usr/src/linux/arch/x86/boot/bzImage/mnt/boot/vmlinz

Prepare grub

Install grub:
Grub-install -- root-directory =/mnt // dev/hda
Configure grub. conf
Vim/mnt/boot/grub. conf
Default = 0
Timeout = 5
Title My Linux (2.6.18)
Root (hd0, 0)
Kernel/vmlinuz ro root =/dev/hda2
Initrd/initrd.gz

Provide initrd to compile and use Busybox

Preparation before Compilation
Tar xf busybox-1.20.2.tar.bz2-C/root/
Mkdir busybox-1.20.2/include/mtd
Cp/usr/src/linux/include/mtd/ubi-user.h busybox-1.20.2/include/mtd (copy the header file of the 2.6.38 kernel)
Compile busybox
Cd busybox-1.20.2
Make menuconfig (there is no need to change too much here. Just change the compilation option and compile it into a binary file for migration)
Make install
Cd _ install/(enter this directory after compilation)
Rm-rf linuxrc (delete the link file automatically created for us)
Mkdir/tmp/initrd (create a directory by yourself and copy the _ install file here. All configurations are changed here)
Cp busybox-1.20.2/_ install/*/tmp/initrd
Cd/tmp/initrd
Mkdir proc sys mnt/sysroot dev tmp lib/modules etc-pv (create basic directory)
Mknod dev/console c 5 1 (create a device file)
Mknod dev/null c 1 3
Create init script
Completed tasks:
1. Mount the proc file system. The proc file system is used to output the kernel image.
2. Mount the sys File System (output hardware information)
3. Import the kernel module and the ext3 kernel module; otherwise, the real file system cannot be accessed (the/dev/hda2 format is ext3 here. If it is formatted as ext2, do not install this module)
The script content is as follows:
#! /Bin/sh
#
Echo "mounting proc and sys ....."
Mount-t proc/proc
Mount-t sysfs/sys

Echo "Detect and export hardware infomation..." How to dynamically create a device file
Mdev-s

Echo "Mount real rootfs to/mnt/sysroot ....."
Mount-t ext3/dev/hda2/mnt/sysroot mount the real File System

Echo "Switch to real rootfs ....."
Exec switch_root/mnt/sysroot/sbin/init switch to the/mnt/sysroot root, and then run the/sbin/mnt/sysroot/init command under the/mnt/sysroot directory.
Chmod + x init
Archive compression to generate an initrd File
Find. | cpio-H newc -- quiet-o | gzip-9>/mnt/boot/initrd.gz

Remember to sync!

  • 1
  • 2
  • 3
  • Next Page

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.