# [SOLVED] boot fails: Block device is not a valid root device

## lalebarde

Hi all,

I made a mistake when I tried to start a Windows installed basically with a dual boot, from Gentoo with qemu -hda /dev/sdb9. As it did not boot, I tried with the first partition where Windows is supposed to have written the MBR, so qemu -hda /dev/sdb1. To be clear for this Windows install, I retrieved first my Gentoo disk, installing Windows on the appropriate partition. Then I set back the first disk and I have used the trick to permute the disks in the grub config (Gentoo is on sda and Windows on sdb). As the qemu start for Windows still did not work, I tried to start it on the grub MBR with qemu -hda /dev/sda1.   :Embarassed: 

I don't know when I corrupted my system, but now when I want to boot on Gentoo, I have the grub menu, I choose the right entry, then it starts booting and fails with :

```
/init: line 256: setup_hotplug: not found

>> Skipping module load; no modules in the ramdisk!

>> Hint: use parameter scandelay [=seconds]

/init: line 286: start_dev_mgr: not found

>> Determining root device...

!! Block device /dev/sda6 is not a valid root device

!! Could not find the root block device in .
```

Here is my fstab : 

```
/dev/sda5      /boot      ext2      noauto,noatime   1 2

/dev/sda6      /      ext4      noatime      0 1

/dev/sda9      none      swap      sw      0 0

/dev/sr0      /mnt/cdrom   auto      ro   0 0

/dev/sda7      /usr      ext4      noatime      0 2

/dev/sda8               /var      ext4            noatime,nosuid  0 2

/dev/sda2               /home      ext4            noatime,nosuid         0 2

/dev/sda3               /Data_Caro           ext4            noatime,nosuid,noexec         0 2

/dev/sdb5      /backup/boot   ext2      noauto,noatime      1 2

/dev/sdb6      /backup      ext4      noauto,noatime      0 1

/dev/sdb7      /backup/usr   ext4      noauto,noatime      0 2

/dev/sdb8               /backup/var   ext4            noauto,noatime,nosuid     0 2

/dev/sdb3               /backup/home   ext4            noauto,noatime,nosuid   0 2
```

I cannot use uname -a from the LiveDVD, but I have : 

```
linux-3.3.8-gentoo x86_64 Intel(R) Core(TM) i7 CPU 870 @ 2.93GHz GenuineIntel GNU/Linux
```

I had not a recent backup, but I could compare my /etc with the backup and discovered that /etc/mtab and /etc/resolv.conf were messed up. The resolv.conf was like a DHCP one where it was a static IP one. So I restored the modified file with deep checks, and I re-emerged system and world. I rebuilt also the ramfs.

Here is my grub configuration :

```
default 0

timeout 5

splashimage=(hd0,4)/grub/splash.xpm.gz

title G-3.3.8-wifi-kvm

root (hd0,4)

kernel /boot/kernel-gentoo-sources-3.3.8-wifi-kvm root=/dev/ram0 real_root=/dev/sda6 rootfstype=ext4

initrd /boot/initramfs-genkernel-x86_64-3.3.8-gentoo

title Windows XP

map (hd1) (hd0)

map (hd0) (hd1)

rootnoverify (hd1,0)

#makeactive

chainloader +1
```

No progress   :Crying or Very sad: 

Here is my kernel build script :

```
#!/bin/bash

cd /usr/src/linux

time make && make modules_install

module-rebuild populate

module-rebuild rebuild

depmod -a

mount /boot

cp .config .config-gentoo-sources-3.3.8-wifi-kvm 

cp .config /boot/.config-gentoo-sources-3.3.8-wifi-kvm 

cp arch/x86_64/boot/bzImage /boot/kernel-gentoo-sources-3.3.8-wifi-kvm

genkernel --linuxrc=/usr/share/genkernel/defaults/linuxrc.uswsusp --initramfs-overlay=/var/lib/genkernel/overlay --install --no-ramdisk-modules initramfs

umount /boot

cd
```

Then I backed up all my system partitions (/, /boot, /usr, /var), deleted the partitions, recreate them, reformat and push back the system. I also rewrote the MBR. No progress   :Crying or Very sad: 

Then I updated udev, following the documentation, to sys-fs/udev-200. No progress   :Crying or Very sad: 

I changed also my fstab to use labels :

