1.0 linux系统根文件系统的制作
/*制作根文件系统*/
1.解压
[root@bogon opt]# tar -xvf busybox-1.17.2-20101120.tgz
[root@bogon busybox-1.17.2]# vim Makefile //find . -name *.c
2.vim Makefile
修改164行 ?=arm-linux-
3.配置
[root@bogon busybox-1.17.2]# make defconfig //vim .config
//make menuconfig
4.编译busybox
[root@bogon busybox-1.17.2]# make
find . -name ls; cd ...//查看常用命令的路径
5.安装
[root@bogon busybox-1.17.2]# make install
//查看生成的lib库:
[root@bogon busybox-1.17.2]# cd _install/
[root@bogon _install]# ls
bin linuxrc sbin usr
6.拷贝_install里的所有到rootfs
[root@bogon rootfs]# cp /opt/busybox-1.17.2/_install/* . -a
[root@bogon rootfs]# ls
bin linuxrc readme.txt sbin usr
7.拷贝交叉编译工具的lib库到rootfs
[root@bogon /]# which arm-linux-gcc
/root/tools/4.5.1/bin/arm-linux-gcc //查看 which arm-linux-gcc
[root@bogon rootfs]# cp /root/tools/4.5.1/arm-none-linux-gnueabi/sys-root/lib/ . -a
[root@bogon rootfs]# ls
bin lib linuxrc readme.txt sbin usr
//cp /root/tools/4.5.1/arm-none-linux-gnueabi/sys-root/lib/ . -rf
8.添加其他目录
[root@bogon rootfs]# mkdir dev proc sys media mnt home opt root etc tmp var
[root@bogon rootfs]# ls
bin etc lib media opt readme.txt sbin tmp var
dev home linuxrc mnt proc root sys usr
9.拷贝inittab
[root@bogon rootfs]# cp /opt/inittab etc/
[root@bogon rootfs]# ls etc/
inittab
10.
[root@bogon etc]# mkdir init.d
[root@bogon etc]# cd init.d/
[root@bogon init.d]# vim rcS
添加rcS脚本:
#!/bin/sh
mount -t proc none /proc/
mount -t sysfs none /sys/ //none虚拟,占位
mdev -s //从/sys/提取驱动设备信息放到/dev目录下生成设备文件
!!!!!!!!!!!看inittab文件是否正确
[root@bogon etc]# cat inittab
::sysinit:/etc/init.d/rcS //sysinit : 系统初始化
//路径 : /etc/init.d
//rcS : 系统初始化的各种脚本
ttySAC0::askfirst:-/bin/sh
//ttySAC0 : 控制台指定的串口接收数据
//askfirst : 询问是哪个脚本
//-/bin/sh : 说明我们用的是什么shell
[root@bogon init.d]# chmod +x rcS //加权限
修改rootfs 的标头名:
[root@bogon etc]# ls
init.d inittab
[root@bogon etc]# vim profile
[root@bogon etc]# cat profile
PS1='[millet9527@\W]'
11.配置nfsroot目录的挂载权限
[root@bogon rootfs]# cat /etc/exports
/mnt/nfs 192.168.1.104/24(ro,sync,no_root_squash)
/mnt/share 192.168.1.104/24(rw,sync,no_root_squash)
#/nfsroot *(rw,sync,no_root_squash)
/rootfs *(rw,sync,no_root_squash)
// vim /etc/exports
写:/rootfs *(rw,sync,no_root_squash)
挂载的形式设置、测试:
在ARM开发板设置环境变量:
pri
set bootargs "root=/dev/nfs nfsroot=192.168.1.104:/rootfs ip=192.168.1.100 console=ttySAC0,115200 lcd=S70"
sav
TINY4412 # pri
baudrate=115200
bootargs=root=/dev/nfs nfsroot=192.168.1.104:/rootfs ip=192.168.1.100 console=ttySAC0,115200 lcd=S70
bootcmd=ext2load mmc 0:2 40008000 zImage;bootm 40008000
bootdelay=3
ethaddr=00:40:5c:26:0a:5b
gatewayip=192.168.1.1
ipaddr=192.168.1.100
netmask=255.255.255.0
serverip=192.168.1.104
可以重启开发板测试了...
1.怎么执行程序?for example:
PC端:
(1) /rootfs 编写 X.c 程序
(2) arm-linux-gcc X.c
开发板:
./a.out
/****************************************************************/
ls /rootfs/bin //放置需要自启动的二进制可执行程序
vim rcS //添加开发板要自启动的相应程序的路径
/*****************************************************************/
开发板端成功进入新制作的根文件系统:
[ 6.315000] link_reset() speed: 10 duplex: 0
[ 6.325000] IP-Config: Guessing netmask 255.255.255.0
[ 6.325000] IP-Config: Complete:
[ 6.325000] device=eth0, addr=192.168.1.100, mask=255.255.255.0, gw=255.255.255.255
[ 6.325000] host=192.168.1.100, domain=, nis-domain=(none)
[ 6.325000] bootserver=255.255.255.255, rootserver=192.168.1.104, rootpath=
[ 6.330000] hotplug_policy_init: intialised with policy : DVFS_NR_BASED_HOTPLUG
[ 6.335000] ALSA device list:
[ 6.340000] No soundcards found.
[ 6.815000] Link Status is: 0
[ 8.640000] Link Status is: 1
[ 8.645000] dm9620 1-2.4:1.0: eth0: link up, 100Mbps, full-duplex, lpa 0x4DE1
[ 8.650000] link_reset() speed: 10 duplex: 0
[ 11.935000] nf_conntrack: automatic helper assignment is deprecated and it will be removed soon. Use the iptables CT tar.
[ 46.570000] VFS: Mounted root (nfs filesystem) on device 0:10.
[ 46.570000] Freeing init memory: 584K
Please press Enter to activate this console.
[millet9527@/]ls
a.out home mnt root tmp
bin lib opt sbin usr
dev linuxrc proc sys var
etc media readme.txt test.c
[millet9527@/]./a.out
hello,this is my new root-system!
附录:
FHS 简介
Busybox 的编译
目录创建,设备文件的静态创建
lib 库的移植
rcS 脚本编写
inittab 脚本编写
浙公网安备 33010602011771号