BusyBox
A binary program that simulates the implementation of many programs.
/bin/busybox
To view native hardware device information:
#cat/proc/cpuinfo
#cat/proc/meminfo
#lsusb Displays the USB interface information.
#lspci displays all devices on the PCI bus.
#hal-device displays detailed information for all hardware.
Hardware abstract layer hardware abstraction.
Compile BusyBox:
#tar XF busybox.tar.bz2
#cd BusyBox
#make Menuconfig
Busybox Settings
Build Options
Build BusyBox as a static binary (no share libs) (NEW)
Installation Options ("Make Install" behavior)
You can specify the address generated by the. Install file.
#make Install
If make install error, this kernel version is missing some header files, need to download the updated kernel.
#tar XF linux-xxx.tar.bz2-c/usr/src
#cp-R/linux-xxx/include/mtd/ubi-user.h/root/busybox/include/mtd/
Use BusyBox to create the system kernel.
0. Mount the relevant equipment:
#mount/dev/sdb1/mnt/boot
#mount/dev/sdb2/mnt/sysroot
1. Compiling BusyBox
#tar XF busybox.tar.bz2
#cd BusyBox
#make Menuconfig
Busybox Settings
Build Options
Build BusyBox as a static binary (no share libs) (NEW)
Installation Options ("Make Install" behavior)
You can specify the address generated by the. Install file.
#make Install
3. Make INITRD file:
1. Copy the entire contents of the _install in the BusyBox directory:
#cp-A _install/tmp/busybox
#ls/tmp/busybox
Bin Linuxrc sbin usr
#rm LINUXRC
2. Create the appropriate directory:
#mkdir-P etc dev lib proc mnt/sysroot tmp
3. Copy the relevant libraries required by EXT3.
#cp/lib/modules/kernelversion/kernel/fs/jbd/jbd.ko/tmp/busybox/lib/modules/
#cp/lib/modules/kernelversion/kernel/fs/ext3/ext3.ko/tmp/busybox/lib/modules/
4. Create the init file.
#vim/tmp/busybox/etc/rc.d/init
#!/bin/sh
MOUNT-T proc Proc/proc
Mount-t Sysfs Sysfs/sys
Insmod/lib/modules/jbd.ko
Insmod/lib/modules/ext3.ko
Mdev-s
Mount-t Ext3/dev/sda2/mnt/sysroot
EXEC switch_root/mnt/sysroot/sbin/init
#chmod +x Init
5. Create 2 necessary device files.
#mknod/tmp/busybox/dev/console C 5 1
#mknod/tmp/busybox/dev/null C 1 3
6. Create the Initrd file:
#cd/tmp/busybox
#find. | Cpio-h newc-o--quiet |gzip-9>/mnt/boot/
Initrd.gz
4. Copy the Vmlinux file from the current system:
#cp/boot/vmlinux-xxx.el5/mnt/boot/vmlinux
5. Install Grub:
#grub-install--root-directory=/mnt/boot/dev/sdb
6. Create the grub.conf file:
#vim/mnt/boot/grub/grub.conf
Default=0
Timeout=3
Title=my Linux
Root (hd0,0)
Kernel/vmlinux ro root=/dev/hda2 Quiet
Initrd/initrd.gz
7. Create the relevant file system:
#cd BusyBox
#cp _inistall/mnt/sysroot
#cd/mnt/sysroot
#rm LINUXRC
#mkdir-pv lib/modules proc sys Dev ETC/RC.D/INIT.D root mnt media
#mkdir-PV root tmp home var/{log,run,lock/subsys,tmp} usr/{bin,sbin,local} opt boot
8. Create the Inittab file:
#cd/mnt/sysroot/etc
#vim Inittab
:: Sysinit:/etc/rc.d/rc.sysinit
Console::reapawn:-/bin/sh
:: Ctrlaltdel:/sbin/reboot
:: Shutdonw:/bin/umount-a-R
9. Create a Fstab file
#vim Fstab
Sysfs/sys Sysfs Defaults 0 0
PROC/PORC proc Defaults 0 0
/dev/hda1/boot ext3 defaults 0 0
/DEV/HDA2/EXT3 defaaults 1 1
10. Create the necessary device files:
#mknod/mnt/sysroot/dev/console C 5 1
#mknod/mnt/sysroot/dev/null C 1 3
11. Create the Initrd file:
#vim/mnt/sysroot/etc/rc.d/rc.sysinit
#!/bin/bash
Echo-e "\twelcom to \e33[34mmy linux\033[0m"
Echo-e "Remounting root ... [\033[32mok\033[0m] "
MOUNT-T proc Proc/proc
Mount-t Sysfs Sysfs/sys
Echo-e "Creating Files of device ... [\033[32mok\033[0m] "
Mdev-s
ECHO-E "Mounting the filesystem ... [\033[32mok\033[0m] "
Mount-a
Swapon-a
#chmod +x/mnt/sysroot/etc/rc.d/rc.sysinit
This article is from "Small Private blog" blog, please be sure to keep this source http://ggvylf.blog.51cto.com/784661/1615046
Creating a thin Linux kernel instance using BusyBox