教你如何制作根文件系統(tǒng)
1 創(chuàng)建目錄及設(shè)備文件
? mkdir rootfs
?cd rootfs
?mkdir bin dev etc lib proc sbin sys usr mnt tmp var
?mkdir usr/bin usr/sbin usr/lib lib/modules
?mknod -m 666 dev/console c 5 1
?mknod -m 666 dev/null c 1 3
?將上述命令寫到腳本文件create_rootfs_bash中
?修改該文件的屬性chmod +x create_rootfs_bash
?在rootfs的上一層執(zhí)行該腳本即可
2 建立動(dòng)態(tài)鏈接庫
?利用友善之臂提供的根文件包中的。
?cp -rfd .../root_qtopia/lib/*so* .../rootfs/lib/
?
3 編譯并安裝內(nèi)核模塊
?make modules ARCH=arm CROSS_COMPILE=arm-linux-
?make modules_install ARCH=arm INSTALL_MOD_PATH=/root/src/mini2440/rootfs
?
4 交叉編譯busybox
?tar -zxf busybox-1.13.3-mini2440.tgz
?cd busybox-1.13.3?
?4.1
??vi Makefile
??修改:?
??CROSS_COMPILE ?=arm-linux-?? //第164 行?
??ARCH ?=arm //第189 行
?4.2 make menuconfig 配置
??Makefile:422: *** Mixed implicit and normal rules. stop
??? Makefile:1270: *** Mixed implicit and normal rules. stop
??? 是make版本差異導(dǎo)致的
??? 把422行
??? config %config: scripts_basic outputmakefile FORCE
??????????? $(Q)mkdir -p include
??????????? $(Q)$(MAKE) $(build)=scripts/kconfig $@
??????????? $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
??改為
????? %config: scripts_basic outputmakefile FORCE
??????????????? $(Q)mkdir -p include
??????????????? $(Q)$(MAKE) $(build)=scripts/kconfig $@
??????????????? $(Q)$(MAKE) -C $(srctree) KBUILD_SRC= .kernelrelease
??把1270行
????? / %/: prepare scripts FORCE
??????????????? $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1)
??????????????? $(build)=$(build-dir)
??改為
????? %/: prepare scripts FORCE
??????????????? $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1)
??????????????? $(build)=$(build-dir)
??修改完畢后便可以進(jìn)行busybox的配置
??進(jìn)入busybox setting->
???build options->
??? ?選中build busybox as a static binary,靜態(tài)鏈接
??? ?cross compiler prefix(arm-linux-)
?? ?install options->
?? ??選中"Dont use/usr",避免busybox被安裝到宿主系統(tǒng)的/usr目錄下
?? ?Busybox Library Tuning->
?? ??選中Username completion和Fancy shell prompts,否則板子上的命令提示符不會(huì)變
?4.3 編譯busybox
??make
??如果出現(xiàn),networking/interface.c:818: error: `ARPHRD_INFINIBAND' undeclared here (not in a function)
??則可以:將networking/interface.c文件的818行修改為“.type = -1”,然后再次編譯
??
??make CONFIG_PREFIX=/root/src/mini2440/rootfs install
??如果成功,會(huì)出現(xiàn)如下信息:
??--------------------------------------------------
??You will probably need to make your busybox binary
??setuid root to ensure all configured applets will
??work properly.
??--------------------------------------------------
??在/root/src/mini2440/rootfs/sbin目錄下查看是否有init,如有則證明busybox安裝成功
??
5 建立etc 目錄下的配置文件
?5.1 在目錄etc下創(chuàng)建文件mdev.conf。
??我們可以通過文件mdev.conf自定義一些設(shè)備節(jié)點(diǎn)的名稱或鏈接來滿足特定的需要,但在此處讓它為空。
??#touch etc/mdev.conf?
?5.2 將主機(jī) etc 目錄下的passwd、group、shadow文件拷貝到 root_fs/etc目錄下
??#cp -f /etc/passwd /etc/group /etc/shadow etc
??5.2.1 /etc/passwd
???root:x:0:0:root:/root:/bin/bash
???bin:x:1:1:bin:/bin:/sbin/nologin
???daemon:x:2:2:daemon:/sbin:/sbin/nologin
???ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin
???nobody:x:99:99:Nobody:/:/sbin/nologin
??5.2.2 /etc/group
???root:x:0:root
???bin:x:1:root,bin,daemon
???daemon:x:2:root,bin,daemon
???ftp:x:50:
???nobody:x:99:
??5.2.3 /etc/shadow
???root:$6$hnswPTgxzFaZHlLl$WMMV0Av6O6c4RA4pwpVSgcKSiURhUlP5dxF3/MKEZlGzNXhoWMQeZA1rdf1z7VQbrrmOZe7YHw1rIQmAc8BNK/:14819:0:99999:7:::
???bin:*:14715:0:99999:7:::
???daemon:*:14715:0:99999:7:::
???ftp:*:14715:0:99999:7:::
???nobody:*:14715:0:99999:7:::
??
?5.3 將busybox,etc目錄下的所有文件拷貝過來
??cp -rf .../busybox-1.13.3/examples/bootfloppy/etc/* etc
??5.3.1 修改文件etc/inittab如下
???::sysinit:/etc/init.d/rcS?
???s3c2410_serial0::askfirst:-/bin/sh?????
???::ctrlaltdel:/sbin/reboot?
???::shutdown:/bin/umount -a –r
??5.3.2 修改文件etc/init.d/rcS如下:
???#! /bin/sh
???PATH=/sbin:/bin:/usr/sbin:/usr/bin
???runlevel=S
???prevlevel=N
???umask 022
???export PATH runlevel prevlevel
???/bin/hostname lhz
???echo "----------mount all----------"
???/bin/mount -a
???echo /sbin/mdev>/proc/sys/kernel/hotplug
???mdev -s
???echo "***************done********************"
??5.3.3 修改文件etc/fstab如下:
???#device??? mount-point???? type????? option???? dump?? fsck?? order
???proc????????? /proc??????? proc???? defaults??? 0??????? 0 ???
???none????????? /tmp??????? ramfs??? defaults??? 0??????? 0 ???
???sysfs???????? /sys????????? sysfs??? defaults??? 0??????? 0
???mdev????????? /dev??????? ramfs??? defaults??? 0??????? 0
??5.3.4 文件/etc/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='[u@h W]# '
???PATH=$PATH???
???HOSTNAME=`/bin/hostname`???
???export USER LOGNAME PS1 PATH
6 制作文件系統(tǒng)
7 啟動(dòng)內(nèi)核
?tftp 30008000 uImage
?bootm 30008000