一.背景

文件系统安装在sd卡的第一个分区中,使用的是ext4文件系统,linux内核版本为4.14

二.思考

在内核启动之前,uboot给内核传递了参数root=/dev/mmcblk0p1,但是为何还会出现:

VFS: Cannot open root device "mmcblk0p1" or unknown-block(179,1): error -19

Please append a correct "root=" boot option; here are the available partitions:

三.扒一扒内核代码

init/do_mouts.c

void __init mount_block_root(char *name, int flags)

{

...  retry:

  for (p = fs_names; *p; p += strlen(p)+1) {
  int err = do_mount_root(name, p, flags, root_mount_data);
  switch (err) {
    case 0:
      goto out;
    case -EACCES:
     case -EINVAL:
    continue;
  }
  /*
   * Allow the user to distinguish between failed sys_open
  * and bad superblock on root device.
   * and give them a list of the available devices
  */
  #ifdef CONFIG_BLOCK
  __bdevname(ROOT_DEV, b);
  #endif
   printk("VFS: Cannot open root device \"%s\" or %s: error %d\n",
   root_device_name, b, err);  此处的打印信息被输出
   printk("Please append a correct \"root=\" boot option; here are the available partitions:\n");此处的打印信息被输出
  
  printk_all_partitions();
  #ifdef CONFIG_DEBUG_BLOCK_EXT_DEVT
   printk("DEBUG_BLOCK_EXT_DEVT is enabled, you need to specify "
  "explicit textual name for \"root=\" boot option.\n");
  #endif
  panic("VFS: Unable to mount root fs on %s", b);  发生panic的地方在这里

...

}

static int __init do_mount_root(char *name, char *fs, int flags, void *data)

{

  struct super_block *s;
   int err = sys_mount(name, "/root", fs, flags, data);  此处返回的err是我们需要关心的,这里的err=-19,那么为何会等于-19呢?
  if (err)
  return err;
  
  sys_chdir("/root");
  s = current->fs->pwd.dentry->d_sb;
  ROOT_DEV = s->s_dev;
  printk(KERN_INFO
  "VFS: Mounted root (%s filesystem)%s on device %u:%u.\n",
   s->s_type->name,
  sb_rdonly(s) ? " readonly" : "",
  MAJOR(ROOT_DEV), MINOR(ROOT_DEV));
  return 0;

}

再分析sys_mount

fs/namespace.c

SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,char __user *, type, unsigned long, flags, void __user *, data)

{

...  

  ret = do_mount(kernel_dev, dir_name, kernel_type, flags, options);

...

}

long do_mount(const char *dev_name, const char __user *dir_name,const char *type_page, unsigned long flags, void *data_page)

{

...

retval = do_new_mount(&path, type_page, sb_flags, mnt_flags,dev_name, data_page);

...

}

/* * create a new mount for userspace and request it to be added into the

 * namespace's tree

*/

static int do_new_mount(struct path *path, const char *fstype, int sb_flags,

int mnt_flags, const char *name, void *data)

{

...

  type = get_fs_type(fstype);
  if (!type)
  return -ENODEV;

...

}

-ENODEV=-19

从最后的get_fs_type可以得知:当前不支持某种文件系统,进而type等于非0,因此就会返回-19这个值

四.解决

当前sd卡上的第一个分区装入的文件系统为ext4,然而内核此时并不支持此文件系统,因此加入CONFIG_EXT4_FS的配置项重新编译内核即可

