打印
[嵌入式linux]

根文件系统。

[复制链接]
1523|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
leo1983|  楼主 | 2008-1-3 16:46 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我想建一个根文件系统,然后把这个跟文件系统放入 ramdisk,
我的开发板自带的 ramdisk解压,mount后是可以得到rootfs的,
但是我想自己做一个根文件系统,
不知道怎么做,?
一个根文件系统需要哪些内容?

相关帖子

沙发
leo1983|  楼主 | 2008-1-7 16:22 | 只看该作者

re

3.3 rootfs的制作  *
3.3.1 busybox 编译
我的编译器用的是2.95.3,在网上看见有说cross compile跟busybox的版本有匹配的问题。
刚开始我用的是 busybox-1.2.1.tar.bz2,发现编译有问题,后来改成了 busybox-1.1.1.tar.tar,可以编译了,
a. busybox1.1.1编译选项配置,安装
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/2.95.3/bin/arm-linux-)                     
                           Cross Compiler prefix                                      
                              /* 指定交叉编译工具路径 */                                 
              Init Utilities >                                                        
                        
  •  init                                                      
                        
  •  Support reading an inittab file                           
                             /* 支持init读取/etc/inittab配置文件,一定要选上 */           
              Shells >                                                                
                        Choose your default shell (ash) >                             
                            /* (X) ash 选中ash,这样生成的时候才会生成bin/sh文件           
                             * 看看我们前头的linuxrc脚本的头一句:                        
                             * #!/bin/sh 是由bin/sh来解释执行的*/                       
                        
  •  ash                                                       
              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                        
             Networking Utilities >                                                   
                        
  •  inetd                                                     
                           /* 支持inetd超级服务器inetd的配置文件为/etc/inetd.conf文件,    
                            * "在该部分的4: 相关配置文件的创建"一节会有说明*/  

    [arm@localhost busybox1.1.3]$make TARGET_ARCH=arm CROSS= /usr/local/arm/2.95.3/bin/arm-linux- /home/leo/busybox-1.1.1/_install all 
    [arm@localhost busybox1.1.3]$make install
    CROSS 为交叉编译器的路径。
    PREFIX指明安装路径:就是我们根文件系统所在路径。
    注:
    * 如果在编译的过程中出现错误,这可能是某些支持问题,可以在配置的时候把相关的选项去掉试试。
    * 如果出现找不到内核版本号的编译错误,可以有两种方法解决:(1)把你的内核源码中的version.h文件拷贝到交叉编译器的包含文件的linux目录下(该方法笔者试验成功);(2)该方法来源于论坛上面的一位朋友,做法为删掉#include <linux/version.h>换成#define UTS_RELEASE "2.4.27"  #define LINUX_VERSION_CODE 132123
    我试了1方法是可以的 2方法好像有点问题

    到这里我们就可以在默认的安装目录/home/leo/busybox-1.1.1/_install 下看到了
    bin  lib  linuxrc  sbin  usr 
    linuxrc  这个文件是一个链接,这个文件好像我们可以不要
    另外我们可以看到所有的这些命令其实都是一个链接
    [root@localhost bin]# ls -l
    total 632
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 ash -> busybox
    -rwxr-xr-x    1 root     root       642632 Apr 21 00:16 busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 cat -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 cp -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 dmesg -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 hostname -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 ls -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 mkdir -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 mknod -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 mount -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 mv -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 ps -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 pwd -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 rm -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 rmdir -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 touch -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 umount -> busybox
    lrwxrwxrwx    1 root     root            7 Apr 21 00:16 vi -> busybox

    b. etc/的文件的编写
    mkdir etc dev proc home root mnt var tmp
    dev文件夹:这个目录一定要建 ,没有这个目录我们的跟文件系统将无法mount。
    RAMDISK: Compressed image found at block 0
    Freeing initrd memory: 5859K
    VFS: Mounted root (ext2 filesystem).
    mount_devfs_fs(): unable to mount devfs, err: -2
    Freeing init memory: 52K
    Warning: unable to open an initial console.
    hub.c: USB new device connect on bus1/2, assigned device number 2
    usb.c: USB device not accepting new address=2 (error=-110)
    hub.c: USB new device connect on bus1/2, assigned device number 3
    usb.c: USB device not accepting new address=3 (error=-110)
    proc文件夹: 没有这个文件夹我们的proc文件系统将无法实现,lsmod这些命令就不能用
    etc文件夹是许多系统配置文件保存的地方。这些文件非常重要,如果配置错误,就可能影响系统的启动。busybox源代码example/bootfloopy/etc目录中的文件算是一个简单的例子,可以把其中的文件拷贝过来作为基础。(在example/bootfloopy目录中的一些脚本和文档也很值得阅读)
    cd /home/leo/busybox-1.1.1/examples/bootfloppy/etc
    这个目录下面有 fstab  init.d  inittab  profile
    这里我们得到了inittab文件,这个文件很重要
    cp  -fr * /mnt/ramdisk/etc

    首先inittab文件是系统启动后所访问的第一个脚本文件,后续启动的文件都由它指定。
    我们看看里面的内容:
     这个文件调用下面的rcs。
     
    Inittab的内容
    [root@localhost etc]# less  inittab 
    ::sysinit:/etc/init.d/rcS
    ::respawn:-/bin/sh
    tty2::askfirst:-/bin/sh
    ::ctrlaltdel:/bin/umount -a -r
    rcS的内容:
    [root@localhost etc]# cd init.d/
    [root@localhost init.d]# less rcS 
    #! /bin/sh

    /bin/mount -a

    到这里为止,我们的文件系统就可以用了,
    由于这里只是一个最简单的文件系统,我们是要在这个基础上修改的。
  • 使用特权

    评论回复
    发新帖 我要提问
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    23

    主题

    56

    帖子

    1

    粉丝