Gentoo Archives: gentoo-user

From: Rich Freeman <rich0@g.o>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] General weirdness - a tale of woe.
Date: Thu, 28 May 2015 12:44:36
Message-Id: CAGfcS_mKZi4ODw=D+587KKJcvuutk-ojH21rT0a1Rc5SbHJn_w@mail.gmail.com
In Reply to: Re: [gentoo-user] General weirdness - a tale of woe. by Peter Humphrey
1 On Wed, May 27, 2015 at 8:01 PM, Peter Humphrey <peter@××××××××××××.uk> wrote:
2 >
3 > My mdadm.conf is now this:
4 > DEVICE /dev/sd[ab]1
5 > DEVICE /dev/sd[ab]5
6 > DEVICE /dev/sd[ab]7
7 > ARRAY /dev/md1 devices=/dev/sda1,/dev/sdb1
8 > ARRAY /dev/md5 devices=/dev/sda5,/dev/sdb5
9 > ARRAY /dev/md7 devices=/dev/sda7,/dev/sdb7
10 >
11 > I'll see how that goes; so far no complaints about finding no arrays in the
12 > config file. I've never used UUIDs, preferring to be able to read what I'm
13 > specifying.
14 >
15
16 The problem with this sort of approach is that you're hard-coding
17 device names. If for whatever reason your devices are lettered
18 differently, mdadm may not assemble the array.
19
20 Here is an example of one of my old mdadm.conf files:
21 DEVICE /dev/sd[abcdefgh][12345] /dev/hd[abcde][12345]
22 #ARRAY /dev/md126 UUID=e424848a:593e3c8e:0e120ac2:958f662e
23 #ARRAY /dev/md124 UUID=dae2458d:e144dbde:34d5107b:2f8c859e
24 #ARRAY /dev/md127 UUID=4096c546:a0d9d5c4:5063dd02:38d16c75
25
26 This tells mdadm to scan all those permutations of device names, find
27 anything with those UUIDs and attempt to assemble the arrays, giving
28 them the preferred minor numbers.
29
30 Some of those device names probably don't even exist (not all of those
31 drives have 5 partitions, etc). It doesn't matter - mdadm just checks
32 the ones that do exist. Then if for whatever reason sdd is now hdc it
33 doesn't matter.
34
35 With an approach like yours, mdadm will attempt to create md1 by
36 looking ONLY at sda1 and sdb1, and if that pair forms a valid array it
37 is started, and if not it is not. If you add a new drive to your
38 system or for whatever reason the kernel/udev rules change a little or
39 some race condition changes a little then your devices might get
40 different names, and the array will not be assembled.
41
42 UUIDs are often preferable in these kinds of configurations, because
43 you're less likely to run into duplicate identifiers, they don't
44 change, and so on. If I mount root=UUID=foo, then my initramfs will
45 try really hard to find that partition and mount it. If I mount
46 root=label=foo then it will still try hard, but if for some reason I
47 have more than one device with that label I could end up booting from
48 the wrong one. If I mount root=/dev/sda1 then my boot may fail if I
49 add a new drive, if the kernel behavior changes, if the udev behavior
50 changes, and so on.
51
52 I don't believe either the kernel or udev makes promises about device
53 names being stable. It often works out this way, but it isn't ideal
54 to depend on this.
55
56 --
57 Rich

Replies

Subject Author
Re: [gentoo-user] General weirdness - a tale of woe. Todd Goodman <tsg@×××××××××.net>
Re: [gentoo-user] General weirdness - a tale of woe. Peter Humphrey <peter@××××××××××××.uk>