HowTo: Linux Rename a RAID Array From md0 to md2

by on November 20, 2012 · 4 comments· LAST UPDATED November 20, 2012

in

I am moving a raid array called /dev/md0 from serverA to serverB. On serverB /dev/md0 is already in use. How do I rename a RAID array from /dev/md0 to /dev/md2?

You can move a RAID array (software based RAID array) to another system. However, if /dev/md0 is already is use on serverB, you can rename /dev/md0 as /dev/m2 (or next available md device). In this example:
Tutorial details
DifficultyAdvanced (rss)
Root privilegesYes
RequirementsLinux and mdadm
Estimated completion timeN/A

  1. /dev/md0 is original software based RAID array.
  2. /dev/md0 is made of the two partitions called /dev/sdc1 and /dev/sdd2.
  3. I am going to rename /dev/md0 as /dev/md2 i.e. set /dev/md2 as the new device name.
WARNING! These examples may crash your computer if executed. Make a backup - it cannot be stressed enough how important it is to make a backup of your system before you do this.

Type the following commands on serverA

# mdadm --detail /dev/md0
Sample outputs:

 
/dev/md0:
        Version : 0.90
  Creation Time : Sat Jan  1 05:30:03 2000
     Raid Level : raid1
     Array Size : 2490176 (2.37 GiB 2.55 GB)
  Used Dev Size : 2490176 (2.37 GiB 2.55 GB)
   Raid Devices : 2
  Total Devices : 2
Preferred Minor : 0
    Persistence : Superblock is persistent
 
    Update Time : Wed Nov 21 01:43:40 2012
          State : clean
 Active Devices : 2
Working Devices : 2
 Failed Devices : 0
  Spare Devices : 0
 
           UUID : 8c229b6a:c20a3bfa:2d164f4f:84bee133 (local to host nas03)
         Events : 0.43537
 
    Number   Major   Minor   RaidDevice State
       0       8        1        0      active sync   /dev/sdc1
       1       8       17        1      active sync   /dev/sdd1
 

Note down the output, especially version number 0.90. It is recommended that you use the same version on the serverB. Next, stop the /dev/md0 on serverA, enter:
# mdadm --stop /dev/md0
The --stop option deactivate array /dev/md0, releasing all resources. Either use option #1 or option #2 to reassemble the RAID array.

Option #1: Rename a RAID

Next, you need to reassemble a pre-existing array as /dev/md2:
# mdadm --assemble /dev/md2 --super-minor=0 --update=super-minor /dev/sdc1 /dev/sdd1
The above command renames /dev/md0 indicated by the option --super-minor=0 as /dev/md2. The array is now ready to move into the serverB.

Option #2: Rename a RAID

The --super-minor option is only relevant for v0.90 metadata, and should not normally be used. Using --uuid is much safer. First, find out UUID for all devices, run:
# mdadm -Es
Sample outputs:

ARRAY /dev/md0 UUID=8c229b6a:c20a3bfa:2d164f4f:84bee133
ARRAY /dev/md1 UUID=b9cf66f0:f4e3e168:2d164f4f:84bee133
ARRAY /dev/md/2 metadata=1.2 UUID=e8e12adc:e0a02bdf:1cd25903:6c2f2b02 name=nas03:2

Type the following command reassemble the RAID device as /dev/md2:
# mdadm --uuid=8c229b6a:c20a3bfa:2d164f4f:84bee133 --update=super-minor --assemble /dev/md2
The array is now ready to move into the serverB.

Type the following commands on serverB

Attach /dev/sdc and /dev/sdd to the serverB and boot the server. The new server will use /dev/md2 immediately without any problem. You may need to update mdadm.conf file.
# cp -v /etc/mdadm/mdadm.{conf,bakup-nov-21-2012-by-nixcraft}
# mdadm -Es > /etc/mdadm/mdadm.conf

Possible caveats when renaming a RAID array

  1. You may need to update your grub.conf.
  2. This procedure may work fine but after reboot /dev/md2 may not be recognized at all. To avoid this problem use uuid when reassembling the RAID array.
  3. Make sure you update mdadm.conf on both serverA and serverB.
Recommended readings:
  • mdadm man page
TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 4 comments… read them below or add one }

1 Rajiv Singhal November 21, 2012 at 3:59 am

This would work if both server A & B are available, but what if server A can’t be booted & the array has to be moved to server B ?

Reply

2 nixCraft November 21, 2012 at 12:59 pm

In that case, just attach the drive and type option #1 or option #2 commands.

Reply

3 Andy April 11, 2013 at 5:41 pm

I might have missed something. Following Option #2, I obtain my UUID for the array-to-be-renamed.
I issue this command:
#> mdadm –uuid=61acc65f:0193c32a:f07e0e6d:1fff95a9 –update=super-minor –assemble /dev/md1

This is the error output:
#> mdadm: –uuid does not set mode, so cannot be the first option

my mdadm is pretty weak. what can my first option be?!

Reply

4 JN October 28, 2013 at 10:38 pm

mdadm -Es

Reply

Leave a Comment

Tagged as: , , ,

Previous Faq:

Next Faq: