On 1/1/21 10:28 AM, c.buhtz@xxxxxxxxx wrote:
In the last weeks I played around with mdadm - on VMs, Odroid-Devices, PCs - all with Debian 10. I observed a (for me) curious behavior about the naming of RAID devices. I did "--create /dev/md0" all the time. But sometimes it results in /dev/md127. Sometimes it is /dev/md/0. Sometimes it switches between upgrade of the kernel image (/dev/md127 become /dev/md0 and booting fails). Googleing this topic brings up a lot of other users discussing about that problem. My current solution is to ignore the /dev/*-name and mount the device/partition by its UUID. Another often reported "solution" is to edit the mdadm.conf. But this is not a good solution for me. mdadm looks in the superblock and knows (nearly) everything. Each conf-file I need to edit keeps the possibility for errors/mistakes/faults (because I am not a sysop/admin but a simple home-server-wannabe-admin).
Most distros incrementally assemble raid arrays during early boot, before the real root filesystem is mounted. By itself, with no mdadm.conf guidance, mdadm will assign names to arrays starting with md127 and counting backwards. And will process all arrays found.
I recommend creating an mdadm.conf file containing ARRAY entries for your desired setup. Trim those lines to only have the desired name and UUID.
Have your distro then rebuild your initramfs (distro-specific) so the updated mdadm.conf is available during early boot. Reboot to see that it worked.
Once you are sure it works, I also recommend adding AUTO=-all to mdadm.conf, so any extra arrays you might plug in temporarily won't auto-assemble if still plugged in during boot.
Phil