[Linux驱动开发] 根文件系统制作

 

根文件系统制作

1下载busybox

Busybox下载地址:http://www.busybox.net/

 

解压 配置 编译busybox 

解压

terry@terry-virtual-machine:/opt/filesystem$ ls busybox-1.18.5.tar.bz2

busybox-1.18.5.tar.bz2

terry@terry-virtual-machine:/opt/filesystem$ sudo tar xvf busybox-1.18.5.tar.bz2

terry@terry-virtual-machine:/opt/filesystem$ ls

busybox-1.18.5  busybox-1.18.5.tar.bz2

配置  

进入busybo-1.18.5目录  make menuconfig

进入Busybox Settings --->

进入Build Configuration -->

配置Cross Compiler prefix

为开发板设置编译器前缀 arm-linux-gnu-

保存后

编译 make  

发现错误 :

改错:把ionice去掉

怎样去掉呢?

在make menuconfig中:/ionice,寻找ionice

发现ioniceLocations:--> Miscellaneous Utilities

退回主菜单页面Busybox Configuration寻找Miscellaneous Utilities

去掉ionice选项

修改networking/libiproute/ipaddress.c

vi networking/libiproute/ipaddress.c

把下面这个

改成下面这个

再编译 make   结果通过

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5$ make install

得到目录_install

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5$ mkdir first_fs

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5$ cp _install/* first_fs/ -rf

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5$ cd first_fs/

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5/first_fs$ mkdir etc

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5/first_fs$ vi etc/inittab

bosyboxinit进程会展开/etc/inittab,根据打开文件是设置来启动其他程序

busyboxinittab文件的格式: 
  <控制台>::<动作>:<要启动的脚步或程序> 

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5/first_fs/etc$ mkdir init.d

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5/first_fs/etc$ vi init.d/rcS

给有需要的文件rcS加执行权限

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5/first_fs$ mkdir lib

从交叉编译工具链下面复制库:

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5/first_fs$cp/opt/toolchains/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux-gnu/arm-linux-gnu/lib/*so* ./lib/ -d

完善文件系统:

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5/first_fs$ mkdir sys

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5/first_fs$ mkdir proc

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5/first_fs$ mkdir dev

/dev目录下面创建console文件

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5/first_fs$ sudo mknod dev/console c 5 1

从网络文件nfs挂载根文件系统:

系统启动时,在挂载文件系统前,修改u-boot的参数(这里的u-boot是之前已经做好的,我们所需要的仅仅是在u-boot启动后要加载文件系统时,重新设定u-boot加载的文件系统路径,即,将我们刚刚做好的first_fs文件路径加载到u-boot加载文件的路径当中)

set bootargs root=nfs nfsroot=192.168.7.153:/opt/filesystem/busybox-1.18.5/first_fs console=ttySAC0,115200 ip=192.168.7.253

然后,boot,这样u-boot就会到指定的文件路径中去加载文件系统

这样,最简单的网络挂载根文件系统成功

另外,这里需要特别注意的是,每当我们创建一个文件系统之后,我们需要将这个文件系统放到export中,这样系统才能够识别并加载这个文件系统

具体方法是:sudo vi /etc/exports,添加自己的文件系统

这样的文件系统可以添加很多,但是每次添加之后不要忘记重启:

sudo /etc/init.d/nfs-kernel-server restart

sudo exportfs -a

这里我们还可以编写一个hello应用程序,交叉编译后,把它放到/opt/rootfs/usr/bin下面,并修改权限为777

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5/first_fs/etc/init.d$ vi rc.local

/usr/bin/hello &

terry@terry-virtual-machine:/opt/filesystem/busybox-1.18.5/first_fs/etc$ vi init.d/rcS

系统启动后就会自动执行hello程序


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值