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:
- /dev/md0 is original software based RAID array.
- /dev/md0 is made of the two partitions called /dev/sdc1 and /dev/sdd2.
- 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/sdd1Note 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
- You may need to update your grub.conf.
- 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.
- Make sure you update mdadm.conf on both serverA and serverB.
Recommended readings:
- mdadm man page