定制根文件系统的方法很多,最常用的是使用BusyBox来构建。它能使用户迅速方便地建立一套相对完整、功能丰富的文件系统,其中包括大量常用的应用程序。它集成压缩了Linux的许多工具和命令。下面详细介绍有关BusyBox定制根文件系统。
busybox是linux上的一个应用程序,它整合了许多linux上常用等等工具和命令,官方网站是http://www.busybox.net,在这里你可以找到busybox相关的所有资料
一、系统环境:
1、操作系统:Ubuntu16.04
2、交叉编译工具:arm-linux-gcc4.4.3
3、busybox源码包:busybox-1.29.0.tar.bz2
二、制作rootfs:
1、建立rootfs目录
$ mkdir rootfs
$ cd rootfs
//建立常用目录
$ mkdir root home bin sbin etc dev usr lib tmp mnt sys proc
$ mkdir usr/lib usr/bin
2、下载并解压源码包
$tar -jxvf busybox-1.29.0.tar.bz2
3、制作BusyBox
3.1 make defconfig
busybox提供了几种配置:defconfig (缺省配置)、allyesconfig(最大配置)、 allnoconfig(最小配置),一般选择缺省配置即可。
这一步结束后,将生成.config
3.2 make menuconfig
这一步是可选的,当你认为上述配置中还有不尽如意的地方,可以通过这一步进行微调,加入或去除某些命令。
执行make menuconfig时可能出现如下错误
$ make menuconfig
HOSTCC scripts/kconfig/lxdialog/checklist.o
In file included from scripts/kconfig/lxdialog/checklist.c:24:0:
scripts/kconfig/lxdialog/dialog.h:31:20: fatal error: curses.h: 没有那个文件或目录
compilation terminated.
make[2]: *** [scripts/kconfig/lxdialog/checklist.o] 错误 1
make[1]: *** [menuconfig] 错误 2
make: *** [menuconfig] 错误
这是因为ubuntu系统中缺少一个套件 ncurses devel ,把此套件安装下即可
sudo apt-get install libncurses5-dev
3.3 编译busybox
$ make CROSS_COMPILE=/路径/arm-linux-
这一步就是根据.config,生成busybox,默认使用ubuntu的编译工具,当然你也可以指定其他的编译器, 如arm-linux-gnueabi-
3.4 安装busybox
$ make install
然后会在busybox目录下生成_install目录,然后将 _install/* 、examples/bootfloopy/etc/* 、编译工具链/lib/*(usr/lib/*) 拷贝到文件系统对应目录下