问题:

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. [Python爬虫] 之五:Selenium 处理滚动条

     selenium并不是万能的,有时候页面上操作无法实现的,这时候就需要借助JS来完成了. 当页面上的元素超过一屏后,想操作屏幕下方的元素,是不能直接定位到,会报元素不可见的.这时候需要借助滚动条来拖 ...

  2. Vue组件开发实践之scopedSlot的传递

    收录待用,修改转载已取得腾讯云授权 导语 现今的前端开发都讲究模块化组件化,即把公共的交互和功能封装到一个个的组件之中,在开发整体界面的时候就能像搭积木一样快速清晰高效.在使用Vue开发我们的vhtm ...

  3. 转: Mac 使用ADT的问题

    http://blog.csdn.net/wwj_748/article/details/44806253

  4. 即将来到: CSS Feature Queries (CSS特性查询)

    Feature Queries 是CSS3 Conditional Rules specification中的一部分,它支持“@supports”规则,“@supports”规则可以用来测试浏览器是否 ...

  5. ASP服务器I I S出现authentication mode=Windows错误解决办法

    网上下载的asp.net源码出现 <authentication mode="Windows"/>错误信息 属性 说明 mode 必选的属性. 指定应用程序的默认身份验 ...

  6. ubuntu12.04下helloworld驱动从失败到成功过程

    最近在看linux的设备驱动程序,写一个简单的helloworld程序都花了我好久的时间,具体过程如下: 编写helloworld.c 编写Makefile 注意,makefile中的命令那里是一个t ...

  7. PHP Filter函数

    PHP Filter 函数 PHP Filter 简介 PHP 过滤器用于对来自非安全来源的数据(比如用户输入)进行验证和过滤. 安装 Filter 函数是 PHP 核心的组成部分.无需安装即可使用这 ...

  8. 查看物体A是否被相机B渲染

    using UnityEngine; using System.Collections; public class Test : MonoBehaviour { public GameObject a ...

  9. percona XTRADB Cluster 5.6在ubuntu安装

    installing-perconaXTRADB Cluster 5.6 in-ubuntu-13-10-wheezy First of all, I would recommend login as ...

  10. windows bat文件运行中文乱码

      windows bat文件运行中文乱码 CreationTime--2018年7月17日08点51分 Author:Marydon 1.情景展示 运行bat文件,里面的中文提示显示乱码 2.问题剖 ...