29

I created a RAID with:

sudo mdadm --create --verbose /dev/md1 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1
sudo mdadm --create --verbose /dev/md2 --level=mirror --raid-devices=2 /dev/sdb2 /dev/sdc2

sudo mdadm --detail --scan returns:

ARRAY /dev/md1 metadata=1.2 name=ion:1 UUID=aa1f85b0:a2391657:cfd38029:772c560e
ARRAY /dev/md2 metadata=1.2 name=ion:2 UUID=528e5385:e61eaa4c:1db2dba7:44b556fb

Which I appended it to /etc/mdadm/mdadm.conf, see below:

# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#

# 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

# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes

# automatically tag new arrays as belonging to the local system
HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts
MAILADDR root

# definitions of existing MD arrays

# This file was auto-generated on Mon, 29 Oct 2012 16:06:12 -0500
# by mkconf $Id$
ARRAY /dev/md1 metadata=1.2 name=ion:1 UUID=aa1f85b0:a2391657:cfd38029:772c560e
ARRAY /dev/md2 metadata=1.2 name=ion:2 UUID=528e5385:e61eaa4c:1db2dba7:44b556fb

cat /proc/mdstat returns:

Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] 
md2 : active raid1 sdb2[0] sdc2[1]
      208629632 blocks super 1.2 [2/2] [UU]

md1 : active raid1 sdb1[0] sdc1[1]
      767868736 blocks super 1.2 [2/2] [UU]

unused devices: <none>

ls -la /dev | grep md returns:

brw-rw----   1 root disk      9,   1 Oct 30 11:06 md1
brw-rw----   1 root disk      9,   2 Oct 30 11:06 md2

So I think all is good and I reboot.


After the reboot, /dev/md1 is now /dev/md126 and /dev/md2 is now /dev/md127?????

sudo mdadm --detail --scan returns:

ARRAY /dev/md/ion:1 metadata=1.2 name=ion:1 UUID=aa1f85b0:a2391657:cfd38029:772c560e
ARRAY /dev/md/ion:2 metadata=1.2 name=ion:2 UUID=528e5385:e61eaa4c:1db2dba7:44b556fb

cat /proc/mdstat returns:

Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] 
md126 : active raid1 sdc2[1] sdb2[0]
      208629632 blocks super 1.2 [2/2] [UU]

md127 : active (auto-read-only) raid1 sdb1[0] sdc1[1]
      767868736 blocks super 1.2 [2/2] [UU]

unused devices: <none>

ls -la /dev | grep md returns:

drwxr-xr-x   2 root root          80 Oct 30 11:18 md
brw-rw----   1 root disk      9, 126 Oct 30 11:18 md126
brw-rw----   1 root disk      9, 127 Oct 30 11:18 md127

All is not lost, I:

sudo mdadm --stop /dev/md126
sudo mdadm --stop /dev/md127
sudo mdadm --assemble --verbose /dev/md1 /dev/sdb1 /dev/sdc1
sudo mdadm --assemble --verbose /dev/md2 /dev/sdb2 /dev/sdc2

and verify everything:

sudo mdadm --detail --scan returns:

ARRAY /dev/md1 metadata=1.2 name=ion:1 UUID=aa1f85b0:a2391657:cfd38029:772c560e
ARRAY /dev/md2 metadata=1.2 name=ion:2 UUID=528e5385:e61eaa4c:1db2dba7:44b556fb

cat /proc/mdstat returns:

Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] 
md2 : active raid1 sdb2[0] sdc2[1]
      208629632 blocks super 1.2 [2/2] [UU]

md1 : active raid1 sdb1[0] sdc1[1]
      767868736 blocks super 1.2 [2/2] [UU]

unused devices: <none>

ls -la /dev | grep md returns:

brw-rw----   1 root disk      9,   1 Oct 30 11:26 md1
brw-rw----   1 root disk      9,   2 Oct 30 11:26 md2

So once again, I think all is good and I reboot.


Again, after the reboot, /dev/md1 is /dev/md126 and /dev/md2 is /dev/md127?????

sudo mdadm --detail --scan returns:

ARRAY /dev/md/ion:1 metadata=1.2 name=ion:1 UUID=aa1f85b0:a2391657:cfd38029:772c560e
ARRAY /dev/md/ion:2 metadata=1.2 name=ion:2 UUID=528e5385:e61eaa4c:1db2dba7:44b556fb

cat /proc/mdstat returns:

Personalities : [raid1] [linear] [multipath] [raid0] [raid6] [raid5] [raid4] [raid10] 
md126 : active raid1 sdc2[1] sdb2[0]
      208629632 blocks super 1.2 [2/2] [UU]

