zoukankan      html  css  js  c++  java
  • 内核移植和文件系统制作(3)Ramdisk简介和常见问题

    一,Ramdisk简介:

    Ramdisk是一种基于内存的虚拟文件系统(并非一个实际的文件系统),它将一部分固定大小(这个大小在编译内核的make menuconfig时配置)的内存当作硬盘一个分区来使用。ramdisk是一种将实际的文件系统装入内存的机制,并且可以作为根文件系统,通常我们会使用ext2或ext3文件系统来格式化它。由于ramdisk是在内存中进行操作的,所以我们可以对里面的文件进行添加,修改,删除等等操作,但是一掉电,就什么也没有了。由于这个特性,我们可以将一些经常被访问而又不会更改的文件(如只读的根文件系统)通过Ramdisk放在内存中,这样可以明显地提高系统的性能。

    在Linux的启动阶段,内核和ramdisk都是由 bootloader在启动时加载至内存的指定位置,而initrd提供了一套机制,可以将内核映像和根文件系统一起载入内存。initrd 是boot loader initialized RAM disk,顾名思义是在系统初始化引导时候用的ramdisk,它的作用是完善内核的模块机制,让内核的初始化流程更具弹性。


    1,添加内核支持:

     General setup  ---> 

    [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support             
              ()    Initramfs source file(s)

     支持根文件的挂载,指定initrd,支持Ramdisk根文件系统



     Device Drivers  --->  

     [*] Block devices  --->   

    <*>   RAM block device support                                                  
              (1)     Default number of RAM disks                                            
                (4096) Default RAM disk size (kbytes) 

    添加对ramdisk的支持,修改(4096Default RAM disk size kbytes,这里就是要制作Ramdisk文件系统大小。当然如果你想制作8192KB大小的ramdisk,这里就要对应为8192了,以此类推。此项的默认配置就是(4096)。如这大小和你做的ramdisk不匹配,则启动时仍然会出现kernel panic内核恐慌,提示ramdisk格式不正确,挂载不上ramdisk



    File systems  --->

     <*> Second extended fs support

    [*]   Ext2 extended attributes                                                  
              [*]     Ext2 POSIX Access Control Lists                                        
                [*]     Ext2 Security Labels                                                    
                [*]   Ext2 execute in place support

    ramdisk是一种内存虚拟磁盘技术,实质上并不是一种文件系统,它使用的文件系统时ext2文件系统。所以一定要在make menuconfig时候进入File systems菜单,选上<*> Second extended fs support,以提供对ext2文件系统的驱动支持。


    二,常见问题解决(转载:http://blog.csdn.net/qiaoliang328/article/details/4724511

    1.

    Uncompressing Linux................................................................ donebootingthe kernel.

    问题在与传参,u-boot中传递:

    bootargs=console=ttyS0,115200 mem=64M rw loglevel=7

    我使用linux-3.8,在drivers/tty/serial/samsung.c中修改,FL2440有两个虚拟串口,ttyS0和ttyS1,由于在u-boot已经指定串口ttyS0,所以在linux内核设定需要保持一致 改:#define S3C24XX_SERIAL_NAME "ttyS"

     

    2. 启动参数 initrd=0x30800000,0x20000,0x30800000表示ramdisk在RAM中的地址,0x20000表示ramdisk的大小

     

    3. Failed to execute /linuxrc;Kernel panic No init fo...

    原因:initrd=0x30800000,0x20000; 0x20000小于ramdisk的实际大小

     

    4. RAMDISK: incomplete write (-28 != 32768) 4194304
    RAMDISK: ran out of compressed data
    invalid compressed format (err=1)
    Root-NFS: No NFS server available, giving up.
    VFS: Unable to mount root fs via NFS, trying floppy.
    VFS: Cannot open root device "" or unknown-block(2,0)
    Please append a correct "root=" boot option
    Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)

    出现上面情况,查阅资料才知道是因为没有修改
    Driver device ->
    Block device ->
    (4096)Default RAM disk size (kbytes)
    改4096为8192

     

    5.Error: unrecognized/unsupported machine ID (r1 = 0x33f60264).

    解决办法:参考我的CSDN博客

     

    6. Kernel panic - not syncing: Attempted to kill init!

    其中一个原因是内核不是用带eabi的的编译器编译的,而制作rootfs是的busybox使用带eabi的编译器编译的。

     

    7.编译busybox时可能遇到的问题

    将会遇到下面问题:
    applets
    /applets.c:20:2error: #warning Static linking against glibc produces buggy executables
    applets
    /applets.c:21:2: error: #warning (glibc does not cope well with ld --gc-sections).
    applets
    /applets.c:22:2error: #warning See sources.redhat.com/bugzilla/show_bug.cgi?id=3400
    applets
    /applets.c:23:2error: #warning Note that glibc is unsuitable for static linking anyway.
    applets
    /applets.c:24:2error: #warning If you still want to do it, remove -Wl,--gc-sections
    applets
    /applets.c:25:2error: #warning from top-level Makefile and remove this warning.
    make
    [1]: *** [applets/applets.oError 1

    这个警告的定义在applets/applets.c中。将这段警告注释掉就可以了。这段警告的意思是告诉你最好用uclibc编译,而不是用glibc因为glibc比较大,busybox在寸土寸金的嵌入式系统中运用比较多,所以会有这样的要求。






  • 相关阅读:
    JavaScript对象继承的实现
    Redis资料
    Difference between LINQ to SQL and the Entity Framework
    闭包,懂不懂由你,反正我是懂了
    Castle资料
    csu 1242 碱基配对
    csu 1242 碱基配对——一个错误的解答
    [转载]zoj 分类
    计算素数
    魔方阵
  • 原文地址:https://www.cnblogs.com/xiaoxing/p/3933599.html
Copyright © 2011-2022 走看看