嵌入式VFS:Cannotopenrootdevice”mtdblock2″orunknown-block(2,0)

double2li發表於2016-04-12

系統啟動後,雖然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就掛載成功了


相關文章