# mdadm root mount problem with genkernel-3.4.18 linux-3.0.x

## drescherjm

While testing a brand new server, I am having problems with automounting the / as a raid 1 array using a genkernel-3.4.18 initramfs. I am using grub2 which is using uuids for the raid 1 array. The basic problem is I have 3 arrays with 1.2 metadata and the initramfs is trying to assembly a raid6 array instead of the raid 1 array for / so I get the prompt for the root device. At that point the correct array is not mounted and I need to use the shell and execute

mdadm -A /dev/md1 /dev/sd[gh]3 

then exit and all is well with the boot.

I just noticed something. For some reason the /etc/mdadm.conf is not being added to the initramfs.

```
*** End of the configuration.

*** Execute 'make' to start the build or try 'make help'.

*         >> Compiling 3.0.4-gentoo-btrfs bzImage...

*         >> Not installing firmware as it's included in the kernel already (CONFIG_FIRMWARE_IN_KERNEL=y)...

*         >> Compiling 3.0.4-gentoo-btrfs modules...

* Copying config for successful build to /etc/kernels/kernel-config-x86_64-3.0.4-gentoo-btrfs

* blkid: >> Using cache

* busybox: >> Using cache

* initramfs: >> Initializing...

*         >> Appending base_layout cpio data...

*         >> Appending auxilary cpio data...

*         >> Appending busybox cpio data...

*         >> Appending lvm cpio data...

*           LVM: Adding support (using local static binary /sbin/lvm.static)...

*         >> Appending mdadm cpio data...

*               MDADM: Skipping inclusion of mdadm.conf

*               MDADM: Adding support (compiling binaries)...

*               MDADM: Using cache

*         >> Appending modules cpio data...

*         >> Appending blkid cpio data...

*

* Kernel compiled successfully!

*

* Required Kernel Parameters:

*     real_root=/dev/$ROOT

*

*     Where $ROOT is the device node for your root partition as the

*     one specified in /etc/fstab

*

* If you require Genkernel's hardware detection features; you MUST

* tell your bootloader to use the provided INITRAMFS file. Otherwise;

* substitute the root argument for the real_root argument if you are

* not planning to use the initramfs...

* WARNING... WARNING... WARNING...

* Additional kernel cmdline arguments that *may* be required to boot properly...

* add "dolvm" for lvm support

* add "domdadm" for RAID support

* Do NOT report kernel bugs as genkernel bugs unless your bug

* is about the default genkernel configuration...

*

* Make sure you have the latest ~arch genkernel before reporting bugs.
```

Could that be the problem? 

I do have an /etc/mdadm.conf

```
fileserver1 genkernel # cat /etc/mdadm.conf

ARRAY /dev/md1 level=raid1 num-devices=2 metadata=1.2 name=fileserver1:1 UUID=9259c35d:c9b5488e:5b63f292:5568dfe5

   devices=/dev/sdg3,/dev/sdh3

ARRAY /dev/md2 level=raid6 num-devices=8 metadata=1.2 name=fileserver1:0 UUID=b5a0c3f9:b3da4dec:e101d55c:a18dc26f

   devices=/dev/sda1,/dev/sdc1,/dev/sdd1,/dev/sdb1,/dev/sdi1,/dev/sde1,/dev/sdj1,/dev/sdf1

ARRAY /dev/md3 level=raid1 num-devices=2 metadata=1.2 name=fileserver1:3 UUID=df2200d4:3ba5d29c:524dc437:35d663ea

   devices=/dev/sdg4,/dev/sdh4

```

Also I see that it is trying to mount the hostname:0 array and my / is on hostname:1

Could that the problem?

----------

## drescherjm

Here is the grub2 menuentry

```
menuentry 'GNU/Linux, with Linux x86_64-3.0.4-gentoo-btrfs (recovery mode)' --class gnu-linux --class gnu --class os {

        load_video

        insmod gzio

        insmod part_gpt

        insmod ext2

        set root='(hd6,gpt2)'

        search --no-floppy --fs-uuid --set=root c00bbe5d-5e65-4b89-a200-f77011ac0cb7

        echo    'Loading Linux x86_64-3.0.4-gentoo-btrfs ...'

        linux   /kernel-genkernel-x86_64-3.0.4-gentoo-btrfs root=UUID=31e0492a-b031-4601-adf2-c789d1a01a9d ro single

        echo    'Loading initial ramdisk ...'

        initrd  /initramfs-genkernel-x86_64-3.0.4-gentoo-btrfs

}
```

