嵌入式 VFS: Cannot open root device "mtdblock2" or unknown-block(2,0)
系統啟動后,雖然nand驅動表現正常,但是最后掛載rootfs時候出錯:
Kernel command line: root=/dev/mtdblock2 rw init=/linuxrc console=ttyAMA1,115200 mem=64M rootfstype=yaffs2
。。。。
。。。。
AS353X NAND Driver, (c) 2010 austriamicrosystems
as353x_nand_probe
Nand clock set to 24000000
Nand:res->start at e60000
Nand:mapped registers at c48dc000
as353x_nand_inithw
Nand:initialising set 0 (c3a62800, info c3a934e0)
as353x_nand_init_chip
NAND device: Manufacturer ID: 0xec, Chip ID: 0xd3 (Samsung NAND 1GiB 3,3V 8-bit)
Scanning device for bad blocks
Bad eraseblock 2262 at 0x11ac0000
Bad eraseblock 3151 at 0x189e0000
Bad eraseblock 3649 at 0x1c820000
Bad eraseblock 5198 at 0x289c0000
Bad eraseblock 6842 at 0x35740000
as353x_nand_add_partition
Creating 5 MTD partitions on "NAND 1GiB 3,3V 8-bit":
0x00000000-0x00100000 : "U-Boot"
0x00100000-0x00900000 : "Kernel"
0x00900000-0x0d100000 : "Root filesystem"
0x0d100000-0x11100000 : "Temp"
0x11100000-0x3d700000 : "Data"
Nand:initialised ok
。。。。。。。
Root-NFS: No NFS server available, giving up.
VFS: Unable to mount root fs via NFS, trying floppy.
VFS: Cannot open root device "mtdblock2" or unknown-block(2,0)
Please append a correct "root=" boot option; here are the available partitions:
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
【解決過程】
1.開始以為rootfs里面沒有/dev/mtdblock2這個設備呢,后去制作rootfs的所用的文件那里查證,rootfs里面是有這些設備的:
[crifan@linux-41lh root]$ls dev/mtd* -l
-rw-r----- 1 eric develop 0 2010-01-12 13:58 dev/mtd0
-rw-r----- 1 eric develop 0 2010-01-12 13:58 dev/mtd1
-rw-r----- 1 eric develop 0 2010-01-12 13:58 dev/mtd2
-rw-r----- 1 eric develop 0 2010-01-12 13:58 dev/mtd3
-rw-r----- 1 eric develop 0 2010-01-12 13:58 dev/mtdblock0
-rw-r----- 1 eric develop 0 2010-01-12 13:58 dev/mtdblock1
-rw-r----- 1 eric develop 0 2010-01-12 13:58 dev/mtdblock2
-rw-r----- 1 eric develop 0 2010-01-12 13:58 dev/mtdblock3
【!!!此理解錯誤->】此外,最后經證實和確定,系統訪問/dev/mtdblock2時候,這些塊設備是系統內部生成的,即使你rootfs里面沒建立這些設備文件,也是不影響的。
2.以為rootfs數據有問題,后來發現,此時還未涉及到rootfs數據的讀寫,因為還沒掛載成功呢。
3.經過同事提醒,是否設置了MTD的block device支持。所以去內核源碼處,查看配置:
make ARCH=arm menuconfig
在device drivers -> Memory Technology Device (MTD) support --->
發現里面有個選項:
Caching block device access to MTD devices
經過看其help:
Memory Technology Device (MTD) support -------------------------------------------+
| CONFIG_MTD: |
| |
| Memory Technology Devices are flash, RAM and similar chips, often |
| used for solid state file systems on embedded devices. This option |
| will provide the generic support for MTD drivers to register |
| themselves with the kernel and for potential users of MTD devices |
| to enumerate the devices which are present and obtain a handle on |
| them. It will also allow you to select individual drivers for |
| particular hardware and users of MTD devices. If unsure, say N.
和網上查找:
7.1 MTD-Supported Devices
Caching block device access to MTD devices, CONFIG_MTD_BLOCK
This is the configuration option for the read-write block device MTD user module that is visible as /dev/mtdblockN. If you configure this as a module, the module's filename is mtdblock.o.
得知,這個就是對應的,mtd的塊設備的選項,因此,選上,重新編譯,就可以加入mtd 塊設備的支持了。
也就可以訪問上面的/dev/mtdblcok2了。
【后記】
1.經過實際測試發現,rootfs中的/dev/mtdblockN,還是有關系的,其系統訪問此mtd塊設備,還是會去訪問此文件的,/dev/mtdblockN會連接到底層對應的塊設備,也就是這樣是對的:
[root@linux-41lh root]$ls dev/mtd* -l
crw-r----- 1 root root 90, 0 2009-11-16 15:06 dev/mtd0
crw-r----- 1 root root 90, 2 2009-11-16 15:06 dev/mtd1
crw-r----- 1 root root 90, 4 2009-11-16 15:06 dev/mtd2
crw-r----- 1 root root 90, 6 2009-11-16 15:06 dev/mtd3
crwxr-xr-x 1 root root 90, 8 2009-11-16 15:06 dev/mtd4
brw-r----- 1 root root 31, 0 2009-11-16 15:06 dev/mtdblock0
brw-r----- 1 root root 31, 1 2009-11-16 15:06 dev/mtdblock1
brw-r----- 1 root root 31, 2 2009-11-16 15:06 dev/mtdblock2
brw-r----- 1 root root 31, 3 2009-11-16 15:06 dev/mtdblock3
brwxr-xr-x 1 root root 31, 4 2009-11-16 15:06 dev/mtdblock4
而上面我們看到的:
-rw-r----- 1 eric develop 0 2010-01-12 13:58 dev/mtdblock2
這個明顯不是設備文件,所以是不正常的。
因此,需要生成對應的設備文件放到rootfs里面,然后重新執著roofs鏡像文件(此處我這里是用mkyaffs2image去對root/文件夾及其下面的文件,制作出來yaffs2的rootfs文件的)。
nfs 掛載根文件系統
最近在實驗從nfs服務器上掛載根文件系統。我用的redhat-2.6.18的內核,重新編譯內核后。在啟動過程中出現以下錯誤信息:
。。。。。
looking up port of RPC 100003/2 on 192.168.1.2
portmap: RPC call retured error 101
Root-NFS: Unable to get nfsd port number from server, using default
looking up port of RPC 100005/1 on 192.168.1.2
portmap: RPC call retured error 101
Root-NFS: Unable to get mountd port number from server, using default
mount: RPC call returned error 101
Root-NFS: Unable to get mountd port number from server, using default
mount: RPC call returned error 101
Root-NFS:Server returned error -101 while mounting /tftpboot/nfs
VFS: Unable to mount root fs via NFS, trying floppy
VFS: Cannot open root device "nfs" 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)
我的default 文件配置如下
default local
timeout 100
prompt 1
display msgs/boot.msg
F1 msgs/boot.msg
F2 msgs/general.msg
F3 msgs/expert.msg
F4 msgs/param.msg
F5 msgs/rescue.msg
F7 msgs/snake.msg
label local
localboot 1
label 0
localboot 1
label 1
kernel ../boot/bzImage
append root=/dev/nfs rw nfsroot=192.168.1.2:/tftpboot/nfs ip=dhcp
nfs配置文件如下
/tftpboot *(rw,no_root_squash,sync)
內核編譯文件中
CONFIG_ROOT_NFS=Y
CONFIG_IP_PNP=Y
CONFIG_IP_PNP_DHCP=Y
CONFIG_IP_PNP_BOOTP=Y
CONFIG_IP_PNP_RARP=Y
是因為內核中沒有編譯網卡的驅動,只要在內核中編譯進相應的網卡驅動就好了
問題描述:使用SAM9X25 內核版本是2.6.39 ,采用NFS文件系統, 在啟動內核時會出現VFS: Cannot open root device "nfs" or unknown-block(0,255)錯誤
解決辦法:step1,在內核配置時候文件系統中選中Root file system on NFS,這個選項depend on IP_PNP,發現IP_PNP在/net/ipv4/Kconfig中定義,故此項也要選中。
step2,uboot配置時需要關閉自動配置項,如下關閉eth0的IP自動配置
setenv bootargs root=/dev/nfs rw nfsroot=10.10.150.177:/home/wuer/nfs
ip=10.10.150.180:10.10.150.177:10.10.150.20:255.255.255.0::eth0::off console=ttyS0,115200
這樣NFS就掛載成功了
RFID管理系統集成商 RFID中間件 條碼系統中間層 物聯網軟件集成