Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3309488
  • 博文数量: 754
  • 博客积分: 10132
  • 博客等级: 上将
  • 技术积分: 7780
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-14 23:36
文章分类

全部博文(754)

文章存档

2012年(3)

2011年(39)

2010年(66)

2009年(167)

2008年(479)

我的朋友

分类: LINUX

2009-02-10 16:42:43

请教两个根文件系统mount的问题

我的配置
CONFIG_BLK_DEV_INITRD=y
CONFIG_INITRAMFS_SOURCE="../rootfs.cpio"

我的系统启动总是提示找不到根文件系统

现在有几个问题想请教一下
1. kernel_init的最后一段是

do_basic_setup();

        /*
         * check if there is an early userspace init.  If yes, let it do all
         * the work
         */

        if (!ramdisk_execute_command)
                ramdisk_execute_command = "/init";

        if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {//问题1 这里的“/”不还是ULK3上说的rootfs吗?怎么可能会存在init

                ramdisk_execute_command = NULL;
                prepare_namespace(); //我的系统肯定到这里来了
        }

        /*
         * Ok, we have completed the initial bootup, and
         * we're essentially up and running. Get rid of the
         * initmem segments and start the user-mode stuff..
         */
        init_post();
        return 0;



接着是prepare_namespace里的代码
...
if (initrd_load())
                goto out;
...
initrd_load 是这样的

if (mount_initrd) {
                create_dev("/dev/ram", Root_RAM0);
                /*
                 * Load the initrd data into /dev/ram0. Execute it as initrd
                 * unless /dev/ram0 is supposed to be our actual root device,
                 * in that case the ram disk is just set up here, and gets
                 * mounted in the normal path.
                 */
                if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) { // 我的root是ram0,所以下面3行代码不执行,prepare_namespace 继续执行(不goto out)
                        sys_unlink("/initrd.image");
                        handle_initrd();
                        return 1;
                }
        }
        sys_unlink("/initrd.image");
        return 0;

最后到了prepare_namespace的最后己行代码

mount_root();
out:
        sys_mount(".", "/", NULL, MS_MOVE, NULL);
        sys_chroot(".");
        security_sb_post_mountroot();

在mount_root中,有最后几行(就是mount_root失败了.VFS: could not mount root)

#ifdef CONFIG_BLOCK
        create_dev("/dev/root", ROOT_DEV);
        mount_block_root("/dev/root", root_mountflags);
#endif

   mount_block_root("/dev/root", root_mountflags); 这个函数会用所有的文件系统类型对/dev/root(cpio)进行mount
但是所有的文件系统类型都失败了,最后就是那个panic
问题二是,我这个文件系统是什么类型? 我不知道它是什么类型的,也找不到相关资料,就知道它和kernel被作成了bzImage

我的代码是2.6.23
grub:
kernel /bzImage root=ram0 rw
boot


CONFIG_INITRAMFS_SOURCE="../rootfs.cpio"

你在rootfs.cpio中自己指定init,如果是busybox做的rootfs,直接在根文件系统中ln -s bin/busybox init就可以

从你问你的问题看, 你是想使用cpio-initrd, 可是你把rootfs直接链接到kernel中,这是initramfs的用法

如果你想使用cpio-initrd,需要由boot loader initrd 文件加载到内存的特定位置

想使用initramfs,你可以指定CONFIG_INITRAMFS_SOURCE把它直接链接到kernel中。

[url]http://www.ibm.com/developerworks/cn/linux/l-k26initrd/index.html[/url]
[url][/url]

[[i] 本帖最后由 x4ulocca 于 2007-11-23 16:53 编辑 [/i]]

谢谢,前面来有段代码没看到,ULK也没怎么说rootfs,就是initramfs释放到rootfs,我的rootfs里没有/init 所以接着处理initrd,而我确没有,所以就vfs没有root了
建个链接就好了
谢谢

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