```
LABEL="boot"      /boot      ext2      noauto,noatime   1 2

LABEL="racine"      /      ext4      noatime      0 1

LABEL="swap"      none      swap      sw      0 0

/dev/sr0      /mnt/cdrom   auto      ro   0 0

LABEL="usr"      /usr      ext4      noatime      0 2

LABEL="var"               /var      ext4            noatime,nosuid  0 2

LABEL="home"               /home      ext4            noatime,nosuid         0 2

LABEL="Data"               /Data_Caro           ext4            noatime,nosuid,noexec         0 2

LABEL="backup_boot"      /backup/boot   ext2      noauto,noatime      1 2

LABEL="backup_racine"      /backup      ext4      noauto,noatime      0 1

LABEL="backup_usr"      /backup/usr   ext4      noauto,noatime      0 2

LABEL="backup_var"               /backup/var   ext4            noauto,noatime,nosuid     0 2

LABEL="backup_home"               /backup/home   ext4            noauto,noatime,nosuid   0 2
```

No progress   :Crying or Very sad: 

I assume qemu did some mess somewhere.

If someone has an idea what I could do, he is welcome.Last edited by lalebarde on Tue May 14, 2013 4:06 pm; edited 2 times in total

----------

## NeddySeagoon

lalebarde,

```
!! Could not find the root block device in .
```

tells that your kernel cannot see any block devices at all or they would be listed just before the dot.

For your gentoo install, what does 

```
ls -l /boot
```

 show?

A kernel is being loaded but it never mounts root, so the content of /etc/fstab has not yet been read.

From your kernel line

```
kernel /boot/kernel-gentoo-sources-3.3.8-wifi-kvm root=/dev/ram0 real_root=/dev/sda6 rootfstype=ext4 
```

You may find that 

```
kernel /boot/kernel-gentoo-sources-3.3.8-wifi-kvm root=/dev/sda6 rootfstype=ext4
```

 works better as the initramfs is automatically used if its there.

----------

## lalebarde

Hi NeddySeagoon,

Thank you for your answer.

```
(chroot) livecd / # ls -l /boot

total 19521

lrwxrwxrwx 1 root root       1  3 juil.  2012 boot -> .

drwxr-xr-x 2 root root    1024  8 mai   14:20 grub

-rw-r--r-- 1 root root 2652085  4 juil.  2012 initramfs-3.3.8.img

-rw-r--r-- 1 root root 1693980  8 mai   16:42 initramfs-genkernel-x86_64-3.3.8-gentoo

-rw-r--r-- 1 root root 1206462  6 juil.  2012 initramfs-genkernel-x86_64-3.3.8-gentoo.sauv

-rw-r--r-- 1 root root 4755424  9 juil.  2012 kernel-gentoo-sources-3.3.8

-rw-r--r-- 1 root root 4752656 29 juil.  2012 kernel-gentoo-sources-3.3.8-wifi

-rw-r--r-- 1 root root 4824432  8 mai   16:42 kernel-gentoo-sources-3.3.8-wifi-kvm

drwx------ 2 root root   12288  3 juil.  2012 lost+found
```

I am going to test your suggestion with the modified grub.conf .....

----------

## NeddySeagoon

lalebarde,

Apart from it not working, ls -l /boot looks good.

----------

## lalebarde

the modified grub.conf does not change the result unfortunatly. At least, it is simplier.

----------

## NeddySeagoon

lalebarde,

The problem lies in your kernel or initramfs somewhere.

Your motherboard HDD chipset driver is missing or not being loaded.

It looks like you used genkernel to build your kernel, thats mostly harmless.

Did you make the config file yourself or did you allow genkernel to do it?

If you can find your genkernel command line in your command history, that will tell all.

If you still believe that something was damaged because it used to work, it can only be the kernel or initramfs.

Remaking them both will test that theory.

----------

## lalebarde

My kernel is a manual one. I use genkernel only to build the initramfs to get the ext4 support. That's the only method I have had success with.

Yes, before I played with qemu, everything was al-right. I am not sure to have rebuilt the kernel - at least, not after a clean. So am going to do that..... in some hours after sleeping.

Cheers

----------

## NeddySeagoon

lalebarde,

The next step after that is to post your lspci output, so we can check that you have the kernel options you need for your HDD chip set.

It will be easier after a good nights sleep.

----------

## lalebarde

After 

