Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

5 Answers 5

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.

share|improve this answer
    
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 '13 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 '13 at 0:22
1  
@razor7 mdadm --stop --scan md127 –  Daniel Dinnyes Jan 23 at 16:22
add comment

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=: syntax.

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

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

 mdadm --examine --scan --config=mdadm.conf >> /etc/mdadm.conf
share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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