I'm trying to create 4 RAID 0 disk arrays on my system running Centos 7.5 and have the RAIDs automount after a reboot. For some reason, only one of the RAIDs /dev/md0 is persistent between boots. The remaining three RAIDs (md1,md2,md3) all disappear after a reboot.
I build the RAIDs using:
$ sudo mdadm --create --chunk 4096 --verbose /dev/md0 --level=stripe \
--raid-devices=2 /dev/nvme0n1 /dev/nvme1n1
$ sudo mdadm --create --chunk 4096 --verbose /dev/md1 --level=stripe \
--raid-devices=2 /dev/nvme2n1 /dev/nvme3n1
$ sudo mdadm --create --chunk 4096 --verbose /dev/md2 --level=stripe \
--raid-devices=2 /dev/nvme4n1 /dev/nvme5n1
$ sudo mdadm --create --chunk 4096 --verbose /dev/md3 --level=stripe \
--raid-devices=2 /dev/nvme6n1 /dev/nvme7n1
Then I update the /etc/mdadm.conf
file using:
$ mdadm --detail --scan >> /etc/mdadm.conf
Finally after mounting the drives to their appropriate directory and adding them to /etc/fstab
I rebuilt the initramfs image using dracut
:
$ sudo dracut --force --mdadmconf
After running dracut
, I reboot the system and /dev/md0
is there but the other RAIDs are not, so I did some investigating and it seems like /etc/mdadm.conf
is not being included in the initramfs, so I repeated all of the previous steps, except for the dracut
command I manually added what seemed to be missing using:
$ sudo dracut --force --include /etc/mdadm.conf /etc/mdadm.conf \
--add="mdraid" --mdadmconf`
After running the command, I see that /etc/mdadm.conf
and /usr/sbin/mdadm
are included in the initramfs using:
$ sudo lsinitrd /boot/initramfs-$(uname -r).img
What am I missing?
Edit 1
I've added mdadm –assemble –scan to /etc/rc.local and tried running it from the command line once the system has booted, but md1, md2, and md3 still are not found. As before, md0 is found at boot.
I have a separate OS disk, so I am not booting from md0
Best Answer
The initrd only creates the RAID array needed for root and swap. Run this from the main system (after initrd changes to the real root)