# Kernel Panic -- Unable to mount root fs [SOLVED]

## junikur

Hi;

I am having some real hard time with booting up my gentoo box for almost a month. I built a custom kernel for my box. I used the .config file from www.kernel-seed.org.  Here are some specification of my box:

lsmod: http://paste.pocoo.org/show/480939/

.config : http://paste.pocoo.org/show/480940/

CPU: http://paste.pocoo.org/show/480941/

lspci -k : http://paste.pocoo.org/show/480943/

lspci -n : http://paste.pocoo.org/show/480944/

fdisk -l : http://paste.pocoo.org/show/480945/

lsusb : http://paste.pocoo.org/show/480947/

fstab : http://paste.pocoo.org/show/480948/

Any help is more than appreciated. Thank you very much for your attention and time.Last edited by junikur on Sun Sep 25, 2011 6:25 am; edited 1 time in total

----------

## massimo

Please provide the configuration file of the boot loader.

----------

## junikur

Here it is.

lilo : http://paste.pocoo.org/show/481131/

Thank you for your reply

----------

## Hu

Please provide the actual error message.  There are several different ways that the kernel can fail to mount root, and the exact message will guide us as to which is affecting you.  Also, since you are not using genkernel, knowing the kernel command line would be helpful.

----------

## NeddySeagoon

junikur,

Did you forget to run /sbin/lilo after your last kernel rebuild and reinstall?

Your kernel config appears you have everything set to get you booted, so maybe you are not actually running the kernel that came from that config.

Why do you use lilo and not grub ?

----------

## junikur

Hi NeddySeagoon;

I am positive I ran /sbin/lilo before I rebooted my box. That was just last night and my memory is fresh. 

I like way better lilo compared to grub because I have been using Slackware for  years now and traditionally in Slackware lilo is used even nowadays.

Do you think it will make any difference if I use grub instead?

Thank you very much for your time and attention.

----------

## NeddySeagoon

junikur,

Both bootloaders work if used properly, so no, it will make no difference.

Please post the output of

```
ls -l /mnt/gentoo/boot
```

after you have mounted your partitions but not chrooted

It will do no harm to rerun /sbin/lilo, even if you ran it last night.  Just to be sure.

I've used lilo and I've been sure I ran /sbin/lilo and still booted into the old kernel.

A typo in the kernel file name would not produce any error messages.

Check the fille timestamps on the following files.  Again, mounted not chrooted.

```
/mnt/gentoo/usr/src/linux/.config

/mnt/gentoo/usr/src/linux/arch/x86/boot/bzImage

/mnt/gentoo/boot/<kernel>
```

.config should be the oldest. bzImage and <kernel> should be identical but if not, <kernel> must be newer.

Exactly what is the error message?

If it ends in unknown-block (x,y) where x and y are numbers, we need the numbers.

----------

## krinn

 *Hu wrote:*   

> Please provide the actual error message.  There are several different ways that the kernel can fail to mount root, and the exact message will guide us as to which is affecting you.  Also, since you are not using genkernel, knowing the kernel command line would be helpful.

 

Just requoting as i also think it's an important question that need answer

- don't just assume your disk will be name /dev/sda because it appears as /dev/sda when you use a livecd, if your first bootdisk is per example a cdrom, many motherboard assume random (not really random, but a too strange order to be guess right in an easy way) order for other disk, linux also assume a first load/first served drive id (the first driver load will get the first drive id available and this might cause issue with multi controller with build-in kernel support)

- Because grub allow you to alter your boot configuration on-the-fly, for me, lilo is missing a big feature there and grub is better just because of that.

- your swap should have id=82 and not 83

----------

## junikur

This is what I managed to get so far:

Run one more time make && make modules_install and then /sbin/lilo and reboot. I observed the same error;

If I do not mount other partitions and do  not chroot  ls  -l /mnt/gentoo/boot gives me nothing. It seems as if no files are present in this folder. However after I chroot in this folder I can see kernel-2.3.39. 

As well after chroot the time stamp is the following (as predicted by NeddySeagoon)

.config Sept 22, 20:22;

bzimage Sept 22, 20:15

kernel-2.6.39 Sept 22, 20:15

The error I get when booting up is:

