问题:

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. 机器学习学习笔记之一:K最近邻算法(KNN)

    算法 假定数据有M个特征,则这些数据相当于在M维空间内的点 \[X = \begin{pmatrix} x_{11} & x_{12} & ... & x_{1M} \\ x_ ...

  2. SQL语言 之 数据查询

    在Oracle 数据库中,SELECT 语句的基本语法为: SELECT [ALL|DISTINCT] column_name [,expression...] FROM table1_name [, ...

  3. Oracle的操作系统身份认证

    Oracle的操作系统身份认证 oraclelogin数据库远程登录authenticationos sqlnet.authentication_services=(NTS),在$ORACLE_HOM ...

  4. Linux系统登录:本地登录与远程登录

    安装登录系统的位置可以将登录方式分为两种:本地登录和远程登录.本地登录可以使用图形界面和命令行模式(也称字符界面)两种方式:远程登录可以使用SSH.Telnent.VNC.SFTP 4种方式. 常见的 ...

  5. Google开源单元測试框架Google Test:VS2012 配置

    由题目可知,Google Test(简称gtest)是Google公布的一个开源C/C++測试框架,被应用于多个开源项目及Google内部项目中,包括Chrome浏览器.LLVM编译器架构.Proto ...

  6. NGUI Tutorial 4 ScrollView

    一.createScrollView 1.First, select the panel you want to be your scroll view and right-click anywher ...

  7. [Swift A] - Using Swift with Cocoa and Objective-C--Mix and Match

    Swift与Objective-C的兼容能力允许你在同一个工程中同时使用两种语言.你可以用这种叫做“mix and match”的特性来开发基于混合语言的应用.使用Swfit的最新特性--“mix a ...

  8. Hibernate4.2.21.Final创建入门的HelloHibernet工程

    1.在hibernate官网下载hibernate-release-4.2.21.Final.zip并解压 2.新建一个java project工程(HelloHibernet)(myeclipes) ...

  9. centos下 安装jdk

    JDK 1.7下载地址 http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html JDK ...

  10. STS(Spring Tool Suite)设置支持maven