Chinaunix首页 | 论坛 | 博客
  • 博客访问: 8038
  • 博文数量: 4
  • 博客积分: 170
  • 博客等级: 入伍新兵
  • 技术积分: 50
  • 用 户 组: 普通用户
  • 注册时间: 2008-12-04 21:00
文章分类

全部博文(4)

文章存档

2009年(4)

我的朋友
最近访客

分类: LINUX

2009-02-05 14:18:48

利用busybox1.1.3进行简单的文件系统的创建

主要参考的是《linux系统移植开发文档中的步骤》

我用的是NFS方式进行文件系统的挂载,所以首先要配置好主机上的nfs文件系统,然后将板子上的启动参数设置好。我的板子上是sbc2410bootloadervivi。编译环境是arm-linux-3.3.2

首先是构建根文件系统

#mkdir nfsd

#pwd

/home/bz/

#cd nfsd

#

nfsd中建立linux目录树

#mkdir bin dev etc home lib mnt proc sbin sys tmp root usr

#mkdir mnt/etc

#mkdir usr/bin usr/lib usr/sbin

#touch linuxrc

#tree

(其中的linuxrc是一个启动脚本,是一个shell脚本文件。对于简单的文件系统可以不用建立,因为在busybox生成的过程中会生成一个linuxrc文件将你生成的覆盖,但是系统能够正常的运行)

到目录当中,并且解压。

进入解压后的目录中,配置BUSYBOX

#make menuconfig

###############################################################
 Busybox Settings >
 General Configuration >
 [*] Support for devfs
 Build Options >
 [*] Build BusyBox as a static binary (no shared libs)
/*
busybox编译为静态连接,少了启动时找动态库的麻烦 */
 [*] Do you want to build BusyBox with a Cross Compiler?
 (/usr/local/arm/3.4.1/bin/arm-linux-)
(按下enter键修改)
 Cross Compiler prefix
/*
指定交叉编译工具路径 */
 Init Utilities >
 [*] init
 [*] Support reading an inittab file
/*
支持init读取/etc/inittab配置文件,一定要选上 */
 Shells >
 Choose your default shell (ash) >(
注意括号中的应该是ash,而不是none)
/* (X) ash
选中ash,这样生成的时候才会生成bin/sh文件
*
看看我们前头的linuxrc脚本的头一句:
* #!/bin/sh
是由bin/sh来解释执行的
*/
[*] ash
###################################################################################
另外,按照他的这种方法做出来的文件系统,运行的时候 shell 并不好有,没有历史记录、自动补全、删除字符的功能,下面介绍如何为它添加这些功能:
               Shells --->
---   Bourne Shell Options                                            
   [ ]   Hide message on interactive shell startup                    
   [ ]   Standalone shell                                             
   [*]   command line editing                                         
   [*]     vi-style line editing commands                            
      (15)    history size                                           
   [*]     history saving                                             
   [*]     tab completion                                             
   [*]       username completion                                     
   [ ]     Fancy shell prompts
###################################################################################

 Coreutils >
[*] cp
[*] cat
[*] ls
[*] mkdir
[*] echo (basic SuSv3 version taking no options)
[*] env
[*] mv
[*] pwd
[*] rm
[*] touch
Editors >
[*] vi
Linux System Utilities >
[*] mount
[*] umount

[*]support mounting NFS file system
[*] Support loopback mounts
[*] Support for the old /etc/mtab file
Networking Utilities >

[*]inetd

/*支持inetd 超级服务器

inetd的配置文件为/etc/inetd.conf文件*/
##########################################################
 Linux Module Utilities  ---> 
        

[*] insmod                  
       

[*] rmmod                                   
        

[*] lsmod                  
        

[*]   lsmod pretty output for 2.6.x Linux kernels                    
        

[*] modprobe                                            
       

[*]   Multiple options parsing              
                     ---   Options common to multiple modutils              
        

[*]   Support tainted module checking with new kernels            
       

[ ]   Support version 2.2.x to 2.4.x Linux kernels    //此项一定不要选!!!
       

[*]   Support version 2.6.x Linux kernels                                        

########################################################################

编译并且安装Busybox

#make TARGET_ARCH=arm CROSS=arm-linux- PREFIX=/home/bz/nfsd/ all install

PREFIX 指明安装的路径:就是我们根文件系统所在的路径。

(只要install busybox ,我们的根文件系统下先前建立好的linuxrc就会被覆盖为一个同名的二进制文件,所以事先备份好自己的linuxrc ,在安装完busybox之后,将linuxrc复制回去就好,这里就用它自己生成的linuxrc文件)。

下面在etc下创建目录init.d

cd init.d

创建脚本rcS

内容如下:

# /bin/sh

保存,并修改rcS的权限,否则会出现Cannot run ‘/etc/init.d/rcS’:Permission denied的错误:

chmod 775 rcS

etc目录下编写挂载表fstab

proc /proc proc defaults 0 0

sysfs /sys sysfs defaults  0 0

none /dev/pts devpts mod=0622 0 0

tmpfs /dev/shm tmpfs defaults 0 0

不用其他的配置或者文件,重启板子,这个系统就成功的挂载上了,这也算是一个比较最简单的文件系统了。如果想要增加功能可以在这个基础上进行。

阅读(679) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~