Google
 

音樂分享 - 「君がいるから」by 江口一聲

2007年5月3日 星期四

Linux Kernel panic: VFS 開機失敗

VFS : Cannot open root device "802" or unknown-block(8,2)
Please append a corect "root=" boot option
Kernel panic: VFS: Unable to mount root fs on unknown-block(8,2)


我在 IBM Netfinity 3500 與 HP DL370 升級 Linux Kernel 都遇過此問題,也一直不解為何會如此,早知道有解就該多找找 Google ... 冏rz

以下是找到的解法...

這一篇是說明問題,問題在於 升級後的 kernel 的 initrd.img 沒有內含 ext3 的 module (ext3.ko) ,所以開機時就無法讀入 ext3 的分割區,開機當然就失敗啦~

Linux Kernel panic VFS Unable to mount root fs and solution | Frequently Asked Questions

Q. I am using Linux on HP server and I am getting error that read root file system , Linux Kernel panic: VFS: Unable to mount root fs on unknown-block(8,2) . How do I solve this problem?

A. Most modern distributions including Debian uses loadable kernel module for ext3 file system. So to read ext3/ext2 file system kernel must load ext3 kernel module (ext3.ko).

This module is included in an initrd image. If an initrd image is missing or that image does not include suitable kernel modules to access the ext3 filesystem on the partition, an error message (Linux Kernel panic: VFS: Unable to mount root fs on unknown-block(8,2) will be displayed to you.

To solve this problem you need to use mkinitrd script that constructs a directory structure that can serve as an initrd root file system.

解決方法就是,自已再做一個 initrd.img 並把 ext3 的 module 包進入,以下是做法:

Source: Rebuild the initial ramdisk image | Frequently Asked Questions

Q: I think I am missing some driver or my initial ramdisk is corrupted for running kernel how do I Rebuild the initial ramdisk image under Linux?

A: You need ramdisk if you have added new hardware devices such as SCSI or FibreChannel controller to your server as the ramdisk contains the necessary modules (i.e. drivers) to initialize hardware driver. If you modified the /etc/modprob.conf (or modules.conf) file then you need to execute special script called mkinitrd.

The mkinitrd script constructs a directory structure that can serve as an initrd root file system. It then generates an image containing that directory structure using mkcramfs, which can be loaded using the initrd mechanism. The kernel modules for the specified kernel version will be placed in the directory structure. If version is omitted(省略), it defaults to the version of the kernel that is currently running.

Find out your kernel version:

# uname -r 先確認 kernel 版本
2.6.15.4

Make backup of existing ram disk: 做個備份
# cp /boot/initrd.$(uname -r).img /root

To create initial ramdisk image type following command as the root user:

# mkinitrd -o /boot/initrd.$(uname -r).img $(uname -r) 製作 initrd.img
# ls -l /boot/initrd.$(uname -r).img

You may need to modify grub.conf to point out to correct ramdisk image, make sure following line existing in grub.conf file:

initrd /boot/initrd.img-2.6.15.4.img 在 grub.conf 裏指定正確的 initrd.img

When the system boots using an initrd image created by mkinitrd command, the
linuxrc will wait for an amount of time which is configured through mkinitrd.conf, during which it may be interrupted by pressing ENTER. After that, the modules specified in will be loaded.

講了很多 initrd.img ,現在來解釋一下 什麼是 initrd... 簡單說就是 Initial Ramdisk 的縮寫,為了解決開機時有關雞生蛋或蛋生雞的問題… 說明:root file system 是 ext3 ,但是 ext3 並未包含在 kernel 裏,而是做成 loadable module ,這樣開機時 kernel 就讀不到 root file system 了… 即使是 kernel 想載入 ext3 module,可是對這 module 在 ext3 的 file system 裏啊~ 哈 真是有趣,果然是雞跟蛋的問題… 這個initrd 會產生一個 image 檔,裏面會有一個 filesystem ,並也建構了 modules 的目錄與放進了 module,這樣 kernel 就能載入這些 module了,然後就能把 root filesystem 掛載起來,繼續完開機的動作。

Source: Digital Hermit - Kernel-Build-HOWTO

Create Initial RAMDisk

If you have built your main boot drivers as modules (e.g., SCSI host adapter, filesystem, RAID drivers) then you will need to create an initial RAMdisk image. The initrd is a way of sidestepping the chicken and egg problem of booting -- drivers are needed to load the root filesystem but the filesystem cannot be loaded because the drivers are on the filesystem. As the manpage for mkinitrd states:

mkinitrd creates filesystem images which are suitable for use as Linux initial
ramdisk(initrd) images. Such images are often used for preloading the
block device modules (such as IDE, SCSI or RAID) which are needed to access the
root filesystem. mkinitrd automatically loads filesystem modules (such as
ext3 and jbd), IDE modules,all scsi_hostadapter entries in /etc/modules.conf,
and raid modules if the systems root partition is on raid, which makes it
simple to build and use kernels using modular device drivers.

--MKINITRD(8)

To create the initrd, do the following:

$ mkinitrd /boot/initrd-2.6.0.img 2.6.0

Some versions of mkinitrd may require other options to specify the location of the new kernel. On SuSe 9.0, for example, the following syntax is required:

$ mkinitrd -k vmlinux-VERSION -i initrd-VERSION

沒有留言: