# grub-mkconfig do not see initramfs rootfs in not a valid dev

## emc

First I have running and booting system, I try to genkernel newer kernel I repeat steps from previous successful compilation and booting, but in the end I can boot new kernel / rootfs can't be mount:

I'm using LVM2 on top of RAID5 with 3HDD

1. got .confg from current running kernel 4.14.52-gentoo (and check with  zcat /proc/config.gz > .config.running)

2. try compile 4.14.83-gentoo

3. run make oldconfig maually (diff is minimal 2-3 options)

4. genkernel --lvm --mdadm --microcode --install --menuconfig --kernname=variant07 --loglevel=3 --color all

5. compilation success

6. ls -la /boot/

```
drwxr-xr-x  6 root root     1024 Jan  5 15:50 grub

-rw-r--r--  1 root root  8155156 Jul 29 00:39 initramfs-genkernel-x86_64-4.14.52-gentoo

-rw-r--r--  1 root root 11815756 Jan  2 23:47 initramfs-variant05-x86_64-4.14.83-gentoo

-rw-r--r--  1 root root 11112912 Jan  5 14:18 initramfs-variant06-x86_64-4.14.83-gentoo

-rw-r--r--  1 root root 13255528 Jan  5 15:39 initramfs-variant07-x86_64-4.14.83-gentoo

-rw-r--r--  1 root root  6132272 Jul 29 00:05 kernel-genkernel-x86_64-4.14.52-gentoo

-rw-r--r--  1 root root  3957200 Jan  2 23:23 kernel-variant05-x86_64-4.14.83-gentoo

-rw-r--r--  1 root root  3588560 Jan  5 14:17 kernel-variant06-x86_64-4.14.83-gentoo

-rw-r--r--  1 root root  6480448 Jan  5 15:02 kernel-variant07-x86_64-4.14.83-gentoo

drwx------  2 root root    12288 Jul 28 16:22 lost+found

-rw-r--r--  1 root root  3009193 Jul 29 00:05 System.map-genkernel-x86_64-4.14.52-gentoo

-rw-r--r--  1 root root  3037192 Jan  2 23:23 System.map-variant05-x86_64-4.14.83-gentoo

-rw-r--r--  1 root root  2763365 Jan  5 14:17 System.map-variant06-x86_64-4.14.83-gentoo

-rw-r--r--  1 root root  3140653 Jan  5 15:02 System.map-variant07-x86_64-4.14.83-gentoo
```

And here is tricky part after rebooting kernel stops just after 1 or 2 sceens...

```
kernel panic not syncing: VFS: Unable to mount root fs on unknown-block(0,0)
```

got me thinking initramfs??? and teh after 10 tries of compiing kernel I noticed ont thing

7. grub-mkconfig -o /boot/grub/grub.cfg

```
Generating grub configuration file ...

Found linux image: /boot/kernel-variant07-x86_64-4.14.83-gentoo

Found linux image: /boot/kernel-variant06-x86_64-4.14.83-gentoo

Found linux image: /boot/kernel-variant05-x86_64-4.14.83-gentoo

Found linux image: /boot/kernel-genkernel-x86_64-4.14.52-gentoo

Found initrd image: /boot/initramfs-genkernel-x86_64-4.14.52-gentoo

done
```

See, grub-mkconfig do not see initramfs, so I've added manually to grub.cfg: 

```
initrd  /initramfs-variant07-x86_64-4.14.83-gentoo
```

8. after rebooting is better but then got:

```
some modules are loading..

>> Scanning for and activating Volume Groups

Reading all phsical volumes. This may take a while...

>> Determining root device...

!! Block device /dev/mapper/vg01-rootfs in not a valid device...

!! Could not find the root block device in .

!! Please specify another values for:

!! - pres enter for the same

!! - type shell for a shell

!! - type q to skip
```

here is my /etc/defaults/grub:

```
GRUB_DISTRIBUTOR="Gentoo"

GRUB_TIMEOUT=5

GRUB_CMDLINE_LINUX_DEFAULT="dolvm domdadm rootfstype=ext4"

GRUB_DISABLE_SUBMENU=y
```

in /etc/genkernel I got:

```
INSTALL="yes"

OLDCONFIG="yes"

MENUCONFIG="yes"

GCONFIG="no"

NCONFIG="no"

XCONFIG="no"

CLEAN="no"

MRPROPER="no"

MOUNTBOOT="yes"

SAVE_CONFIG="yes"

USECOLOR="yes"

MAKEOPTS="$(portageq envvar MAKEOPTS)"

NICE=10

LVM="yes"

MICROCODE="yes"

MDADM="yes"

MDADM_CONFIG="/etc/mdadm.conf"

DISKLABEL="yes"

BOOTLOADER="grub2"

GK_SHARE="${GK_SHARE:-/usr/share/genkernel}"

CACHE_DIR="/var/cache/genkernel"

DISTDIR="${GK_SHARE}/distfiles"

LOGFILE="/var/log/genkernel.log"

LOGLEVEL=3

# =========COMPILED UTILS CONFIGURATION============

#

# Default location of kernel source

DEFAULT_KERNEL_SOURCE="/usr/src/linux"
```

/etc/mdadm.conf

```
ARRAY /dev/md0 metadata=1.2 name=livecd:0 UUID=5a5b7bcb:b208c3fe:1b53ce5e:2d587893
```

/etc/fstab

```
# <fs>                  <mountpoint>    <type>  <opts>                  <dump/pass>

/dev/sda2               /boot           ext2    defaults,noatime        0 2

/dev/vg01/swap          none            swap    sw                      0 0

/dev/vg01/rootfs        /               ext4    noatime                 0 1

/dev/sr0                /mnt/cdrom      auto    noauto,user             0 0
```

