栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

嵌入式linux开发,使用nfs挂载根文件系统时,报错:VFS: Cannot open root device “nfs“ or unknown-block(2,0): error -6

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

嵌入式linux开发,使用nfs挂载根文件系统时,报错:VFS: Cannot open root device “nfs“ or unknown-block(2,0): error -6

一、问题描述。

        嵌入式linux开发,使用nfs挂载根文件系统时,内核无挂载文件系统,报错如下:

VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "nfs" or unknown-block(2,0): error -6
Please append a correct "root=" boot option; here are the available partitions:
1f00            2048 mtdblock0  (driver?)
1f01           20480 mtdblock1  (driver?)
1f02          239616 mtdblock2  (driver?)
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
CPU: 0 PID: 1 Comm: swapper Not tainted 3.10.101 #233
Backtrace:
[] (dump_backtrace+0x0/0x10c) from [] (show_stack+0x18/0x1c)
 r6:c05b3d68 r5:00008000 r4:c051a658 r3:00000000
[] (show_stack+0x0/0x1c) from [] (dump_stack+0x20/0x28)
[] (dump_stack+0x0/0x28) from [] (panic+0xa4/0x1f8)
[] (panic+0x0/0x1f8) from [] (mount_block_root+0x1c4/0x270)
 r3:00000001 r2:00000000 r1:c3843ea0 r0:c051a658
 r7:c051a6c0
[] (mount_block_root+0x0/0x270) from [] (mount_root+0xec/0x114)
[] (mount_root+0x0/0x114) from [] (prepare_namespace+0x160/0x1c0)
 r8:c05b3d40 r7:c0623dc0 r6:c05b3d68 r5:c05b3d68 r4:c0623e20
[] (prepare_namespace+0x0/0x1c0) from [] (kernel_init_freeable+0x1d8/0x220)
 r6:c0623dc0 r5:00000007 r4:c05d960c
[] (kernel_init_freeable+0x0/0x220) from [] (kernel_init+0x10/0x158)
[] (kernel_init+0x0/0x158) from [] (ret_from_fork+0x14/0x3c)
 r5:c046519c r4:00000000
二、问题分析。

        nfs版本问题,我使用的linux系统版本是ubuntu18.04.5,。使用nfsstat命令查看nfs状态信息,确认host端nfs支持的版本。

ms@ubuntu:~$ nfsstat -v
Server packet stats:
packets    udp        tcp        tcpconn
234        209        25         2

Server rpc stats:
calls      badcalls   badfmt     badauth    badclnt
25         209        209        0          0

Server reply cache:
hits       misses     nocache
0          0          25

Server io stats:
read       write
0          0

Server read ahead cache:
size       0-10%      10-20%     20-30%     30-40%     40-50%     50-60%     60-70%     70-80%     80-90%     90-100%    notfound
0          0          0          0          0          0          0          0          0          0          0          0

Server file handle cache:
lookup     anon       ncachedir  ncachenondir  stale
0          0          0          0          0

Server nfs v3:
null             getattr          setattr          lookup           access
2         8%     12       48%     0         0%     0         0%     2         8%
readlink         read             write            create           mkdir
1         4%     0         0%     0         0%     0         0%     0         0%
symlink          mknod            remove           rmdir            rename
0         0%     0         0%     0         0%     0         0%     0         0%
link             readdir          readdirplus      fsstat           fsinfo
0         0%     0         0%     2         8%     0         0%     4        16%
pathconf         commit
2         8%     0         0%

ms@ubuntu:~$ 
三、解决方案。

        修改内核配置,在bootargs中指定nfs版本,加上v3。

CONFIG_CMDLINE="noinitrd root=/dev/nfs nfsroot=198.168.1.18:/mnt/nfs/rootfs,v3,nolock rw ip=198.168.1.25:198.168.1.18:198.168.1.1:255.255.255.0::eth0:off init=/linuxrc console=ttyS0,115200n8 mem=64M"

        成功启动,如下:

VFS: Mounted root (nfs filesystem) on device 0:11.
devtmpfs: mounted
Freeing unused kernel memory: 276K (c0594000 - c05d9000)


BusyBox v1.22.1 (2016-02-03 14:11:04 CST) built-in shell (ash)
Enter 'help' for a list of built-in commands.

~ #

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/457484.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号