1)创建根文件系统的基本目录结构。
我把这个过程做成了shell脚本(文件名为mkroot) ,很方便!
#! /bin/sh
echo "creatint rootfs dir......"
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个目录
mkdir usr/bin usr/lib usr/sbin lib/modules
# Don't use mknod ,unless you run this Script as root !
# 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/jffs2 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"
在你想要建立根文件系统的地方,运行:
[root@localhost home]# ./mkroot
creatint rootfs dir......
making dir : bin dev etc lib proc sbin sys usr
making dir : mnt tmp var
making dir : home root boot
done
[root@localhost home]# cd rootfs/dev/
[root@localhost home]# mknod -m 600 console c 5 1;mknod -m 666 null c 1 3;exit
exit
2)配置、编译和安装Busybox-1.10.4
[root@localhost home]# tar -xjvf busybox-1.10.4.tar.bz2
修改Makefile文件: [root@localhost home]# pwd
/home/work/hzh1024n/source/busybox-1.9.0
[root@localhost busybox-1.9.0]$ vim Makefile
......(第174行附近)
#ARCH ?= $(SUBARCH)
#CROSS_COMPILE ?=
ARCH = arm
CROSS_COMPILE = /usr/local/arm/3.4.1/bin/arm-linux-
[root@localhost busybox-1.9.0]$ make menuconfig
在原有的基础上修改如下:
Busybox Settings --->
Installation Options --->
[*] Don't use /usr
(/home//rootfs) BusyBox installation prefix
Busybox Library Tuning --->
[*] Support for /etc/networks
[*] Additional editing keys
[*] vi-style line editing commands
(15) History size
[*] History saving
[*] Tab completion
[*] Username completion
[*] Fancy shell prompts
Linux Module Utilities --->
[N] Support version 2.2.x to 2.4.x Linux kernels
Shells --->
--- Ash Shell Options 下的选项全选
[root@localhost busybox-1.9.0]$ make
......
LINK busybox_unstripped
Trying libraries: crypt m
Library crypt is needed
Library m is needed
Final link with: crypt m
编译时的错误:
miscutils/taskset.c:17: error: parse error before '*' token
miscutils/taskset.c:18: warning: function declaration isn't a prototype
miscutils/taskset.c: In function `__from_cpuset':
miscutils/taskset.c:22: error: `CPU_SETSIZE' undeclared (first use in this function)
miscutils/taskset.c:22: error: (Each undeclared identifier is reported only once
miscutils/taskset.c:22: error: for each function it appears in.)
miscutils/taskset.c:26: warning: implicit declaration of function `CPU_ISSET'
miscutils/taskset.c:26: error: `mask' undeclared (first use in this function)
miscutils/taskset.c: In function `taskset_main':
miscutils/taskset.c:46: error: `cpu_set_t' undeclared (first use in this function)
miscutils/taskset.c:46: error: parse error before "mask"
miscutils/taskset.c:79: error: `mask' undeclared (first use in this function)
miscutils/taskset.c:97: error: `CPU_SETSIZE' undeclared (first use in this function)
miscutils/taskset.c:97: error: enumerator value for `CNT_BIT' not integer constant
miscutils/taskset.c:99: warning: implicit declaration of function `CPU_ZERO'
miscutils/taskset.c:103: warning: implicit declaration of function `CPU_SET'
make[1]: *** [miscutils/taskset.o] 错误 1
make: *** [miscutils] 错误 2
解决办法:
进入make menuconfig:
在 Miscellaneous Utilities --->
[ ] taskset
将其前的星号去掉即可。
[root@localhost busybox-1.9.0]$ make install
这样就基本上将busybox安装好了,下面是配置文件系统的相应文件夹和选项
-----------------------/lib文件--------------------------------
/lib的库其实就是进行busybox编译的库,即交叉编译器的库,我们这里使用的是3.4.1(位置/usr/local/arm/3.4.1)。
# cd /usr/local/arm/3.4.1/arm-linux/lib
# for file in libc libcrypt libdl libm libpthread libresolv libutil
> do
> cp $file-*.so /homerootfs/lib (复制到你做的文件系统的/lib目录下)
> cp -d $file.so.[*0-9] /homerootfs/lib > done
> cp -d ld*.so* /homerootfs/lib
-----------------系统配置文件的建立---------------------
--========/etc目录============
(1)profile文件
#Set search library path
#echo "Set search library path..........."
export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
#Set user path
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:$PATH
mknod /dev/ttyp5 c 3 5
mknod /dev/ptyp5 c 2 5
mknod /dev/buttons c 254 0
mknod /dev/tp c 250 0
mknod /dev/led c 253 0
export T_ROOT=/
export LD_LIBRARY_PATH=/lib
export TSLIB_CONSOLEDEVICE=none
export TSLIB_TSDEVICE=/dev/tp
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/plugins
#hwclock -s
(2)fstab文件
proc /proc proc defaults 0 0
none /tmp ramfs defaults 0 0
mdev /dev ramfs defaults 0 0
sysfs /sys sysfs defaults 0 0
(3)inittab文件
::sysinit:-/etc/init.d/rcS
::respawn:-/bin/sh
::ctrlaltdel:/bin/umount -a -r
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a
(4)创建/etc/init.d文件夹和rcS,在rcS中添加
#! /bin/sh
/bin/echo
/bin/echo "**********************************************"
/bin/echo " SEP4020 ARM Linux-2.6.16(VERSION4.0) "
/bin/echo " busybox1.10.4 "
/bin/echo "**********************************************"
echo "# mount all..........."
/bin/mount -a
echo "# Starting mdev........."
mdev -s
|
文件: |
busybox.rar |
大小: |
2KB |
下载: |
下载 | |
(5)host文件
QIU
(6)创建mdev.conf文件 (空文件)
(7)复制主机/etc/下面的文件passwd, group, shadow 文件到/etc
# cp /etc/group .
# cp /etc/passwd .
# cp /etc/shadow .
修改passwd中用户使用的shell名称。FC6上默认的为bash,而vivi只支持ash。
root:x:0:0:root:/root:/bin/bash -->root:x:0:0:root:/root:/bin/ash
(8)修改各文件和文件夹的权限
# chmod 755 /rootfs/etc/init.d/rcS
# chmod 755 /rootfs/etc/host
阅读(1227) | 评论(0) | 转发(0) |