使用busybox制作ramdisk记录点

在使用busybox制作ramdisk时参考学习了很多网络大神的文章,这里没法一一列出,本文只是将个人认为比较重要的几个点做个记录。

1.构建文件系统目录

ARCH=powerpc
CROSS_COMPILE=/opt/wr_ppc_chain/bin/powerpc-linux-gnu-
CONFIG_PREFIX=/work/fs_mini

step 1:busybox的编译

  
 make menuconfig ARCH=powerpc  CROSS_COMPILE=/opt/wr_ppc_chain/bin/powerpc-linux-gnu-  
    /*
    把busybox编译成静态链接的可执行文件,运行时独立其他函数库,否则运行时就依赖其他库文件。单独有内核时无法运行。
        busybox settings -> Build Options ->Build BusyBox as a static binary (no shared libs)
    */
    make ARCH=powerpc  CROSS_COMPILE=/opt/wr_ppc_chain/bin/powerpc-linux-gnu-
    make install ARCH=powerpc  CROSS_COMPILE=/opt/wr_ppc_chain/bin/powerpc-linux-gnu- CONFIG_PREFIX=/work/fs_mini


step 2:构建etc
    直接拷贝busybox根目录下/examples/bootfloppy/etc,根据需求修改inittab
step 3:构建dev
  
 mknod console c 5 1
 mknod null c 1 3


    如有需要
   
ln -sf /dev/null /dev/ttyS0


step 4:构建其他目录


 mkdir proc mnt tmp sys root
   
2.使用genext2fs制作镜像

   
genext2fs -b 8192 -d fs_mini ramdisk

    /*
    Usage: genext2fs [options] image
    Create an ext2 filesystem image from directories/files

      -x, --starting-image <image>
      -d, --root <directory>
      -D, --devtable <file>
      -b, --size-in-blocks <blocks>
      -i, --bytes-per-inode <bytes per inode>
      -N, --number-of-inodes <number of inodes>
      -m, --reserved-percentage <percentage of blocks to reserve>
      -g, --block-map <path>     Generate a block map file for this path.
      -e, --fill-value <value>   Fill unallocated blocks with value.
      -z, --allow-holes          Allow files with holes.
      -f, --faketime             Set filesystem timestamps to 0 (for testing).
      -q, --squash               Same as "-U -P".
      -U, --squash-uids          Squash owners making all files be owned by root.
      -P, --squash-perms         Squash permissions on all files.
      -h, --help
      -V, --version
      -v, --verbose
    */


3.使用u-boot中的mkimage工具打包
   
mkimage -n "RAMFS" -A powerpc -O linux -T ramdisk -C none -a 4000000 -e 4000040 -d ramdisk ramdisk.img
    /*
    Usage: ./mkimage -l image
          -l ==> list image header information
       ./mkimage [-x] -A arch -O os -T type -C comp -a addr -e ep -n name -d data_file[:data_file...] image
          -A ==> set architecture to 'arch'
          -O ==> set operating system to 'os'
          -T ==> set image type to 'type'
          -C ==> set compression type 'comp'
          -a ==> set load address to 'addr' (hex)
          -e ==> set entry point to 'ep' (hex)
          -n ==> set image name to 'name'
          -d ==> use image data from 'datafile'
          -x ==> set XIP (execute in place)
       ./mkimage [-D dtc_options] -f fit-image.its fit-image
    */


    
4.一个使用ramdisk的根文件系统的bootargs示例如下:
  要保证bootargs从u-boot传递到kernel中有效,在制作kernel时将该项留空。
 
bootargs root=/dev/ram rootfstype=ext2 init=/linuxrc console=ttyS0,115200 ramdisk_size=20480 mem=128M


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值