Running kernel form grub.cfg

```
menuentry 'Gentoo GNU/Linux, with Linux x86_64-4.14.52-gentoo (recovery mode)' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-x86_64-4.14.52-gentoo-recovery-141f992c-a8ce-4fa2-8f40-602954b1e300' {

        load_video

        if [ "x$grub_platform" = xefi ]; then

                set gfxpayload=keep

        fi

        insmod gzio

        insmod part_msdos

        insmod ext2

        set root='hd0,msdos2'

        if [ x$feature_platform_search_hint = xy ]; then

          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2  b085fb37-5c2e-475a-81f8-6ab233b80981

        else

          search --no-floppy --fs-uuid --set=root b085fb37-5c2e-475a-81f8-6ab233b80981

        fi

        echo    'Loading Linux x86_64-4.14.52-gentoo ...'

        linux   /kernel-genkernel-x86_64-4.14.52-gentoo root=/dev/mapper/vg01-rootfs ro single

        echo    'Loading initial ramdisk ...'

        initrd  /initramfs-genkernel-x86_64-4.14.52-gentoo

}
```

not running

```
menuentry 'Gentoo GNU/Linux, with Linux variant07-x86_64-4.14.83-gentoo' --class gentoo --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-variant07-x86_64-4.14.83-gentoo-advanced-141f992c-a8ce-4fa2-8f40-602954b1e300' {

        load_video

        insmod gzio

        insmod part_msdos

        insmod ext2

        set root='hd0,msdos2'

        if [ x$feature_platform_search_hint = xy ]; then

          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos2 --hint-efi=hd0,msdos2 --hint-baremetal=ahci0,msdos2  b085fb37-5c2e-475a-81f8-6ab233b80981

        else

          search --no-floppy --fs-uuid --set=root b085fb37-5c2e-475a-81f8-6ab233b80981

        fi

        echo    'Loading Linux variant07-x86_64-4.14.83-gentoo ...'

        linux   /kernel-variant07-x86_64-4.14.83-gentoo root=/dev/mapper/vg01-rootfs ro  dolvm domdadm rootfstype=ext4

}
```

They are almost exactly the same (just initrd par is missing as I mention)

Any advice I'm tired since 2 weeks I try update my kernel

----------

## ribx

mkconfig does not check for your initrd name:

see /etc/grub.d/10-linux

```
  for i in "initrd.img-${version}" "initrd-${version}.img" "initrd-${version}.gz" \

       "initrd-${version}" "initramfs-${version}.img" \

       "initrd.img-${alt_version}" "initrd-${alt_version}.img" \

       "initrd-${alt_version}" "initramfs-${alt_version}.img" \

       "initramfs-genkernel-${version}" \

       "initramfs-genkernel-${alt_version}" \

       "initramfs-genkernel-${GENKERNEL_ARCH}-${version}" \

       "initramfs-genkernel-${GENKERNEL_ARCH}-${alt_version}"; do

...

```

anyway, it "should" work if you add the initrd line manually.

Please note: RAID5 is kind of obsolete with todays storage capabilities. Problem is, if you have a RAID5 and a disc crashes, the chances that another disc dies while making the restore is quite high (as every block will be read/write for calculation of parity, no matter if it has real data on it or not). Also you could loose performance with SSDs. A better way is to use a filesystem like btrfs or zfs and handle the mirroring of file on the filesystem layer. thats much more effective and if two discs die, you still have some files remaining on the last disc. You could do the raid stuff also in the lvm layer, but then again with btrfs you can even get rid of the lvm layer. (and get nice features like snapshoting too)

----------

## emc

yeah should... dont know what can I do more... how to fix it  :Sad: 

regarding raid5 I just got spare 3hdd and just give a try... didn't know about it... I just return to gentoo after some years and I setup old desktop just for fun... so maybe I just start installing gentoo again from scrach... so what you recommend for 3 x 1TB HDD to get more then 1TB and get some mirroring.... I got found 64 GB SDD use it as bcache????

----------

## niku

For a similar error this one says that that the initramfs should be constructed with udev modules, and you have to do it yourself by adding the udev hook to mkinitcpio.conf (and then mkinitcpio yourself, I presume -- I have never used genkernel!). So, try lsinitcpio -a /path/to/initramfs.

The post has another valuable suggestion: try mounting /dev/mapper/vg01-rootfs directly and see what happens.

This one (from 2012), specifically says that mounting LV devices with an initrd created by genkernel will fail as genkernel does not use the udev hook.

Edit: sanity check via this.

Edit 2: You can see the contents of the initrd by 

```
cpio -idm --file initrd.img
```

----------

## emc

 *niku wrote:*   

> For a similar error this one says that that the initramfs should be constructed with udev modules, and you have to do it yourself by adding the udev hook to mkinitcpio.conf (and then mkinitcpio yourself, I presume -- I have never used genkernel!). So, try lsinitcpio -a /path/to/initramfs.
> 
> The post has another valuable suggestion: try mounting /dev/mapper/vg01-rootfs directly and see what happens.
> 
> This one (from 2012), specifically says that mounting LV devices with an initrd created by genkernel will fail as genkernel does not use the udev hook.
> ...

 

nice... mkinitcpio is nor officially supported... and make ebuild myself try to emerge and then and find out all the stuff with lvm/raid is not worth for me... to be honest... I will never have so much time.... to fix it. any way I need get my box up and running, (but so much to install mint) anyway I read more about btrfs on 3HDD... and make it more usable and maintainable. As I mention this desktop I just for fin to play with gentoo... again...

----------

## niku

An alternative to genkernel/mkinitcpio would be Dracut. Also, making custom initramfs.

----------

