1.新建根目录
mkdir rootfs
2.建立根目录下的子目录
cd rootfs mkdir bin dev etclib proc sbin sys usr mnt tmp var mkdir usr/binusr/lib usr/sbin lib/modules
3.创建设备文件
cd /dev mknod -m 666 consolec 5 1 mknod -m 666 nullc 1 3
改变执行权限
chmod 777 *
3.配置etc目录下文件及文件夹,必须对以下文件及文件夹都用chmod 777 *修改权限
新建group文件
内容如下:
root:*:0: daemon:*:1: bin:*:2: sys:*:3: adm:*:4: tty:*:5: disk:*:6: lp:*:7:lp mail:*:8: news:*:9: uucp:*:10: proxy:*:13: kmem:*:15: dialout:*:20: fax:*:21: voice:*:22: cdrom:*:24: floppy:*:25: tape:*:26: sudo:*:27: audio:*:29: ppp:x:99: 500:x:500:plg 501:x:501:fa
新建inittab文件
内容如下:
# /etc/inittab ::sysinit:/etc/init.d/rcS console::askfirst:-/bin/sh ::ctrlaltdel:/sbin/reboot ::shutdown:/bin/umount -a –r
新建passwd文件
内容如下:
root::0:0:root:/:/bin/sh ftp::14:15:FTP User:/var/ftp: bin:*:1:1:bin:/bin: daemon:*:2:2:daemon:/sbin: nobody:*:99:99:Nobody:/: jacob::502:502:Linux User,,,:/home/jacob:/bin/sh
新建fstab系统挂载文件系统列表文件
内容如下:
# device mount-point type options dump fsck order none /proc proc defaults 0 0 none /dev/pts devpts mode=0622 0 0 tmpfs /dev/shm tmpfs defaults 0 0
新建init.d/rcS:系统启动加载项,内容如下:
#!/bin/sh PATH=/sbin:/bin:/usr/sbin:/usr/bin runlevel=S prevlevel=N umask 022 export PATHrunlevel prevlevel # # Trap CTRL-C &c only in this shell so wecan interrupt subprocesses. # /bin/mount -t procnone /proc /bin/mount -ttmpfs none /tmp /bin/mount -ttmpfs none /var /bin/mkdir -p/var/log /bin/hostname -F/etc/sysconfig/HOSTNAME
新建sysconfig/HOSTNAME文件
内容如下:
FL2440
mkdir profile文件
内容如下:
#Ash profile #vim: syntax=sh #No core files by default #ulimit -S -c 0 > /dev/null 2>&1 USER="'id -un'" LOGNAME=$USER PS1='[FL2440]#' PATH=$PATH:/usr/local/bin LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib HOSTNAME='/bin/hostname' export USER LOGNAME PS1 PATH LD_LIBRARY_PATH
新建resolv.conf文件,内容如下:
nameserver 61.144.56.100
"home"目录:创建一个 jacob目录,与etc目录passwd文件中的jacob相对应
"lib"目录:这个里面放的都是库文件,由于我busybox是用静态链接,所以不用拷贝交叉编译器中库文件。
注意一个路径是这样的 /etc/init.d/rcS, rcS是文件
4.编译内核模块,内核配置如上。
进入内核根目录
make modulesARCH=arm CROSS_COMPILE=arm-linux-
5.安装内核模块
makemodules_install ARCH=arm INSTALL_MOD_PATH=/xxx/rootfs
6.配置busybox(在busybox源代码中)
进入busybox目录执行
make menuconfig
Busybox Settings---> General Configuration ---> Buffer allocation policy (Allocatewith Malloc) ---> [*] Show verbose applet usage messages [*] Support --install [-s] to installapplet links at runtime [*] Enable locale support (system needslocale for this to work) [*] Support for devfs [*] Use the devpts filesystem forUnix98 PTYs [*] Runtime SUID/SGID configuration via/etc/busybox.conf [*] Suppress warning message if/etc/busybox.conf is not readable (/proc/self/exe) Path to BusyBox executable Build Options ---> [*] Build BusyBox as a static binary(no shared libs) //选中"Build busybox as a static binary",静态链接 [*] Build with Large File Support (foraccessing files > 2 GB) [*]Do you want to build BusyBoxwith a Cross Compiler? (arm-linux-) cross Compiler prefix // 填写交叉编译前缀 Installation Options ---> [ *] Don't use /usr //选中“Don'tuse /usr”,选中该项可以避免busybox被安装到宿主系统的/usr目录下,破坏宿主系统 Applets links (as soft-links)---> (/xxxx/rootfs) BusyBox installationprefix //填写你的安装路径 Busybox Library Tuning ---> (2) MD5: Trade Bytes for Speed Linux ModuleUtilities ---> (/lib/modules) Default directory containingmodules (modules.dep) Default name of modules.dep [*] insmod [*] rmmod [*] lsmod [*]lsmodpretty output for 2.6.x Linux kernels [*] modprobe [*] Multipleoptions parsing --- Options common to multiple modutils [*] Support tainted module checking withnew kernels [*] Support version 2.6.x Linux kernels
7.编译,安装busybox
make arch=ARMCROSS COMPILE=arm-linux- make install
在sbin中看init检查busybox安装成功与否
Yaffs2文件系统制作工具:
http://arm9download.cncncn.com/linux/mkyaffs2image.tgz
最后执行:
mkyaffs2image-128M rootfs rootfs.bin