3

I recently installed a new Debian 9 ("stretch") machine.

Initally it had 2 drives. I configured them as RAID1 using the Debian installer, and it gave me a /dev/md0 with

/etc/mdadm/mdadm.conf:

containing

# definitions of existing MD arrays
ARRAY /dev/md/0  metadata=1.2 UUID=3d21d0e0:2758c58e:962b5191:98e225c1 name=MYHOSTNAME:0

and /proc/mdstat showing:

md0 : active raid1 sda1[0] sdb1[1]
      488253440 blocks super 1.2 [2/2] [UU]
      bitmap: 0/4 pages [0KB], 65536KB chunk

That device I formatted as ext4 and mounted by UUID as '/' in /etc/fstab). All works fine, as expected.

Later I added a couple more even bigger drives. Partitioned them (with a small swap parition on each first) and configured them using mdadm -C -n 2 -l raid1 /dev/md1 /dev/sdc2 /dev/sdd2 (that's definitely what I did because it's still in my root's shell history, along with a couple of subsequent mdadm --examine /dev/md1 and mdadm --detail --verbose /dev/md1).

I also added a line to /etc/mdadm/mdadm.conf (just following the pattern for the initial device):

ARRAY /dev/md/1  metadata=1.2 UUID=47492bd7:08d1fd1c:418dad41:2aa7d77f name=MYHOSTNAME:1

And of course I ext4 formatted the device and added a UUID entry to /etc/fstab to mount this at my chosen /data mount point.

That all seems to be working fine, and after multiple reboots of the machine too, and I have happily been doing huge rsyncs to the new disks.

However today I happened to glance at etc/mtab and /proc/mdstat and I notice my /dev/md1 seems to have disappeared and morphed into a /dev/md127 (in /proc/mdstat) and/or a /dev/md127p1 in /etc/mtab:

/proc/mdstat:

shows:

md127 : active raid1 sdc2[0] sdd2[1]
      3904788480 blocks super 1.2 [2/2] [UU]
      bitmap: 2/30 pages [8KB], 65536KB chunk

md0 : active raid1 sda1[0] sdb1[1]
      488253440 blocks super 1.2 [2/2] [UU]
      bitmap: 0/4 pages [0KB], 65536KB chunk

and

/etc/mtab:

shows:

/dev/md0 / ext4 rw,relatime,errors=remount-ro,data=ordered 0 0
/dev/md127p1 /data ext4 rw,relatime,errors=remount-ro,data=ordered 0 0

It all still seems to be working fine, but what the heck happened there? I've configured RAID1 in much the same way on a couple of other machines before (admittedly many years ago) and there the RAID arrays just ended up called /dev/md0 and /dev/md1. Where did this 127 come from and what's the difference between /dev/md127 and /dev/md127p1? Is there some way I can rename them to /dev/md1, or is this something I'm stuck with?

  • 1
    Is your /etc/mdadm/mdadm.conf, specifically the /dev/md/1 line, still the same? And does the UUID listed there still match your md1? The 127 thing is when MDRAID gets confused for some reason, and thinks you might get a numbering conflict with the existing arrays, so it starts numbering backwards. 127 is the maximum, I think. But this can happen for different reasons. – Faheem Mitha Aug 25 '17 at 21:15
1
  1. Use the following command to make sure you are dealing with the right UUIDs:

    mdadm --detail /dev/md* | grep -e /dev/md -e UUID
    
  2. Edit your arrays list, you can use nano if unsure:

    nano /etc/mdadm/mdadm.conf
    

    for it to contain the UUIDs of arrays you want; or double-check it:

    ARRAY /dev/md/0 metadata=1.2 name=MYHOSTNAME:0 UUID=3d21d0e0:2758c58e:962b5191:98e225c1
    ARRAY /dev/md/1 metadata=1.2 name=MYHOSTNAME:1 UUID=47492bd7:08d1fd1c:418dad41:2aa7d77f
    

    Name your arrays to your liking.

  3. Use the following command to make sure you are mounting the right file systems:

    blkid /dev/md*
    

    for the /etc/fstab to contain these in such fashion:

    UUID=...
    
  4. The most important step you probably missed, I suspect, is updating your initramfs:

    update-initramfs -u
    

That should be it. I myself had the exact issue on the same system. If I missed a step or forgot on something, please leave a comment and I will edit this answer tomorrow morning.

Q&As:

Where did this 127 come from?

As you forgot to update your initramfs, during boot the system does not know about your new array and by default starts naming it from the end (127).

What's the difference between /dev/md127 and /dev/md127p1?

  • /dev/md127 is the name of array

  • /dev/md127p1 is the name of the partition on the array

Supplemental information by OP:

As described above the update-initramfs -u did indeed seem to be crucial! However, there turned out to a bit more tweaking possible, which I'll edit in here rather than in a different answer or comment:

After the steps above, I had /dev/md0 and /dev/md1p1. Curiously, looking at /proc/partitions I could see both a /dev/md1 and a /dev/md1p1. A bit of googling led me to suspect this was related to the default behaviour described in /proc/mdstat.conf:

# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
#DEVICE partitions containers

and indeed adding an non-commented-out line

DEVICE partitions

meant I had just /dev/md0 and /dev/md1 after the next reboot.

(Looking at some older Debian machines with mdadm raid, I see they've all had an explicit DEVICE partitions line too, and I've never knowingly used or wanted to use mdadm's notion of "containers")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.