```
fileserver1 genkernel # blkid | grep /dev/md1

/dev/md1: UUID="31e0492a-b031-4601-adf2-c789d1a01a9d" TYPE="ext4"

```

----------

## mp342

 *drescherjm wrote:*   

> Here is the grub2 menuentry

 

I'm not familiar with grub2 but here are some things you can do:

- Check all your partition for the correct type (linux raid autodetect = fd)

- If you use the whole disks, I think you need the domdadm option. With grub, the option is set in the kernel line. it should be the same with grub2, probably in the linux line.

- Add your mdadm.conf file to your initrd with the "MDADM_CONFIG=" option in /etc/genkernel.conf

----------

## drescherjm

 *mp342 wrote:*   

> I'm not familiar with grub2 but here are some things you can do:
> 
> - Check all your partition for the correct type (linux raid autodetect = fd)
> 
> 

 

The two disks that have the raid 1 are gpt. With their partitions of type fd00.

 *Quote:*   

> 
> 
> - If you use the whole disks, I think you need the domdadm option. With grub, the option is set in the kernel line. it should be the same with grub2, probably in the linux line.

 

I have the domdadm added.

Edit: Hmm, looks like that did not get to the grub2 menuentry. I will check in that..

 *Quote:*   

> 
> 
> - Add your mdadm.conf file to your initrd with the "MDADM_CONFIG=" option in /etc/genkernel.conf

 

Thanks. I now got that one to work.. Inside the busybox shell I can now do

mdadm -A /dev/md1 

and the array starts. However It still insists on trying to start /dev/md2 instead so I get the boot prompt still..

----------

## drescherjm

Ahh. I posted the wrong menuitem. domdadm is enabled.

```
menuentry 'GNU/Linux, with Linux x86_64-3.0.4-gentoo-btrfs' --class gnu-linux --class gnu --class os {

        load_video

        insmod gzio

        insmod part_gpt

        insmod ext2

        set root='(hd6,gpt2)'

        search --no-floppy --fs-uuid --set=root c00bbe5d-5e65-4b89-a200-f77011ac0cb7

        echo    'Loading Linux x86_64-3.0.4-gentoo-btrfs ...'

        linux   /kernel-genkernel-x86_64-3.0.4-gentoo-btrfs root=UUID=31e0492a-b031-4601-adf2-c789d1a01a9d ro  domdadm

        echo    'Loading initial ramdisk ...'

        initrd  /initramfs-genkernel-x86_64-3.0.4-gentoo-btrfs

}

```

----------

## mp342

 *drescherjm wrote:*   

> Ahh. I posted the wrong menuitem. domdadm is enabled.
> 
> ```
> menuentry 'GNU/Linux, with Linux x86_64-3.0.4-gentoo-btrfs' --class gnu-linux --class gnu --class os {
> 
> ...

 

Perhaps a silly question (I don't know grub2   :Smile:  ) but why do you have 2 different uuid ?

----------

## mp342

Just remembered a previous thread. Check this guide :

http://dev.gentoo.org/~scarabeus/grub-2-guide.xml

It's a work in progress but it contains useful informations.

----------

## drescherjm

That I do not know. This is only my first day with grub2 working. This script is generated from grub2-mkconfig

With that said I see that this is my /boot

/dev/sdg2: UUID="c00bbe5d-5e65-4b89-a200-f77011ac0cb7" TYPE="ext2"

If you want to know why on earth /boot is on /dev/sdg2 after testing I intend to remove the 8 drive 512GB raid 6 array and replace it with a production 8 drive 1 TB raid 6 array and those drives will have the boot. I can't test on the production box however.

----------

## drescherjm

 *mp342 wrote:*   

> Just remembered a previous thread. Check this guide :
> 
> http://dev.gentoo.org/~scarabeus/grub-2-guide.xml
> 
> It's a work in progress but it contains useful informations.

 

Thanks. I see they did a little different with the efi partition. Although that part has to be working since grub does show up..

----------

## drescherjm

 *Quote:*   

> Add your mdadm.conf file to your initrd with the "MDADM_CONFIG=" option in /etc/genkernel.conf

 

That with the addition of a scandelay of 5 seconds seems to have fixed the issue. Without the scan delay arrays were starting degraded. 

Is there a way in genkernels initrd to prevent it from trying to start arrays degraded so this does not unnecessarily degrade my arrays if 5 seconds is not enough?

----------

