HowTo: Linux Rename a RAID Array From md0 to md2

See all GNU/Linux related FAQ
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
Difficulty level Advanced
Root privileges Yes
Requirements Linux and mdadm
Est. reading time 3 minutes

  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:

        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

🥺 Was this helpful? Please add a comment to show your appreciation or feedback.

nixCrat Tux Pixel Penguin
Hi! 🤠
I'm Vivek Gite, and I write about Linux, macOS, Unix, IT, programming, infosec, and open source. Subscribe to my RSS feed or email newsletter for updates.

5 comments… add one
  • Rajiv Singhal Nov 21, 2012 @ 3:59

    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 ?

    • 🛡️ Vivek Gite (Author and Admin) nixCraft Nov 21, 2012 @ 12:59

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

  • Andy Apr 11, 2013 @ 17:41

    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?!

    • JN Oct 28, 2013 @ 22:38

      mdadm -Es

    • Nate Nov 22, 2016 @ 8:04

      The comment should be:
      mdadm --assemble /dev/md1 --uuid=61acc65f:0193c32a:f07e0e6d:1fff95a9

Leave a Reply

Your email address will not be published. Required fields are marked *

Use HTML <pre>...</pre> for code samples. Your comment will appear only after approval by the site admin.