If you want to use software raid device in your Gentoo Linux system (init boot, not systemd) with boot partition resided in the raid for better redundancy but using metadata 1.2 version you won’t have autodetection feature on boot and there are some additional steps you may consider!
Linux kernel’s autodetection feature of the software raid is only for superblock (metadata) version 0.90!
If you create a software raid with superblock version 1, 1.1 or 1.2 you want to boot from it you must use:
- Grub 2, lilo won’t load the kernel from such paritions.
- include mdadm in initramfs
- initramfs booted with aditional parameter “domdadm” (in fact, it is not a “native” kernel option, read below)
Here is our setup, two partitions on our two hard drives:
Number Start End Size File system Name Flags 1 1049kB 4194kB 3146kB primary boot, esp 2 4194kB 21.5GB 21.5GB primary raid
One small for the UEFI boot and one partition for the root (and boot). We created the software raid with superblock metadata 1.2 version:
mdadm --create --verbose --metadata=1.2 /dev/md0 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2
The Linux kernel’s autodetect is not going to work!
The kernel will load, but it won’t find your root file system so no init process to start your system!
Determining root device ... !! Could not find the root block device in UUID=b21c64a2-89df-4be5-9e6e-c0d622dc09a0. !! Please specify another value or: !! - press Enter for the same !! - type "shell" for a shell !! - type "q" to skip...
Here is a screenshot of the boot error:
To solve the above problem:
- include mdadm tool in initramfs – use genkernel for Gentoo, dracut for CentOS 7 and update-initramfs for Ubuntu
- add “domdadm” to the initramfs’ additional boot parameters in grub.cfg – the easy way is to add it in /etc/default/grub variable GRUB_CMDLINE_LINUX variable and generate the grub.cfg. In fact “domdadm” is a parameter, which instructs the init script of initramfs to call mdadm with scan and assemble options. You can check it by unpacking your initramfs file and look for “/init” script and “/etc/initrd.scripts”.
Here is what you may do with your Gentoo:
localhost ~ # cat /etc/default/grub |grep GRUB_CMDLINE_LINUX GRUB_CMDLINE_LINUX="domdadm" localhost ~ # genkernel --mdadm --no-clean --no-mrproper initramfs * Gentoo Linux Genkernel; Version 3.5.3.3 * Running with options: --mdadm --no-clean --no-mrproper initramfs * Using genkernel.conf from /etc/genkernel.conf * Sourcing arch-specific config.sh from /usr/share/genkernel/arch/x86_64/config.sh .. * Sourcing arch-specific modules_load from /usr/share/genkernel/arch/x86_64/modules_load .. * Linux Kernel 5.0.3-gentoo for x86_64... * .. with config file /etc/kernels/kernel-config-x86_64-5.0.3-gentoo * busybox: >> Using cache * initramfs: >> Initializing... * >> Appending devices cpio data... * >> Appending base_layout cpio data... * >> Appending auxilary cpio data... * >> Copying keymaps * >> Appending busybox cpio data... * >> 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... * >> Appending modprobed cpio data... * >> Appending linker cpio data... * >> Deduping cpio... * >> Compressing cpio data (.xz)... * WARNING... WARNING... WARNING... * Additional kernel cmdline arguments that *may* be required to boot properly... * add "domdadm" for RAID support * With support for several ext* filesystems available, it may be needed to * add "rootfstype=ext3" or "rootfstype=ext4" to the list of boot parameters. * 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. localhost ~ # grub-mkconfig -o /boot/grub/grub.cfg Generating grub configuration file ... Found linux image: /boot/kernel-genkernel-x86_64-5.0.3-gentoo Found initrd image: /boot/initramfs-genkernel-x86_64-5.0.3-gentoo done
The partitions layout of the two disks
localhost ~ # parted /dev/sda GNU Parted 3.2 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p Model: ATA SATA SSD (scsi) Disk /dev/sda: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 4194kB 3146kB primary boot, esp 2 4194kB 21.5GB 21.5GB primary raid (parted) q localhost ~ # parted /dev/sdb GNU Parted 3.2 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p Model: ATA SATA SSD (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 1049kB 4194kB 3146kB primary boot, esp 2 4194kB 21.5GB 21.5GB primary raid (parted) q
Bonus
Install grub 2. Here the command if you need to install the grub 2:
UEFI boot mode:
grub-install --efi-directory=/boot/efi/ --target=x86_64-efi /dev/sda
BIOS legacy mode:
grub-install /dev/sda
Hint: do it for the two disks – sda and sdb. You should mount /dev/sda1 (/boot/efi) and /dev/sdb1 (/mnt/efi for example) and copy the all the files from /boot/efi to the /mnt/efi.
Bonus Systemd
Systemd replaces the init boot and it starts “mdmon@.service”, which scans and assembles the mdadm devices. So you do not need to boot with this “domdadm” parameter. We also tested in a CentOS 7 system and you do not need this option. As said before this option “domdadm” is only instructing the initramfs init script to call mdadm with scan and assemble.