error: Kernel Panic – not  syncing: VFS: Unable to mount root fs on unknown-block (8.3)

Pid: 1, comm.: swapper Not taineted 2.6.39-gentoo-r3 # 7…..

I switched to grub ending up with the same error; My grub look like the folowwing:

# This is a sample grub.conf for use with Genkernel, per the Gentoo handbook

# http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=10#doc_chap2

# If you are not using Genkernel and you need help creating this file, you

# should consult the handbook. Alternatively, consult the grub.conf.sample that

# is included with the Grub documentation.

default 0

timeout 30

#splashimage=(hd0,0)/boot/grub/splash.xpm.gz

title Gentoo Linux 2.6.39

root (hd0,0)

kernel /boot/kernel-2.6.39 root=/dev/sda3

title Gentoo Linux 2.6.39 (rescue)

root (hd0,0)

kernel /boot/kernel-2.6.39 root=/dev/sda3 init=/bin/bb

 When I change fstab so all drives would mount and then run mount –a nothing mounts (from chroot); however, when I mount (from chroot) manually (example mount –t ext4  /dev/sdb1  /mnt/storage1) it works.

= Sorry for my ignorance but I do not  understand whet do you mean by “the kernel command line”

I am already impressed by this forum. You are so willing to help. Thank you very much.

----------

## cach0rr0

 *junikur wrote:*   

> 
> 
> Sorry for my ignorance but I do not  understand whet do you mean by “the kernel command line”
> 
> 

 

kernel command line == whatever arguments you pass along with the path to the kernel in your bootloader's configuration file

so in the case of the grub.conf you posted

```

kernel /boot/kernel-2.6.39 root=/dev/sda3

```

out of curiosity, if youre still using grub, try:

```

kernel /boot/kernel-2.6.39 root=/dev/sda3 rootfstype=ext4

```

----------

## krinn

and because now you use grub, you can directly ask grub to show how it see your drives when booting.

