Knowledge Base:Unable to mount root fs

From Gentoo Wiki
Jump to: navigation, search

Synopsis

When booting a freshly configured kernel, the boot fails with the following message:

VFS: Cannot open root device "hda3" 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)

The numbers in the unknown-block section can be different.

Environment

Any Gentoo Linux system on which a new kernel is being booted (or an update was made on the bootloader configuration).

Analysis

The panic informs that the Linux kernel is unable to:

  1. Detect the controller for the hard disk (a likely candidate if the message says unknown-block(0,0));
  2. Detect the partition because it does not have support for the partition type (less likely, but still possible);
  3. Mount the partition because it does not know how to access the file system (a likely candidate if the message gives a non-zero figure in the first number set, such as unknown-block(2,0));
  4. Detect the partition because the wrong device was passed in the boot loader configuration.

Resolution

Boot with the old kernel (if available), or with a LiveCD, and open the kernel configuration:

root #make menuconfig
  • Ensure that the controller chipset has been configured in the Linux kernel (and in-kernel, not as a module);
  • Ensure that the used file systems (such as ext2, ext3, ext4, ReiserFS, Btrfs, etc.) are configured in the Linux kernel (and built into the kernel, not as a module);
  • Ensure that, if you use root=UUID=..., you have built an initramfs when configuring the bootloader, see "Configuring the linux kernel" of your installation handbook
  • If running Gentoo as a Qemu guest, ensure that the virtio block drivers and PCI driver for virtio devices are enabled in the kernel (that is, CONFIG_VIRTIO_BLK=y and CONFIG_VIRTIO_PCI=y in the kernel configuration file).


Also verify that the boot loader configuration (/boot/grub/grub.conf for GRUB legacy and /boot/grub/grub.cfg for GRUB2) refers to the correct partition:

FILE /boot/grub/grub.confGRUB Legacy partition example
title Gentoo Linux
root (hd0,0)
kernel /kernel-3.0.4 root=/dev/sda3

If you are using an initramfs and upgrade to another kernel version, make sure the initramfs is recreated correctly in /boot for the new kernel version and that the boot loader configuration refers to the correct initramfs.