[CentOS7] RAID not building on boot

If you use software RAID at boot time, either for your /boot or / partition, it may not assemble at the correct time and prevent a successful boot. This can be confusing to track down as a cause if one RAID that’s a physical volume of a volume group assembles but another PV in the same volume group doesn’t. You’ll see an error like this:

Buffer I/O error on device dm-[some device], logical block [some number]

The RAIDs that are assembled at boot are specified in the RAID options. You can add them to the default options so it’s always there whenever you add a new kernel.

First, get a list of your RAID devices (from rescue mode):

# mdadm –examine –scan

ARRAY /dev/md/0  metadata=1.0 UUID=07c6d4fe:cedd2a76:e7c2a387:be4c3486 name=localhost:0

ARRAY /dev/md/1  metadata=1.2 UUID=46793e20:f9dc8f57:a67c2cc9:d05bca87 name=localhost:1

ARRAY /dev/md/2  metadata=1.2 UUID=cda9acb6:7ccf0e86:f4e12842:961e07a9 name=localhost:2

In this particular case I’ve run in to the first two were already set in the grub defaults but not the last one.

# cat /etc/default/grub | grep GRUB_CMDLINE_LINUX

GRUB_CMDLINE_LINUX=”crashkernel=auto rd.md.uuid=46793e20:f9dc8f57:a67c2cc9:d05bca87 rd.lvm.lv=vg_slash/lv_slash rd.md.uuid=07c6d4fe:cedd2a76:e7c2a387:be4c3486 rhgb quiet rd.auto rd.auto=1″

Edit the file and add the UUID of the RAID device you want to assemble at boot time to the cmdlink with the rd.md.uuid option. Afterwards that line should look like this:

GRUB_CMDLINE_LINUX=”crashkernel=auto rd.md.uuid=46793e20:f9dc8f57:a67c2cc9:d05bca87 rd.lvm.lv=vg_slash/lv_slash rd.md.uuid=07c6d4fe:cedd2a76:e7c2a387:be4c3486 rhgb quiet rd.auto rd.auto=1 rd.md.uuid=cda9acb6:7ccf0e86:f4e12842:961e07a9″

Once you’ve done that you’ll need to rebuild your grub config:

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

This will change the options for all of the kernel options in your grub conf. At this point you’re all set and you can reboot normally.