just hit the "e" key, and type root (hd0, and hit "tab" key, grub will list possible partitions visible for that drive, and you should see your sda partitions list there (all your disks are 1 partition, except your boot drive where you have 4 if i remember well), if not, it's just because hd0 is not the drive you think will be sda or some partitions aren't support/valid.

----------

## junikur

When grub loaded up I hit “e” and then wrote root(hd0, and hit tab key the follow lines showed up:

Possible partitions are:

Partitition num: 0, Filesystem type is ext2fs, partition type 0x83

Partitition num: 1, Filesystem type is unknown, partition type 0x83

Partitition num: 2, Filesystem type is ext2fs, partition type 0x83

Partitition num: 3, Filesystem type is ext2fs, partition type 0x83

It seems there are 4 partitions in sda as expected; partition 1 is the swap and I do not know why grub thinks it is with unknown filesystem. 

Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     2099199     1048576   83  Linux

/dev/sda2         2099200    23070719    10485760   83  Linux

/dev/sda3        23070720   148899839    62914560   83  Linux

/dev/sda4       148899840   398297087   124698624   83  Linux

Editing  the kernel command line to 

kernel /boot/kernel-2.6.39 root=/dev/sda3 rootfstype=ext4

did not change the outcome;

Thank you very much for your help.

----------

## krinn

 *junikur wrote:*   

> partition 1 is the swap and I do not know why grub thinks it is with unknown filesystem.
> 
> Partitition num: 1, Filesystem type is unknown, partition type 0x83
> 
> 

 

 *myself wrote:*   

> - your swap should have id=82 and not 83

 

If you own multi-controller buldin your kernel, the disks naming scheme will be first load/first served, and if the controller driver with the bootdisk attach to it is loaded after another one, there's no way for that bootdisk to have a chance to grab its sda name.

And you are using more than one controller as you own many disks and the SATA use the ahci driver, you should check your bootdisk is really getting the sda name, and this could be seen in dmseg (i mean boot, let it fail, boot a livecd/another linux... and grab that dmesg, in it, you will see how kernel see your drives and assign name to them).

I'm not really sure how they will get their name, if it's like it was before, name will be grab by controller pci location and by disks attach on it : for your case it would be disks attach to the SB7x0/SB8x0/SB9x0 appears before ones attach to JMB362/JMB363

----------

## junikur

Hi krinn;

Here is dmesg from that the fail event and boot up in gentoo live/cd boot up; maybe you can see something useful in it.

dmesg : http://paste.pocoo.org/show/481689/

Thank you very much for your help.

----------

## krinn

that livecd tell it load the jmicro_PATA controller first and that controller have the (what i think is) your bootdisk attach to it.

```
scsi0 : pata_jmicron

scsi 2:0:0:0: Direct-Access     ATA      Maxtor 6L200P0   BAH4 PQ: 0 ANSI: 5

sd 2:0:0:0: [sda] 398297088 512-byte logical blocks: (203 GB/189 GiB)

 sda: sda1 sda2 sda3 sda4

```

If it's correct (it should it's the one with 4 partitions) that your bootdisk is a pata drive attach to that jmicron controller, just set ahci as module and this will make sure the ahci will be load after the pata driver (because your others disks are attach to the SATA controllers that both use ahci)

i was expecting more the mesg from your booting gentoo  :Razz: 

you don't even need to chroot, just mount it in your livecd and you could access it directly.

----------

## NeddySeagoon

junikur,

```
Unable to mount root fs on unknown-block (8.3) 
```

means thet athe kernel is loaded, finds your drive and reads the partition table.

That much is good.

The 8,3 is /dev/sda3 which should be your root too. So the kernel finds your root partition then cannot read it.

Whatever filesystem you have on /dev/sda3 must be missing from the kernel.

```
Possible partitions are:

Partitition num: 0, Filesystem type is ext2fs, partition type 0x83

Partitition num: 1, Filesystem type is unknown, partition type 0x83

Partitition num: 2, Filesystem type is ext2fs, partition type 0x83

Partitition num: 3, Filesystem type is ext2fs, partition type 0x83 
```

The unknown partition is your swap space.  It does not have a filesystem, just a swap signature. so thats ok.

As has been said. swap should have a partition type of 82 (set it with fdisk) but partition types are not used by linux with the exception of type fd, so it won't matter.

that looks right.

From your fstab 

```
/dev/sda3      /      ext3      noatime      0 1
```

 and your .config 

```
CONFIG_EXT3_FS=y
```

When the boot fails, the kernel should list the partitionson all devices that it found.  This bit is important.

Were there three partitions listed for /dev/sda or were they listed for some other drive?

There are two possibilities.  The kernel .config you posted earlier is no longer relevant and some other .config (with ext3 support missing) was used to generate your kernel, or as krinn says, the device enumeration order for your own kernel is not the same as for the liveCD.

Thats easy to check with grub and some trial and error.  Get to the grub screen and press e. 

edit your kernel command line from 

```
kernel /boot/kernel-2.6.39 root=/dev/sda3
```

to

```
 kernel /boot/kernel-2.6.39 root=/dev/sdb3
```

and let the boot continue.

Rinse and repeat for your other drives, that s b,c,d and e.

If your kernel is good, one should mount the root filesystem and fail at rootfsck with an error that ends "Give the root password for maintanance or press Ctrl-D to continue."

If you want to look around your system give the root password. root will be mounted read only so you need to fix that.

```
mount -o remount,rw /
```

Now you can mount /boot, edit grub.conf and edit /etc/fstab  to change the sda to sd<what worked>

However, drive enumeration is non deterministic, so next boot the order may be different so it may not work.  It may just work until you chnage the kernel.  This is not very satisfactory and can be fixed with udev rules. 

More on that once you have determined that its the drive enumeratition order thats the problem.

----------

## junikur

After screening different kernel command lines the following unfolded.

kernel /boot/kernel-2.6.39 root=/dev/sdb3 

error: Kernel panic…..Unable to mount root fs system on unknown block (8,19)

kernel /boot/kernel-2.6.39 root=/dev/sdc3

error: Kernel panic…..Unable to mount root fs system on unknown block (8,35)

kernel /boot/kernel-2.6.39 root=/dev/sdd3

error: Kernel panic…..Unable to mount root fs system on unknown block (8,51)

When the kernel command line was changed to: kernel /boot/kernel-2.6.39 root=/dev/sde3 

finally it booted up; however df –h shows that 

/dev/sdb1

 /dev/sdc1

 /dev/sdd1

 are mounted but /dev/sde1 and /dev/sda4  are not, although I specified this in fstab ; as well, the swap does not mount even though I changed  it type into 82 using fdisk (error: swapon: /dev/sda2: stat failed: NO such file or directory); Regardless it boots up as many times I tried;

The present fstab:

/dev/sda1               /boot           ext2            noauto,noatime  1 2

/dev/sda3               /               ext4            noatime         0 1

/dev/sda2               none            swap            sw              0 0

/dev/cdrom              /mnt/cdrom      auto            noauto,ro       0 0

/dev/fd0                /mnt/floppy     auto            noauto          0 0

proc        /proc        proc    defaults             0 0

shm         /dev/shm     tmpfs   nodev,nosuid,noexec  0 0

/dev/sda4               /home            ext4            defaults    0  0

/dev/sdb1               /mnt/storage1        ext4            defaults    0  0

/dev/sdc1               /mnt/storage2        ext4            defaults    0  0

/dev/sdd1               /mnt/storage3        ext4            defaults    0  0

/dev/sde1               /mnt/storage4        ext3            defaults    0  0

Please can somebody enlighten me on this. Should I set AHCI as module (as suggested by krinn)? 

Thanks again for your help;

----------

## krinn

yes made it module and it will be load next to your pata driver, problem solved.

if you wish see it, now that it boot, just look into your dmesg you'll see that linux is loading ahci before pata and that's why your disk is now at sde.

ps: you might just miss or didn't understood it clear, but your swapon could then only fail : if you wish it work with your current configuration, you should have type :

swapon /dev/sde2

just to show you why it fail and it might more enlight you of what is going on

and to see really who is mount, use the

```
mount
```

----------

## krinn

and i have explain it many times, it's easy to do, the label trick might help you define where your disk will be mount, this could help you, look here for example (as you see your problem was really common)

https://forums.gentoo.org/viewtopic-p-6759504-highlight-label.html#6759504

----------

## NeddySeagoon

junikur,

With your system, I would change to using the filesystem UUIDs to discover and mount things.

This works regardless of the location /dev nodes for the filesystems.  It works in a similar manner to labels but has a few advantages.

Not all filesystems support labels. extX and DOS does but all filesystems support UUIDs.

With labels or UUIDs you need an initrd, since you must call the userspace mount command to mount anything by label or UUIDs.

UUIDs are preferred over labels. See this wiki page.  You will need to read it through before you understand it.

----------

## krinn

 *NeddySeagoon wrote:*   

> 
> 
> With labels or UUIDs you need an initrd

 

Only for the bootloader NeddySeagoon, i don't use any and it "could" only trouble me for the kernel command line, and with grub, this isn't really a problem.

I prefer not using initrd, altering grub if i need, and still having fstab following my drives mount point.

----------

## NeddySeagoon

krinn,

You get to use UUIDs or Labels in /etc/fstab anyway.  You have userspace mount available there.

As you say, its only an issue for grub.conf.

With UUIDs or Labels in grub.conf, you system becomes immune from accidently connected USB storage devices bumping the drive order.

I've become accustomed to initrds as I have moved to running root on lvm on raid, so my hand is forced.

I also have separate /usr and /var logical volumes. Very soon now, I will need an initrd for that configuration to work as udev needs things in /usr and /var before localmount has been run.

My initrds do not contain kernel modules, just the userspace tools to get me booted, so they do not need to be updated every kernel.

----------

## junikur

IT WORKED ! 

I am very excited to let you know that my first ever installed gentoo booted successfully. I rebuilt kernel again and this time AHCI was set as module; I am using grub and not lilo, which was the key to troubleshooting this conundrum of mine. 

CONFIG_SATA_AHCI=m

CONFIG_SATA_AHCI_PLATFORM=m

CONFIG_SATA_ACARD_AHCI=y

I spent all afternoon installing gnome and doing other system configuration. All partitions are mounted as stated in fstab. As fas as using UUIDs, I had to used them once when I had a  similar problem in Debian to the one NeddySeagoon is talking about. So far, everything  is working great so I will not try to mess around with UUIDs. Gentoo is fascinating so is this forum. I could not ever done without your help. You shall hear from me again.

Thank you very much for your time and attention.

----------