```
cd /usr/src/linux

make clean

make proper

cp .config-gentoo-sources-3.3.8-wifi-kvm .config

make && make modules && make modules_install

module-rebuild populate

module-rebuild rebuild

depmod -a

mount /boot

cp .config .config-gentoo-sources-3.3.8-wifi-kvm 

cp .config /boot/.config-gentoo-sources-3.3.8-wifi-kvm 

cp arch/x86_64/boot/bzImage /boot/kernel-gentoo-sources-3.3.8-wifi-kvm

genkernel --linuxrc=/usr/share/genkernel/defaults/linuxrc.uswsusp --initramfs-overlay=/var/lib/genkernel/overlay --install --no-ramdisk-modules initramfs

umount /boot
```

It still does not work. So, the .config may be corrupted ? I tried my two old kernel builds (different .config), but the result is the same (I use the same initramfs thought). So probably it is a problem with initramfs ?

Here are my :

lspci -vv : http://pastebin.com/DT134Zu5

.config (no comment) : http://pastebin.com/SZ3S66ty

dmesg : http://pastebin.com/2jg9Hyub

/var/log/kern.log : http://pastebin.com/rV52xyrK

In the last, you can see the qemu kernel calls that I suppose broke the system (but I am not sure how to interpret it).

----------

## krinn

I would say you have disable AHCI and your controller now run in legacy mode thru intel ata_piix driver.

While i suppose previously your controller was running AHCI and handle thru ahci driver.

I'm not sure how fine a non ahci driver could handle a 1.5Tb disk.

And for your non booting windows

```
title Windows XP

map (hd1) (hd0)

map (hd0) (hd1)

rootnoverify (hd1,0) 
```

As soon as drive are xchange, hd1 will be hd0 and then to access it you should use hd0 name so.

For me, i would have set rootnoverify (hd0,0) as now hd1 is hd0 ; like that i think you are just negate the previous swap to finally try booting on the same disk.

----------

## lalebarde

Hi krinn,

Thank you for your answer.

The different drivers and modules activated by the LiveDVD are :

```
livecd ~ # lspci -vv | egrep -i "driver|module"

   Kernel driver in use: pcieport-driver

   Kernel driver in use: ehci_hcd

   Kernel modules: ehci-hcd

   Kernel driver in use: pcieport-driver

   Kernel driver in use: pcieport-driver

   Kernel driver in use: pcieport-driver

   Kernel driver in use: pcieport-driver

   Kernel driver in use: ehci_hcd

   Kernel modules: ehci-hcd

   Kernel driver in use: ata_piix

   Kernel modules: ata_piix

   Kernel driver in use: i801_smbus

   Kernel modules: i2c-i801

   Kernel driver in use: ata_piix

   Kernel modules: ata_piix

   Kernel driver in use: ohci1394

   Kernel modules: ohci1394, firewire-ohci

   Kernel driver in use: tg3

   Kernel modules: tg3
```

From the chroot :

```
(chroot) livecd linux # lspci -vv | egrep -i "driver|module"

   Kernel driver in use: pcieport-driver

   Kernel driver in use: ehci_hcd

   Kernel driver in use: pcieport-driver

   Kernel driver in use: pcieport-driver

   Kernel driver in use: pcieport-driver

   Kernel driver in use: pcieport-driver

   Kernel driver in use: ehci_hcd

   Kernel driver in use: ata_piix

   Kernel driver in use: i801_smbus

   Kernel driver in use: ata_piix

   Kernel modules: nvidia

   Kernel driver in use: ohci1394

   Kernel modules: snd-ctxfi

   Kernel driver in use: tg3

   Kernel modules: tg3

   Kernel modules: parport_pc
```

All are present in my kernel configuration :