md127 : active (auto-read-only) raid1 sdb1[0] sdc1[1]
      767868736 blocks super 1.2 [2/2] [UU]

unused devices: <none>

ls -la /dev | grep md returns:

drwxr-xr-x   2 root root          80 Oct 30 11:42 md
brw-rw----   1 root disk      9, 126 Oct 30 11:42 md126
brw-rw----   1 root disk      9, 127 Oct 30 11:42 md127

What am I missing here?

1
  • 2
    The only thing that's missing here is a problem. If --name is given in mdadm.conf, it assigns a random number, as you told it, that you prefer accessing the array through its name in /dev/md/name. It therefore keeps the lower numbers clear for arrays without names.
    – Bachsau
    Jul 15, 2020 at 14:48

4 Answers 4

30

I found the answer here, RAID starting at md127 instead of md0. In short, I chopped my /etc/mdadm/mdadm.conf definitions from:

ARRAY /dev/md1 metadata=1.2 name=ion:1 UUID=aa1f85b0:a2391657:cfd38029:772c560e
ARRAY /dev/md2 metadata=1.2 name=ion:2 UUID=528e5385:e61eaa4c:1db2dba7:44b556fb

to:

ARRAY /dev/md1 UUID=aa1f85b0:a2391657:cfd38029:772c560e
ARRAY /dev/md2 UUID=528e5385:e61eaa4c:1db2dba7:44b556fb

and ran:

sudo update-initramfs -u

I am far from an expert on this, but my understanding is this ...

The kernel assembled the arrays prior to the normal time to assemble the arrays occurs. When the kernel assembles the arrays, it does not use mdadm.conf. Since the partitions had already been assembled by the kernel, the normal array assembly which uses mdadm.conf was skipped.

Calling sudo update-initramfs -u tells the kernel take a look at the system again to figure out how to start up.

I am sure someone with better knowledge will correct me / elaborate on this.

Use the following line to update the initrd for each respective kernel that exists on your system:

sudo update-initramfs -k all -u
5
  • 3
    Yes, actually this would re-create the initrd for the kernel and include the configuration files relevant for the MD-RAID configuration. This means at the time the devices get created the kernel will know how to name them according to your setting. Good catch. +1 ... btw: noticed that this is also explained in the linked forum topic. Feb 9, 2013 at 8:42
  • Hey, this answer solved a slow RAID initialization issue on my Arch Linux system. It would take 5 seconds to get the RAID0 array up and running while booting. After changing mdadm.conf as described and running mkinitcpio, it takes negligible time!
    – rep_movsd
    Aug 25, 2013 at 8:47
  • Could not get Ubuntu 12.04 (Mint 13) to boot without this. I could not even get my root FS to mount from initramfs shell either. There were a bunch of dm-linear errors and 'bad superblock' errors trying to mount. I also made sure to rename my md0 device to 0, and md1 device to 1. I don't know if that was also needed.
    – cmcginty
    Jan 18, 2014 at 5:37
  • 1
    Your understanding is wrong. The kernel does not assemble metadata1.2 arrays under any circumstances. But the only thing that's missing here is a problem. If --name is given in mdadm.conf, it assigns a random number, as you told it, that you prefer accessing the array through its name in /dev/md/name. It therefore keeps the lower numbers clear for arrays without names.
    – Bachsau
    Jul 15, 2020 at 14:50
  • 1
    @Bachsau Is right people! All the other stories are non-sense. Dec 19, 2020 at 2:43
7
sudo update-initramfs -u

was all I needed to fix that. I did not edit anything in /etc/mdadm/mdadm.conf.

1

I had the same issue.

This solution solvd my problem: http://aubreykloppers.wordpress.com/2012/07/06/mdadm-devmd127/

2
  • 5
    Welcome to Ask Ubuntu. Please include the relevant steps from the link in the answer.
    – chaskes
    Aug 2, 2014 at 2:43
  • A problem involves something being wrong. With md126, there is not. You could just have gone with it. "Problem" solved. Arrays assembled with a --name always get numbers 126 and above, as you told it, that you prefer accessing the array through its name in /dev/md/name. It therefore keeps the lower numbers clear for arrays without names.
    – Bachsau
    Jul 15, 2020 at 14:53
0

I managed to replicate the issue in the following manner:

When "Software Updater" asked if i wanted to update packages (including Ubuntu base" and kernel, i said:OK. The newly installed kernel used the current kernel's/system's settings. I then created the array. Only the currently running kernel got updated with the new RAID settings. Once i rebooted, the new kernel knew nothing about the raid, and gave it an md127 name!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .