问题:

1.目前busybox和bootstrap两种方案制作文件系统,哪种开发周期更短,更加简单?

2.如果需要在文件系统中添加某个package,要怎么做,如vim/udhcpd等?

转自http://blog.csdn.net/happy_stars_2016/article/details/52620577

定制根文件系统的方法很多,最常用的是使用BusyBox来构建。它能使用户迅速方便地建立一套相对完整、功能丰富的文件系统,其中包括大量常用的应用程序。它集成压缩了Linux的许多工具和命令。下面详细介绍有关BusyBox定制根文件系统。

一、系统环境:

1、操作系统:Ubuntu12.04

2、交叉编译工具:arm-linux-gcc4.4.3

3、busybox源码包:busybox-1.25.0.tar.bz2

二、制作rootfs

  • 建立rootfs目录

本人在/home/zxx下建立rootfs目录

#mkdir rootfs
#cd rootfs
#mkdir root home bin sbin etc dev usr lib tmp mnt sys proc //建立常用目录
#mkdir usr/lib usr/bin
#pwd
/home/zxx/rootfs
  • 解压源码包:

#tar -jxvf busybox-1.25..tar.bz2

  • 修改Makefile配置

进入busybox-1.25.0目录,修改Makefile文件如下:

ARCH ?= arm
CROSS_COMPILE ?= /usr/local/arm/4.4./bin/arm-linux- (与你自己主机的arm-linux-gcc安装目录一样)
  • 编译BusyBox

#make menuconfig

选择Busybox Settings--->Build Options--->,选择[*] Build Busybox as a static binary(no shared libs)

选择Busybox Settings ---> Installation Options --->BusyBox installation prefix(在里面输入BusyBox的安装目录,我是保存在/home/zxx/rootfs下)

Shells --->Choose your default shell (ash) --->  --- ash

保存并退出

  • 编译安装
#make
#make install
  • 把busybox源码目录下的etc的内容拷贝到rootfs目录下的etc下
# cd /home/zxx/rootfs/etc
# cp -a /home/zxx/Downloads/busybox-1.25./examples/bootfloppy/etc/* ./
  • 从本机拷贝passwd、shadow、group文件
# cp /etc/passwd .
# cp /etc/shadow .
# cp /etc/group .

修改passwd文件,把第一行和最后一行的bash修改成ash。

  • 修改初始化文件inittab和fstab

# vim inittab

::sysinit:/etc/init.d/rcS
::respawn:-/bin/sh
::restart:/sbin/init 

tty2::askfirst:-/bin/sh

::ctrlaltdel:/bin/umount -a -r
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff –a

# vim fstab

proc /proc proc defaults
none /tmp ramfs defaults
mdev /dev ramfs defaults
sysfs /sys sysfs defaults
  • rootfs下lib的制作

将交叉编译环境下lib库拷贝到/rootfs/lib

#cd /home/zxx/rootfs/lib
#cp /usr/local/arm/4.4./arm-none-linux-gnueabi/sys-root/lib./

三、编译错误解决参考

  • make出现如下错误:
miscutils/nandwrite.c: In function 'nandwrite_main':
miscutils/nandwrite.c:: error: 'MTD_FILE_MODE_RAW' undeclared (first use in this?function)
miscutils/nandwrite.c:: error: (Each undeclared identifier is reported only once
miscutils/nandwrite.c:: error: for each function it appears in.)
scripts/Makefile.build:: recipe for target 'miscutils/nandwrite.o' failed
make[]: *** [miscutils/nandwrite.o] Error
Makefile:: recipe for target 'miscutils' failed
make: *** [miscutils] Error

解决办法

MTD_FILE_MODE_RAW在/usr/include/mtd/mtd-abi.h中定义。将/usr/include/mtd/mtd-abi.h拷贝到busybox的include文件中。

#gedit miscutils/nandwrite.c

修改头文件如下:

#include "libbb.h"
#include "mtd-abi.h"
#include <mtd/mtd-user.h>

编译可以通过。

  • 继续make,出现如下错误:
util-linux/blkdiscard.c: In function 'blkdiscard_main':
util-linux/blkdiscard.c:: error: 'BLKSECDISCARD' undeclared (first use in this function)
util-linux/blkdiscard.c:: error: (Each undeclared identifier is reported only once
util-linux/blkdiscard.c:: error: for each function it appears in.)
scripts/Makefile.build:: recipe for target 'util-linux/blkdiscard.o' failed
make[]: *** [util-linux/blkdiscard.o] Error
Makefile:: recipe for target 'util-linux' failed
make: *** [util-linux] Error

解决办法

BLKSECDISCARD在/usr/include/linux/fs.h中定义,方法如上所述,将/usr/include/linux/fs.h拷贝到busybox的include文件中linux下。

#gedit util-linux/blkdiscard.c

修改内容如下:

#include <linux/fs.h>

编译通过。

到这里rootfs基本上已经制作出来,有些内容需要的,可根据自己rootfs的需要进行自己增加。最后将rootfs目录制作成镜像后,就可以烧写到开发板上了。

[Busybox]Busybox制作文件系统的更多相关文章

  1. Busybox构建根文件系统和制作Ramdisk

      定制根文件系统的方法很多,最常用的是使用BusyBox来构建定制根文件系统.它集成压缩了Linux的许多工具和命令,可以使用户迅速方便地建立一套相对完整.功能丰富的文件系统,其中包括大量常用的应用 ...

  2. 使用busybox构建根文件系统

    当我们在Qemu上运行起来自己编译的内核之后,需要使用busybox构建一个文件系统,将此文件系统挂载上去就可以使用busybox提供的各种命令了. 1.编译安装busybox 源码下载地址:http ...

  3. buildroot制作文件系统

    /******************************************************************* * buildroot制作文件系统 * 使用buildroot ...

  4. [置顶] 从零制作文件系统到JZ2440,使其支持telnet , ftp 和tftp

    转自:http://mp.weixin.qq.com/s?__biz=MzAxNTAyOTczMw==&mid=2649328515&idx=1&sn=5849fba4b44e ...

  5. linux制作文件系统

    1.获取文件系统源码并解压 这里使用的源码是天嵌提供的“root_qtopia_2.2.0_2.6.30.4_20100601.tar.bz2” #tar xvf root_qtopia_2..0_2 ...

  6. Linux的VMWare中Centos7磁盘分区管理 fdisk分区和制作文件系统格式化和开机自动挂载

    一.硬盘的组成零件扇区 磁道 磁盘容量 磁盘分区 简介 硬盘由容量.柱面数.磁头数.扇区数 C/H/S, Cylinder, Head, Sector(柱面/磁头数/扇区数) 1.磁头数表示硬盘总共有 ...

  7. 韦东山笔记之用busybox构建根文件系统

    1 百度搜索busybox进入busybox官网(https://busybox.net/)作者:恒久力行 QQ:624668529  点击左侧DownloadSource下载最新稳定版的busybo ...

  8. 编译busybox-1.24.1 制作文件系统

    arm-linux-gcc  3.4.5 busybox-1.24.1.tar.bz21, 修改 Makefile找到以下2处修改为ARCH ?= armCROSS_COMPILE ?= arm-li ...

  9. 用bosybox制作文件系统

    在orangepi_sdk/source/busybox-1.25.0目录里有源码. ). 先清除编译出来的文件及配置文件 make distclean ). 配置busybox make menuc ...

随机推荐

  1. 一篇文章让你读懂Pivotal的GemFire家族产品

    一篇文章让你读懂Pivotal的GemFire家族产品 学习了:https://www.sohu.com/a/217157517_747818

  2. (转)Session URL重写

    Session URL重写 发表于 2012 年 3 月 5 日 Session URL重写,保证在客户端禁用或不支持COOKIE时,仍然可以使用Session session机制.session机制 ...

  3. Android程序怎么做单元测试

    如何进行Android单元测试 Menifest.xml中加入: <application>中加入: <uses-library android:name="android ...

  4. LoadRunner录制:事务

    背景 LoadRunner 会对事务的性能指标进行记录. 添加事务也是为了在测试的时候统计这段脚本运行时用的时间等等,方便定位性能瓶颈. 一个事务可以包含一个请求,也可以包含多个请求.一般把完成一件事 ...

  5. ARC下 does not support automated __weak references错误

    ARC下 does not support automated __weak references错误 此错误,通常是你的ARC下不支持weak 把你项目里面,weak的地方 改为 unsafe_un ...

  6. Flutter混合工程改造实践

    背景 6月下旬,我们首次尝试用Flutter开发AI拍app.开发的调研准备阶段没有参考业界实践,导致我们踩到一些填不上的坑.在这些坑中,最让我感到棘手的是Flutter和原生页面混合栈管理的问题. ...

  7. tomcat服务器开启gzip功能的方法

    http://blog.csdn.net/wang_159369/article/details/8107163 tomcat5.0以后的版本是支持对输出内容进行gzip格式的压缩的.该功能默认是关闭 ...

  8. poj 3311 Hie with the Pie dp+状压

    Hie with the Pie Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4671   Accepted: 2471 ...

  9. QtGui.QBrush

    The QtGui.QBrush is an elementary graphics object. It is used to paint the background of graphics sh ...

  10. 搭建web项目结合spring+cxf的webservice服务

    服务端: 服务端和客户端都需要引入包 antlr-2.7.7.jar aopalliance-1.0.jar asm-3.3.jar commons-collections-3.2.1.jar com ...