29

For some reason, when I try to rename an mdadm raid array to a textual name, the change doesn't take.

I tried the advice from this serverfault question, but to no avail.

~$ mdadm --version
mdadm - v3.1.4 - 31st August 2010

~$ sudo mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
  Creation Time : Tue Sep 27 08:32:32 2011
     Raid Level : raid1
     Array Size : 1953513424 (1863.02 GiB 2000.40 GB)
  Used Dev Size : 1953513424 (1863.02 GiB 2000.40 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent
    Update Time : Sun Oct  2 17:59:37 2011
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : omicron:0  (local to host omicron)
           UUID : 75c4a555:482aecd0:ade70dfc:1547926a
         Events : 17

Number   Major   Minor   RaidDevice State
   0       8       80        0      active sync   /dev/sdf
   1       8       96        1      active sync   /dev/sdg

~$ sudo mdadm --stop /dev/md0
mdadm: stopped /dev/md0

~$ sudo mdadm --assemble /dev/md/alpha --update=name /dev/sd[gf]
mdadm: /dev/md/alpha has been started with 2 drives.

~$ sudo mdadm --detail /dev/md0
/dev/md0:
        Version : 1.2
  Creation Time : Tue Sep 27 08:32:32 2011
     Raid Level : raid1
     Array Size : 1953513424 (1863.02 GiB 2000.40 GB)
  Used Dev Size : 1953513424 (1863.02 GiB 2000.40 GB)
   Raid Devices : 2
  Total Devices : 2
    Persistence : Superblock is persistent
    Update Time : Sun Oct  2 18:06:11 2011
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0

           Name : omicron:0  (local to host omicron)
           UUID : 75c4a555:482aecd0:ade70dfc:1547926a
         Events : 17

Number   Major   Minor   RaidDevice State
   0       8       80        0      active sync   /dev/sdf
   1       8       96        1      active sync   /dev/sdg

~$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdf[0] sdg[1]
      1953513424 blocks super 1.2 [2/2] [UU]

md126 : active (auto-read-only) raid1 sdd[0] sde[1]
      1953513424 blocks super 1.2 [2/2] [UU]

md127 : active (auto-read-only) raid1 sdb[0] sda[1]
      976762496 blocks [2/2] [UU]

unused devices: <none>

As you can see, the name is still reported as omicron:0 and still reachable through the old device file. Trying sudo mdadm --detail /dev/md/alpha will work, and report the same, wrong, name until the next reboot, when it stops working.

It seems as if when figuring out what name to put in, mdadm gets confused and just creates the device file instead.


ASIDE

Is there any way to make mdadm force an update of the name part of the superblock (i.e. explicitly set the name you want the array to have) without having to explicitly re-create the superblock? (i.e. sudo mdam --zero-superblock /dev/sd[fg]; sudo mdadm --create /dev/md/alpha --raid-devices=2 --level=1 --assume-clean --name=alpha /dev/sd[fg] )


The problem is that after reboot, despite adding ARRAY /dev/md/alpha metadata=1.2 name=omicron:alpha UUID=c66a267... to mdadm.conf, the named device file dissapears and is replaced with one of standard format. (/dev/md125 or similar)

How can I make a renamed mdadm array keep its name? - I.e. - How can I make ubuntu persist the device files between boots?

6 Answers 6

25

You have to give it the name actually with --name= like:

sudo mdadm --assemble /dev/md/alpha --name=newname --update=name /dev/sd[gf]

To have a consistent behavior over reboot you have to use the same name in the --name argument than in the last part of the device. Here it would be : sudo mdadm --assemble /dev/md/alpha --name=alpha --update=name /dev/sd[gf]

See Khassad's post below for a full explanation.

3
  • 2
    A minor update to this command line, for clarity, as like a boob I was enter the array's original name after '--update='. sudo mdadm --assemble /dev/md/alpha --name={newname} --update=name /dev/sd[gf] Hope that makes sense or makes it clearer....
    – anastrophe
    Jan 17, 2013 at 22:02
  • Hi, after issuing command # sudo mdadm --assemble /dev/md127 --name=md0 --update=name /dev/sd[ab] I get mdadm: /dev/sda is busy - skipping mdadm: /dev/sdb is busy - skipping Any thougths? Of course, I have unmounted the array first!
    – razor7
    Feb 23, 2013 at 0:22
  • 2
    @razor7 mdadm --stop --scan md127 Jan 23, 2014 at 16:22
18

The way to make Ubuntu persist the name change across boots is to update your initramfs. After updating your array name and mdadm.conf, you need to issue the following command:

sudo update-initramfs -u

The whole process:

sudo mdadm --stop /dev/md125
sudo mdadm --assemble /dev/md/alpha --name=alpha --update=name /dev/sd[fg]
sudo mdadm -Db /dev/md/alpha

The third command should return something like:

ARRAY /dev/md/alpha metadata=1.2 name=omicron:alpha UUID=5b024352:3a940335:233aa23f:5c6b2a1f

Paste the result into /etc/mdadm/mdadm.conf (replacing the old line). Or execute:

sudo mdadm -Db /dev/md/alpha >> /etc/mdadm/mdadm.conf

Next run:

sudo update-initramfs -u

Finally, reboot.

This discussion was useful.

1
  • I like to use "--name=any:alpha" which makes it easier to bring back online if it needs to move to another system
    – Brain2000
    Mar 18, 2022 at 21:28
10

The first answer by pille and N.N works.

The trick here is that when you don't specify the --name option the only renaming done by mdadm is assigning the array name from the device number it has allocated. In this question it is 0 so the new array name is 0.

Since you specify the device name ("alpha" here) to use in the assemble command it will create and use this device name. But at autostart mdadm creates a device based on the name it sees in the superblock, that is 0 in this case, so the device name you specified in your assemble command is lost.

To make your name change sticky and coherent, you have to use the same name in the last part of your device name and in your new array name. In this case, for the device "alpha" you would have to use this command line :

mdadm --assemble /dev/md/alpha --name=alpha --update=name /dev/sd[gf]

You could also change the hostname, to do this you have to explicitly declare it using the -name=<hostname>:<array_name> syntax.

This may be useful for example after a machine name change.

2

It's seems as if the answer you seek is right in the mdadm man page

[create, build, grow]
      -N, --name=
          Set  a name for the array.  This is **currently only effective when creat‐
          ing an array** with a version-1 superblock, or an  array  in  a  DDF  con‐
          tainer.   The  name is a simple textual string that can be used to iden‐
          tify array components when assembling.  If name is needed but not speci‐
          fied, it is taken from the basename of the device that is being created.
          e.g. when creating /dev/md/home the name will default to home.

and for assemble

       -N, --name=
          Specify the name of the array to assemble.  **This must be the  name  that
          was  specified  when  creating the array**.  It must either match the name
          stored in the superblock exactly, or it  must  match  with  the  current
          homehost prefixed to the start of the given name.

Which explains why the name attribute isn't sticky after it's set. If you did get it to work please ack with a comment which answer did the trick for you. Alternatively, you could always create symlinks using a udev rule and the array's UUID as an anchor.

I don't see the point in adding the fake name to the /etc/mdadm.conf, you're already using the UUID which is the canonical array name. Adding another variable, that you see fit to change, is just unnecessary maintenance and asking for trouble e.g. array fails to start.

Beyond these observations, the best place to go to understand why you just can't update the name at runtime is to ping the linux-raid mailing list.

1

after you change the name, did you try to update your mdadm.conf?

 mdadm --examine --scan --config=mdadm.conf >> /etc/mdadm.conf
0

mdadm has a bug when raid volumes were internally created with a space in their name. These volumes won't mount correctly due to format error in the generated /etc/mdadm/mdadm.conf file. You need to rename them there but it won't be persistent. So renaming the internal names is necessary... but it is not supported on all RAID controlers that block their metadata and don't support the name option. I don't see how to rename these volumes (even if they are internally referenced by their UUID, the names are those used by Linux; Windows on the opposite has no such bug and perfectly mounts RAID volumes containing spaces in their names) !

You must log in to answer this question.

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