我用的是2.6.26版本linux,主机是Ubuntu 9.10 . 编译busybox 1.9.1版本 1、更改busybox1.9.1的Makefile ARCH ?=arm CROSS_COMPILE?= 自己的交叉编译环境的位置我的是: 2、make menuconfig
Busybox Setting-----> build option--> [ ] Build BusyBox as a static binary (no shared libs) [*] Build shared libbusybox [*] Produce a binary for each applet, linked against libbusybox [*] Produce additional busybox binary linked against libbusybox [ ] Build with Large File Support (for accessing files > 2 GB) installation option--> [*] Don't use /usr Applets links (as soft-links) ---> (./_install) BusyBox installation prefix Busybox Library Tuning ---> MD5: Trade Bytes for Speed [*] Faster /proc scanning code (+100 bytes) [*] Support for /etc/networks [*] Support for /etc/networks [*] Additional editing keys [*] vi-style line editing commands [*] History saving [*] Tab completion [*] Username completion [*] Fancy shell prompts Linux Module Utilities ---> [*] Support version 2.6.x Linux kernels [*] insmod [*] Enable load map (-m) option [*] Symbols in load map [*] rmmod [*] lsmod [*] lsmod pretty output for 2.6.x Linux kernels [*] modprobe [ ] Multiple options parsing [ ] Fancy alias parsing --- Options common to multiple modutils [ ] Support tainted module checking with new kernels [ ] Support version 2.2.x to 2.4.x Linux kernels [*] Support version 2.6.x Linux kernels 其他的用默认值 3、make install 开始安装 在busybox的根目录下生成_install文件夹,里面的东西有3项:bin sbin linuxrc 4、修改安装Busybox后的busybox文件属性,具体原因,随后再续。 chmod 4755 ./_install/bin/busybox 5、在自己的home目录中,建立rootfs目录 将_install的内容拷贝到rootfs目录中 6、在rootfs目录下,建立空目录: dev home proc tmp var boot etc lib mnt root sys usr 7、此时 rootfs目录下有如下内容: bin dev home linuxrc proc sbin tmp var boot etc lib mnt root sys usr 8、 以root身份建立节点文件/dev/console, /dev/null mknod -m 600 dev/console c 5 1 mknod -m 666 dev/null c 1 3 9、进入etc目录,建立profile文件,内容如下: #!/bin/sh #/etc/profile:system-wide .profile file for the Bourne shells echo echo -n "Processing /etc/profile......" # Set search library path export LD_LIBRARY_PATH=/lib:/usr/lib # set user path export PATH=/bin:/sbin:/usr/bin:/usr/sbin #Set PS1 USER = "`id -un`" LOGNAME=$USER PS1='[...@\h\w]\$' PATH=$PATH echo "Done!" 10、 在etc目录下建立init.d目录,然后在init.d目录下建立rcS文件 init.d/rcS内容: #!/bin/sh # set hostname, needed host file in /etc directory #./etc/host hostname `cat /etc/host` # mount all filesystem defined in "fstab" echo "#mount all......." /bin/mount -a #+/bin/chmod 0666 /dev/null echo "# starting mdev...." /bin/echo /sbin/mdev > /proc/sys/kernel/hotplug mdev -s /usr/etc/init echo "******************************************" echo " " echo " " echo " " echo "******************************************" 11、在etc目录下建立fstab文件 proc /proc proc defaults 0 0 none /tmp ramfs defaults 0 0 none /var ramfs defaults 0 0 mdev /dev ramfs defaults 0 0 sysfs /sys sysfs defaults 0 0 12、在etc目录下建立inittab文件 ::sysinit:/etc/init.d/rcS ::respawn:-/bin/sh tty2::askfirst:-/bin/sh ::ctrlaltdel:/bin/umount -a -r ::shutdown:/bin umount -a -r ::shutdown:/sbin/swapoff -a 13、在etc目录下建立空文件 mdev.conf 14、 复制主机/etc/下面的文件passwd, group, shadow文件到/etc [r...@centos etc]# cp /etc/group . [r...@centos etc]# cp /etc/passwd . [r...@centos etc]# cp /etc/shadow . 15、 因为是编译的时候使用的是动态链接。所以先看看~/busybox/_install/bin/busybox使用了哪些 lib,然后从glibc复制相应的lib到~/fsroot/lib中。 [r...@centos bin]# /usr/local/arm/3.4.1/arm-linux-gnu-readelf -d busybox Dynamic section at offset 0xb8014 contains 22 entries: Tag Type Name/Value 0x00000001 (NEEDED) Shared library:[libcrypt.so.1] 0x00000001 (NEEDED) Shared library: [libm.so.6] 0x00000001 (NEEDED) Shared library: [libc.so.6] 0x0000000c (INIT) 0xc04c 0x0000000d (FINI) 0xa26f0 0x00000004 (HASH) 0x80e8 0x00000005 (STRTAB) 0xa384 0x00000006 (SYMTAB) 0x8b24 …… …… …… 复制lib 文件到lib目录下: [r...@centos lib]cp /usr/local/arm/3.4.1/arm-linux/lib/ld* . [r...@centos lib]cp /usr/local/arm/3.4.1/arm-linux/lib/libc-2.3.2.so . [r...@centos lib]cp /usr/local/arm/3.4.1/arm-linux/lib/libc.so.6 . [r...@centos lib]cp /usr/local/arm/3.4.1/arm-linux/lib/libm * . [r...@centos lib]cp /usr/local/arm/3.4.1/arm-linux/lib/libcrypt* . 16、进入busybox根目录下,进入usr目录下,建立etc目录 在该etc目录下建立init文件 #!/bin/sh ifconfig eth0 192.168.1.111 up ifconfig lo 127.0.0.1 17、 mkcramfs fsroot fs_2.6.26_busybox.cramfs 18、利用之前编译好的zImage引导操作系统 回复邮件,或者到: http://www.tek-life.org/2010/04/22/%e5%88%b6%e4%bd%9cinitrd/ 中跟贴讨论,谢谢各位! -- To UNSUBSCRIBE, email to debian-chinese-gb-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org Archive: http://lists.debian.org/z2ic58e39921004211800w3b1c2675haa3cea03d2b02...@mail.gmail.com