Probably the most annoying yet most occurring issue on Gentoo Linux systems
is the Unable to mount root fs on unknown-block(x,y) error. However,
resolving it is most of the time simple if you know what hardware
you have in your system...
First of all, let's take a look at the error that you get:
VFS: Cannot open root device "sda1" or unknown-block(8,1)
Please append a correct "root=" boot option
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
This is the Linux kernel telling you that it cannot access the root device you
have selected in the Linux definition of your bootloader. From the error you
can already see what Linux thinks you have selected as root device, namely
the "/dev/sda1" (taken from the first line).
If this root device is wrongly set then this is most likely your issue. Sadly,
most people have this right - it is the kernel configuration that's wrong. Let
us take a look at an example run-down of possible mis-configuration in a kernel
for a Fujitsu Siemens Amilo PRO laptop. I can safely tell you that it uses an
Intel ICH6M SATA controller. How do I know this? Well, lspci told me so.
The lspci tool is one that everyone should use when configuring their
kernel as it almost tells you what kernel options you need to select. And this
is exactly what you should do when you get the VFS-error we talked about earlier.
Why? Because the most likely reason for the error is because the kernel doesn't
support the PCI controller, doesn't support the SATA/IDE controller, doesn't
support SCSI/IDE disks and/or doesn't support the file system that you use on
the root partition (mind you: support for that file system must be built-in in
the kernel).
Let's cross this with the example of the Fujitsu laptop shall we?
00:00.0 Host bridge: Intel Corporation Mobile 915GM/PM/GMS/910GML
Express Processor to DRAM Controller (rev 03)
00:02.0 VGA compatible controller: Intel Corporation Mobile 915GM/GMS/910GML
Express Graphics Controller (rev 03)
00:02.1 Display controller: Intel Corporation Mobile 915GM/GMS/910GML
Express Graphics Controller (rev 03)
These things I can leave alone for this VFS-problem as they are not related to
the partition access problem we are looking at.
00:1c.0 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family)
PCI Express Port 1 (rev 04)
00:1c.1 PCI bridge: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family)
PCI Express Port 2 (rev 04)
This is already more interesting. PCI bridges allow for communication between
the CPU and the PCI bus. The PCI bus is an important component for our access
problem we face because the controller will most likely reside on the PCI bus
(if not, its an ISA controller and those should be extinct by now).
So, what do we definitely need for this? Well, the PCI bridge is of the PCI
Express family, and this requires a specific kernel configuration to be activated:
Bus options (PCI, PCMCIA, EISA, MCA, ISA) --->
[x] PCI support
...
[x] PCI Express support
Great, we had that, so that's okay. The next lines again can be skipped as they
are not of interest now. Mind you, they are quite important for kernel configuration
as it helps you decide what other drivers you need to select!
00:1d.0 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family)
USB UHCI #1 (rev 04)
00:1d.1 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family)
USB UHCI #2 (rev 04)
00:1d.2 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family)
USB UHCI #3 (rev 04)
00:1d.3 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family)
USB UHCI #4 (rev 04)
00:1d.7 USB Controller: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family)
USB2 EHCI Controller (rev 04)
00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev d4)
00:1e.2 Multimedia audio controller: Intel Corporation 82801FB/FBM/FR/FW/FRW
(ICH6 Family) AC'97 Audio Controller (rev 04)
00:1e.3 Modem: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family)
AC'97 Modem Controller (rev 04)
00:1f.0 ISA bridge: Intel Corporation 82801FBM (ICH6M) LPC Interface Bridge (rev 04)
00:1f.1 IDE interface: Intel Corporation 82801FB/FBM/FR/FW/FRW (ICH6 Family)
IDE Controller (rev 04)
Wait a minute! The last line sais that we have an IDE controller. Right, true,
this laptop has an IDE DVD-R/W device. Good to know, even though this is not
related to our VFS-panic issue ;-) The next line we see however is
important for this:
00:1f.2 SATA controller: Intel Corporation 82801FBM (ICH6M) SATA Controller (rev 04)
We need to verify that we have built in Intel SATA Controller support. To find
out where in the kernel this definition is set, you can use the search option
when you are inside the make menuconfig menu: / SATA will give
you a list of configuration options for SATA. From that list, you can see where
the SATA support (at least in the kernel I currently use) is at. So I verify
the next set of kernel options:
Device Drivers --->
SCSI device support --->
...
<*> SCSI disk support
...
SCSI low-level drivers --->
<*> Serial ATA (SATA) support
...
<*>Intel PIIX/ICH SATA Support
That seems fine as well. The rest of the lspci output doesn't give any
other devices that we definitely need right now. So what is the problem then?
Well, actually we could skip all of the above (but if I did that, this wouldn't
be much of an explanation would it?) because the error stated
unknown-block(8,1). Because the numbers aren't (0,0) I could
actually identify that the kernel does support the drivers for the partition
because the numbers identify the major/minor number of the device (SCSI disk,
first partition). So either I don't have such a device (don't laugh, I see many
people thinking they had /dev/hda3 while in fact it was /dev/sda3)
or the file system on that device cannot be read.
The file system on the root device is ext3, so let see what the kernel configuration
sais:
File systems --->
Second extended fs support
...
Ext3 journalling file system support
...
You see the problem here? Ext3 support (and ext2 support, which is compatible with
ext3) is not built in the kernel but built as a module. But the module resides
on the partition, which the kernel can't access because it doesn't know what
file system is on it. So change this to:
File systems --->
<*> Second extended fs support
...
<*> Ext3 journalling file system support
...
Now rebuild the kernel, copy it to /boot and reboot.
Now what in case of initial ramdisks? Well, the same is true, except that you
can have most of the stuff talked about earlier as modules (which are built in
the initrd) but you need Initial Ramdisk support and RomFS built-in into the
kernel instead.
And in case of other storage related things (like LVM, software and pseudo-hardware
RAID, etc)? Well, the same logic is true here, although you will most likely need
an initrd which not only loads the appropriate kernel modules, but also initializes
the storage (volume groups in case of LVM, MD devices in case of RAID), so if you select
such technologies for your root device, be sure to read the documentation well!