Re: naming system of raid devices
flat view
From: antlists <hidden>
Date: 2021-01-01 20:02:13
On 01/01/2021 15:28, c.buhtz@posteo.jp 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). My Question is how this names come up? How does mdadm, the kernel or what ever component is responsible here, decide about the "name" of a raid device? And which factors influence the re-nameing of such devices (e.g. between boot or kernel-updates)?
The kernel and/or mdadm decides the same way it decides what drive is sda, sdb, etc, in that it is COMPLETELY RANDOM. Yes, the dice normally fall the same way and names are consistent, but numbers now normally always count down from 127. (I think that's so we can count down from 32,000 if we need to... :-) For example, because I have just two, mirrored, drives, it doesn't matter which one appears first the arrays count down consistently so eg root is always md127. But that's a quirk of my system. The recommended way with mdadm is to create named arrays, eg /dev/md/root or /dev/md/home. Cheers, Wol