嵌入式 BusyBox制作根文件系统

一、环境
Ubuntu 8.04
arm-linux-gcc 3.4.5
busybox-1.1.3

二、busybox制作文件系统
  1、下载busybox1.1.3(http://www.busybox.net/)并解压。
  2、进入解压后的目录,配置Busybox

  #make menuconfig

  Busybox Settings >

  General Configuration >
  [*] Support for devfs

  Init Utilities >
  [*] init
  [*] Support reading an inittab file
  [*]    Be _extra_ quiet onboot      
  [*]    Support running init from within an initrd (not initramfs)
   [*] poweroff, halt, andreboot
   [*] mesg

  Shells >

  Choose your default shell (ash) >
   (我开始就因为在这里没选上,结果就造成启动不起来 
  [*] ash

添加历史记录、自动补全、删除字符的功能:
   Shells --->
---   Bourne ShellOptions                                          
   []   Hide message on interactiveshellstartup                  
   []   Standaloneshell                                           
  [*]   command lineediting                                       
  [*]    vi-style line editingcommands                           
     (15)    historysize                                         
  [*]    historysaving                                           
  [*]    tabcompletion                                           
  [*]      usernamecompletion                                   
   []    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 loopback mounts
  [*] Support for the old /etc/mtab file

    LinuxModule Utilities  --->
    [*]insmod                
    [*]rmmod      
    [*]lsmod       
   [*]   lsmod pretty output for2.6.x Linuxkernels       
    [*]modprobe      
   [*]   Multiple optionsparsing             
                    ---   Options common to multiplemodutils       
   [*]   Support tainted modulechecking with newkernels      
    []   Support version 2.2.x to2.4.x Linuxkernels   //此项一定不要选!!!     
   [*]   Support version 2.6.x Linuxkernels                                      

   Networking Utilities >
    [*]ifconfig  
    [*]ping 

    Archival Utilities  --->
    [*] tar
    [*]    Enable archive creation (NEW)
    [*]    Enable -j option to handle .tar.bz2files   


   注:可根据需要自已选择命令。

   3、如果文件系统在2410上运行的话,不需要修改源码,如果在2440上运行,需要将busybox-1.1.3/init/init.c中的
两处
  close(0);
  close(1);
  close(2);
注释掉:
 
  //close(0);
  //close(1);
  //close(2);

 
 //close(0);
 //close(1);
 //close(2);
   4、编译并安装Busybox(1.1.3的Makefile里没有设置ARCH和CROSS内容,需要亲自在指令里写上,我是这么做的)

    #exportPATH=$PATH:usr/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux/bin
    #make TARGET_ARCH=arm CROSS="arm-linux-"
    #make install

   5、建立根文件系统结构
    #cd ~
    #mkdir rootfs
    #cd rootfs
    #mkdir bin dev etc lib proc sbin tmp usr var mnt
    #chmod 1777 tmp
    #mkdir usr/bin usr/lib usr/sbin
    #mkdir var/lib var/lock var/log var/run var/tmp
    #mkdir etc/init.d
    #chmod 1777 var/tmp
      把 busybox1.1.3/_install/目录下的所有文件copy过来覆盖rootfs文件夹里的空文件夹。

   lib里面还要拷入一些库文件,下面仅给出一些常用的库
    #cd rootfs/lib
    #cp -rfd/usr/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux/arm-linux/lib/ld*./
    #cp -rfd/usr/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux/arm-linux/lib/libc-2.3.6.so./
    #cp -rfd/usr/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux/arm-linux/lib/libc.so.6./
    #cp -rfd/usr/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux/arm-linux/lib/libm*./
    #cp -rfd/usr/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux/arm-linux/lib/libcrypt*./
      当然为了方便,可以将交叉编译的库全放进去,但是这样会增加文件系统的体积。
    #cp -rfd/usr/crosstool/gcc-3.4.5-glibc-2.3.6/arm-linux/arm-linux/lib/*./  (注意-d,保持库文件的链接关系)

   6、创建etc/init.d/rcS
#!/bin/sh
echo "running /etc/init.d/rcS"
echo "mount the /proc file system"
/bin/mount -t proc proc /proc

echo "mount tmpfs filesystem to /tmp"
/bin/mount -t tmpfs none /tmp

echo "mount ramfs filesystem to /var"
/bin/mount -t ramfs none /var

    然后修改权限:chmod 775 rcS

   7、创建etc/inittab
# This is run first except when booting
console::sysinit:/etc/init.d/rcS
# Start an "askfirst" shell on the console
#::askfirst:-/bin/bash
console::askfirst:-/bin/sh
# Stuff to do when restarting the init process
::restart:/sbin/init
# Stuff to do before rebooting
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
   注:需要将内核源码drivers/char/tty_io.c中所有的
noctty = 1改为noctty = 0

   8、再创建etc/fstab
none           /proc          proc    defaults0 0
none           /dev/pts       devpts mode="0622"      0 0
tmpfs          /dev/shm       tmpfs  defaults       0 0

   至此,根文件系统制作完毕。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值