On Wed, May 27, 2015 at 8:01 PM, Peter Humphrey <pe...@prh.myzen.co.uk> wrote:
>
> My mdadm.conf is now this:
> DEVICE /dev/sd[ab]1
> DEVICE /dev/sd[ab]5
> DEVICE /dev/sd[ab]7
> ARRAY /dev/md1 devices=/dev/sda1,/dev/sdb1
> ARRAY /dev/md5 devices=/dev/sda5,/dev/sdb5
> ARRAY /dev/md7 devices=/dev/sda7,/dev/sdb7
>
> I'll see how that goes; so far no complaints about finding no arrays in the
> config file. I've never used UUIDs, preferring to be able to read what I'm
> specifying.
>

The problem with this sort of approach is that you're hard-coding
device names.  If for whatever reason your devices are lettered
differently, mdadm may not assemble the array.

Here is an example of one of my old mdadm.conf files:
DEVICE /dev/sd[abcdefgh][12345] /dev/hd[abcde][12345]
#ARRAY /dev/md126 UUID=e424848a:593e3c8e:0e120ac2:958f662e
#ARRAY /dev/md124 UUID=dae2458d:e144dbde:34d5107b:2f8c859e
#ARRAY /dev/md127 UUID=4096c546:a0d9d5c4:5063dd02:38d16c75

This tells mdadm to scan all those permutations of device names, find
anything with those UUIDs and attempt to assemble the arrays, giving
them the preferred minor numbers.

Some of those device names probably don't even exist (not all of those
drives have 5 partitions, etc).  It doesn't matter - mdadm just checks
the ones that do exist.  Then if for whatever reason sdd is now hdc it
doesn't matter.

With an approach like yours, mdadm will attempt to create md1 by
looking ONLY at sda1 and sdb1, and if that pair forms a valid array it
is started, and if not it is not.  If you add a new drive to your
system or for whatever reason the kernel/udev rules change a little or
some race condition changes a little then your devices might get
different names, and the array will not be assembled.

UUIDs are often preferable in these kinds of configurations, because
you're less likely to run into duplicate identifiers, they don't
change, and so on.  If I mount root=UUID=foo, then my initramfs will
try really hard to find that partition and mount it.  If I mount
root=label=foo then it will still try hard, but if for some reason I
have more than one device with that label I could end up booting from
the wrong one.  If I mount root=/dev/sda1 then my boot may fail if I
add a new drive, if the kernel behavior changes, if the udev behavior
changes, and so on.

I don't believe either the kernel or udev makes promises about device
names being stable.  It often works out this way, but it isn't ideal
to depend on this.

-- 
Rich

Reply via email to