```
(chroot) livecd linux # grep -i ata_piix .config

CONFIG_ATA_PIIX=y

(chroot) livecd linux # grep -i pcieport .config

CONFIG_PCIEPORTBUS=y

(chroot) livecd linux # grep -i ehci .config

CONFIG_USB_ARCH_HAS_EHCI=y

CONFIG_USB_EHCI_HCD=y

# CONFIG_USB_EHCI_ROOT_HUB_TT is not set

# CONFIG_USB_EHCI_TT_NEWSCHED is not set

# CONFIG_USB_EHCI_MV is not set

(chroot) livecd linux # grep -i i801 .config

CONFIG_I2C_I801=y

(chroot) livecd linux # grep -i ohci .config

CONFIG_USB_ARCH_HAS_OHCI=y

CONFIG_USB_OHCI_HCD=y

# CONFIG_USB_OHCI_BIG_ENDIAN_DESC is not set

# CONFIG_USB_OHCI_BIG_ENDIAN_MMIO is not set

CONFIG_USB_OHCI_LITTLE_ENDIAN=y

CONFIG_PROVIDE_OHCI1394_DMA_INIT=y

(chroot) livecd linux # grep -i ctxfi .config

CONFIG_SND_CTXFI=m

(chroot) livecd linux # grep -i tg3 .config

(chroot) livecd linux # grep -i nvidia .config

CONFIG_NET_VENDOR_NVIDIA=y

# CONFIG_FB_NVIDIA is not set

(chroot) livecd linux # grep -i parport .config

CONFIG_PARPORT=m

CONFIG_PARPORT_PC=m

CONFIG_PARPORT_SERIAL=m

CONFIG_PARPORT_PC_FIFO=y

CONFIG_PARPORT_PC_SUPERIO=y

# CONFIG_PARPORT_PC_PCMCIA is not set

# CONFIG_PARPORT_GSC is not set

CONFIG_PARPORT_AX88796=m

CONFIG_PARPORT_1284=y

CONFIG_PARPORT_NOT_PC=y

# CONFIG_I2C_PARPORT is not set

# CONFIG_I2C_PARPORT_LIGHT is not set

# CONFIG_V4L_ISA_PARPORT_DRIVERS is not set
```

Concerning ahci, it is not present in the lspci, from the LiveDVD nor from the chroot :

```
livecd ~ # lspci -vv | grep -i ahci

(chroot) livecd linux # lspci -vv | grep -i ahci
```

Here is what is set/unset in the .config :

```
(chroot) livecd linux # grep -i ahci .config

CONFIG_SATA_AHCI=y

# CONFIG_SATA_AHCI_PLATFORM is not set

# CONFIG_SATA_ACARD_AHCI is not set
```

Why do you say "you have disable AHCI" ? Why is it relevant to my hardware ? Thought, I am going to try to reboot after rebuilding the kernel with CONFIG_SATA_AHCI_PLATFORM and CONFIG_SATA_ACARD_AHCI set.....

Concerning Windows, there is no problem. It boots and works as expected.

----------

## lalebarde

 *krinn wrote:*   

> I would say you have disable AHCI and your controller now run in legacy mode thru intel ata_piix driver.
> 
> While i suppose previously your controller was running AHCI and handle thru ahci driver.

 

Same problem and error message with the kernel rebuilt with the three AHCI entries set.

----------

## NeddySeagoon

lalebarde,

I am troubled by your lspci. 

```
00:1f.2 IDE interface: Intel Corporation 5 Series/3400 Series Chipset 4 port SATA IDE Controller (rev 05) 
```

I'm surprised it mentions IDE.

Often this means that the BIOS is set to 'compatibility' or 'IDE' mode. Go into the BIOS and check.  If you have AHCI mode, choose that, if not anything other than compatability or IDE mode will do.

The IDE mode is intended to be used just once by windows users, so that they can install the AHCI driver, then switch out of IDE mode forever.

On some chipsets, IDE mode is only partially functional. Not all SATA ports work, there is often no DMA, so its very slow ... but its not intended for everyday use.

When you switch out of IDE mode, Windows may break.  Go back into IDE mode and install its AHCI drivers. 

Your dmesg tells that you have USB debug on - thats lots of logspam that sometimes interferes with USB device operation.

Turn it off in your kernel.

----------

## lalebarde

It is strange, I don't have the IDE option in my BIOS. I had looked everywhere, especially of course where the hard disks are set up. I have only the choice between ATA and RAID. ATA is selected, what correspond to my usage.

----------

## NeddySeagoon

lalebarde,

Choose RAID in your BIOS but do not set up any raid devices.  Everything should work as before but I suspect you will need the AHCI driver now.

lspci may even change the IDE in 

```
00:1f.2 IDE interface: Intel Corporation 5 Series/3400 Series Chipset 4 port SATA IDE Controller (rev 05) 
```

----------

## lalebarde

Unfortunatly, I still have the same error. It seems that from Dell Support, the last BIOS available for my PC does not support AHCI. I saw in some forums that some have it, but probably on more recent models.

----------

## NeddySeagoon

lalebarde,

Lets start from the beginning.

Please post your lspci output and put your current kernel .config file onto a pastebin.

----------