linux kernel 提示VFS: Cannot open root device "mmcblk0p1" or unknown-block(179,1): error -19等信息后发生panic的更多相关文章

  1. 嵌入式 VFS: Cannot open root device "mtdblock2" or unknown-block(2,0)

    系统启动后,虽然nand驱动表现正常,但是最后挂载rootfs时候出错: Kernel command line: root=/dev/mtdblock2 rw init=/linuxrc conso ...

  2. linux内核挂载根文件系统时报错”VFS: Cannot open root device "ram0" or unknown-block(0,0): error -6“如何处理?

    1. 通过error -6得到: #define ENXIO            6      /* No such device or address */ 2. 解决办法 使能CONFIG_BL ...

  3. VFS: Cannot open root device "nfs" or unknown-block(0,255)错误的解决

    1. 解决办法:在内核配置时候文件系统中选中Root file system on NFS

  4. Linux Kernel - Debug Guide (Linux内核调试指南 )

    http://blog.csdn.net/blizmax6/article/details/6747601 linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级 ...

  5. 用Qemu模拟vexpress-a9 (一) --- 搭建Linux kernel调试环境【转】

    转自:http://www.cnblogs.com/pengdonglin137/p/5023342.html#_label2 阅读目录(Content) 环境介绍: 下载Linux内核 安装arm的 ...

  6. 用Qemu模拟vexpress-a9 (一) --- 搭建Linux kernel调试环境

    参考: http://blog.csdn.net/linyt/article/details/42504975 环境介绍: Win7 64 + Vmware 11 + ubuntu14.04 32 u ...

  7. How to: Compile Linux kernel 2.6

      Compiling custom kernel has its own advantages and disadvantages. However, new Linux user / admin ...

  8. Linux Kernel 'sctp_v6_xmit()'函数信息泄露漏洞(CVE-2013-4350)

    漏洞版本: Linux kernel 漏洞描述: BUGTRAQ ID: 62405 CVE(CAN) ID: CVE-2013-4350 Linux Kernel是Linux操作系统的内核. Lin ...

  9. 如何进行Linux Kernel 开发

    转自:http://www.cppblog.com/flyonok/archive/2011/04/15/144316.html 如何进行Linux Kernel 开发? (Take 3) 译者序:这 ...

随机推荐

  1. webpack打包jquery并引用

    一,引入webpack插件 //打包第三方 const CommonsChunkPlugin = require("webpack/lib/optimize/CommonsChunkPlug ...

  2. hihocoder [Offer收割]编程练习赛14 可疑的记录

    题目3 : 可疑的记录 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi有一棵N个节点的树,编号1-N,其中1号节点是整棵树的根.他把这棵树的N-1条边记录成N-1 ...

  3. CVE-2017-1000117命令注入验证

    首先,我们来看第一个问题,就是ssh的一种操作. ssh -oProxyCommand=gnome-calculator xxx 问题的本质在于ssh会把//后的host那么部分带-号的按照参数指令去 ...

  4. 关于移动端rem 布局的一些总结

    1.rem是什么? rem(font size of the root element)是指相对于根元素的字体大小的单位 2.为什么web app要使用rem? 实现强大的屏幕适配布局(淘宝,腾讯,网 ...

  5. C# TOKEN的保存与验证

    Token主要为了防止非本页数据的提交,防止重复提交. /** * * 保存TOKEN信息 * */ public void saveToken() { //此处生成md5串 string md5 = ...

  6. nginx配置文件内容详情及基本属性配置

    Nginx的配置文件nginx.conf配置详解如下: user nginx nginx ; Nginx用户及组:用户 组.window下不指定 worker_processes 8; 工作进程:数目 ...

  7. 牛客网多校赛第七场A--Minimum Cost Perfect Matching【位运算】【规律】

    链接:https://www.nowcoder.com/acm/contest/145/A 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 262144K,其他语言524 ...

  8. Python开发【十八章】:Web框架

    Web框架本质 1.众所周知,对于所有的Web应用,本质上其实就是一个socket服务端,用户的浏览器其实就是一个socket客户端 #!/usr/bin/env python # -*- codin ...

  9. centos shell编程4【分发系统】 服务器标准化 mkpasswd 生成密码的工具 expect讲解 expect传递参数 expect自动同步文件 expect指定host和要同步的文件 expect文件分发系统 expect自动发送密钥脚本 Linux脚本执行方式 第三十八节课

    centos shell编程4[分发系统] 服务器标准化  mkpasswd 生成密码的工具  expect讲解   expect传递参数   expect自动同步文件  expect指定host和要 ...

  10. mysql修改端口经验

    mysql更改端口修改/etc/my.cnf添加port=3308修改后如下[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock ...