15

I have assembled a new raid array to replace an old one. However, this new array got assigned an automatic name of /dev/md127 and I want to rename it to /dev/md3, so that I don't have to change various other settings. How do I rename an mdadm raid array?

3 Answers 3

12

Start with mdadm --detail /dev/md127:

Version : 0.90
Creation Time : Wed Apr 13 20:03:21 2011
Raid Level : raid10
Array Size : 656765952 (626.34 GiB 672.53 GB)
Used Dev Size : 437843968 (417.56 GiB 448.35 GB)
Raid Devices : 3
Total Devices : 2
Preferred Minor : 8
Persistence : Superblock is persistent

The first line shows the metadata version used by this array. Now, stop the array:

mdadm --stop /dev/md127
mdadm --remove /dev/md127

And assemble it again using the new name. If the metadata version is 1.0 or higher, use this:

mdadm --assemble /dev/md3 /dev/sd[abcdefghijk]3 --update=name

For arrays using old metadata structure (most likely 0.90, as it allows for kernel auto-assembly), use this:

mdadm --assemble /dev/md3 --update=super-minor /dev/sd[abcdefghijk]3
4
  • This procedure works fine for me until reboot. Then it's back to /dev/md127.
    – user117600
    Apr 15, 2012 at 16:19
  • 2
    I'm now using array UUID instead of name, as it proved to be much more reliable for me (e.g. dual-booting messed the names each time, and does not cause problems with UUIDs).
    – skolima
    Apr 16, 2012 at 7:03
  • If that is the case, please consider updating your answer.
    – blee
    Jan 17, 2013 at 12:28
  • @briankb what I meant is that I no longer care what names I end up with, because I don't use them any more. I put UUID where I would put e.g /dev/md3 before. If the answer is outdated, please suggest an updated one and I'll be happy to accept it. But in general, I'd suggest avoiding the initial problem altogether by not using array names at all.
    – skolima
    Jan 17, 2013 at 13:33
5

I was in a similar position--I had an array I created which was re-named to /dev/md127 after reboot.

The code

mdadm --stop /dev/md127

mdadm --assemble /dev/md3 /dev/sd[cdef]1

was enough to get the md array re-named /dev/md3 for me, but like everyone else, after a reboot, it would revert back to /dev/md127

I found that if I re-assembled the md array back to /dev/md3, and then re-created the initramfs file (dracut --force as I am on CentOS), then it would remember my array's name (/dev/md3) after reboots.

1
  • 1
    Assemble without --name or --update it will gives you md0, md1, etc. But if you want to name your RAID arrays, the kernel will start with md126 as the first soft raid device. Dec 19, 2020 at 2:39
1

The other answers work, but if you don't want to stop your array prematurely, see here: How-to change the name of an MD device (mdadm) (from superuser)

You must log in to answer this question.

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