## lalebarde

Hi NeddySeagoon,

With RAID set in the BIOS, it tells me my disks are not RAID ones and asks me to set up them as RAID, or to reset them as not RAID. I am afraid this is unsafe. Then, I set back ATA in the BIOS. 

Here is as requested :

lspci : http://pastebin.com/DeDKKiKL

lspci -vv : http://pastebin.com/hjvD7TeD

/usr/src/linux/.config : http://pastebin.com/NwAbZKzu

dmesg : http://pastebin.com/k3ZQBvN6

----------

## NeddySeagoon

lalebarde,

Your dmesg only shows that USB debug is on.

Lets live with ATA mode then.  I thought your SATA chipset provided AHCI mode but no matter, we wiil assume that ATA mode is fully functional..

```
00:1f.2 IDE interface: Intel Corporation 5 Series/3400 Series Chipset 4 port SATA IDE Controller (rev 05)

00:1f.5 IDE interface: Intel Corporation 5 Series/3400 Series Chipset 2 port SATA IDE Controller (rev 05)
```

These two interfaces need the same driver, as lspci shows, its ata_piix, which is on in your kernel 

```
CONFIG_ATA_PIIX=y
```

SCSI is there, along with SCSI disk and SCSI CDROM

You have lots of Partition table support, including MSDOS and GPT, which are the only two that matter on a PC.  

Thats enough to find your HDD.

Going back to your original error, the no modules to load is expected.  You need none to mount root.

```
/init: line 256: setup_hotplug: not found

-- edit --  

Does the kernel, without the initramfs find your HDD ?

It should.  It may not boot properly but a failure after root was located/mounted would confirm its initramfs problems.

>> Skipping module load; no modules in the ramdisk!

>> Hint: use parameter scandelay [=seconds]

/init: line 286: start_dev_mgr: not found

>> Determining root device...

!! Block device /dev/sda6 is not a valid root device

!! Could not find the root block device in .
```

As the kernel looks OK, it must be the initramfs.

-- edit --

Try booting without the aid of the initramfs.  It may well fail but thats OK.  Does it detect your HDD, everything needed is built in ?

----------

## lalebarde

 :Very Happy:   :Very Happy:   :Very Happy:   :Very Happy:   :Very Happy: 

It works without the initramfs ! How is it possible ? 

Here is my grub entry :

```
title G-3.3.8-wifi-kvm no initramfs - rootfstype=ext4

root (hd0,4)

kernel /boot/kernel-gentoo-sources-3.3.8-wifi-kvm root=/dev/sda6 rootfstype=ext4
```

Thanks a lot NeddySeagoon   :Wink: 

----------

## NeddySeagoon

lalebarde,

The initramfs is a fake root filesystem that was originally used to hold things needed to mount the real root filesystem.

It is also used for userspace software you would like to have very early in the boot process, before the real root is mounted.

Provided you don't actually need any of those things, your initramfs can be missing.

For booting to work with no initramfs, the kernel has to be able to mount root with no outside help, that means all the options needed must be set to <*> in menuconfig.

Your kernel satisfies that - so it works.

I use root on lvm2 on raid5, so I need an initramfs that assembles the raid and starts the logical volumes, all of which needs userspace tools, before my root can be mounted. You don't have those complications.

----------

## lalebarde

Thanks for the explanation. I read I need it if /usr is on a separate partition with kernels >= 3, and for recent udev [1, 2] :

[1] : http://www.gentoo.org/doc/en/initramfs-guide.xml

[2] : http://wiki.gentoo.org/wiki/Early_Userspace_Mounting

During my issue resolution, I upgraded to udev-200. Possibly udev requirements have lowered ? Or possibly I did not need initramfs at all ?

Anyway, it seems that my initramfs build process is broken. But that's enough for now.

Big thanks again NeddySeagoon. Like we say in french : « Vous m'avez retiré une sacrée épine du pied » (you have pulled a hell of a thorn from my side / a monkey from my back).

----------

## NeddySeagoon

lalebarde,

Without wishing to start a flamewar, since udev was forked (there are at least two forks) the udev devs do seem to be more tolerant of not breaking things on a whim so often.  I don't know if thats cause and effect though.

For completeness, the separate /usr problems are not related to udev.  For some time now, there has been a trend to move things out of / to /usr.  udev brought that to eveyones attention when it stopped papering over the / -> /usr cracks.  It was not the cause.

----------

