一. 主機環境
Red Hat Linux 9.0 gcc version 3.4.5
二. 用Busybox創建文件系統
1.解壓busybox-1.12.2.tar.bz2,路徑爲:
[root@localhost 2410-s]# pwd
/root/2410-s
[root@localhost 2410-s]# cp /mnt/hgfs/arm/rootfs/busybox-1.12.2.tar.bz2 ./
[root@localhost 2410-s]# tar -xjvf busybox-1.12.2.tar.bz2
[root@localhost 2410-s]# cd busybox-1.12.2
[root@localhost busybox-1.12.2]# vi Makefile
修改Makefile中的ARCH和CROSS_COMPILE與本機的路徑一致:
CROSS_COMPILE ?= arm-softfloat-linux-
。。。。。。。。。。。。。。。。。。。。。。。
ARCH ?= arm
2.編譯busybox。先make menuconfig,修改以下:
[root@localhost 2410-s]#make menuconfig
Busybox Settings --->
Build Options --->
[*] Build BusyBox as a static binary (no shared libs)
//直接編譯成靜態庫,省事點
() Cross Compiler prefix
/opt/crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux/bin/arm-softfloat-linux-與編譯文件Makefile裏保持一致,應該寫的一處就這行了
Installation Options --->
[ ] Don't use /usr
//使用usr目錄
Busybox Library Tuning --->
[*] Fancy shell prompts
//一定要選上,否則很多轉意字符無法識別
Shells --->
Choose your default shell (ash) --->
//這裏選擇shell爲ash,應該是默認選中的
--- ash
//把ash這檔的選項全部選上
Miscellaneous Utilities --->
[ ] inotifyd
//不選
保存退出直接
[root@localhost 2410-s]#make
[root@localhost busybox-1.12.2]# make install
執行make install安裝
安裝成功後在_install目錄下可以看到如下目錄:
[root@localhost busybox-1.12.2]# ls _install/
bin linuxrc sbin usr
[root@localhost busybox-1.12.2]#
3.用shell腳本創建根文件系統的目錄結構,並在想要建立根文件系統的地方運行此腳本。我的用root用戶登陸的,直接創建來了設備節點。
[root@localhost 2410-s]# mkdir root_stand
[root@localhost 2410-s]# cd root_stand/
[root@localhost root_stand]# pwd
/root/2410-s/root_stand
[root@localhost root_stand]# vi build_fs.sh
#!/bin/sh
echo "making rootdir"
mkdir rootfs
cd rootfs
echo "making dir:bin dev etc lib proc sbin sys usr"
mkdir bin dev etc lib proc sbin sys usr #8 dirs
mkdir usr/bin usr/lib usr/sbin lib/modules
#Don't use mknod, unless you run this Script as
mknod -m 600 dev/console c 5 1
mknod -m 666 dev/null c 1 3
echo "making dir:mnt tmp var"
mkdir mnt tmp var
chmod 1777 tmp
mkdir mnt/etc mnt/jiffs2 mnt/yaffs mnt/data mnt/temp
mkdir var/lib var/lock var/log var/run var/tmp
chmod 1777 var/tmp
echo "making dir:home root boot"
mkdir home root boot
echo "done
執行這個sh:
[root@localhost root_stand]# sh build_fs.sh
創建出一個主文件夾rootfs,裏面有一批文件:
[root@localhost root_stand]# cd rootfs/
[root@localhost rootfs]# ls
bin boot dev etc home lib mnt proc root sbin sys tmp usr var
[root@localhost rootfs]#
[root@localhost rootfs]# cd etc/
[root@localhost etc]# ls
[root@localhost etc]# cp -a /root/2410-s/busybox-1.12.2/examples/bootfloppy/etc/* ./[root@localhost etc]# ls
fstab init.d inittab profile
[root@localhost etc]#