Linux: Renaming software RAID

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
peter_b
Chatterbox
Posts: 371
Joined: Tue Nov 12, 2013 2:05 am

Linux: Renaming software RAID

Post by peter_b »

[PROBLEM]
One can realize that him/her wants to change the label/name of their Linux SoftRAID, which is already used in production - and should stay like that.

[SOLUTION]
1) Unmount any RAID you want to rename.
2) Stop the RAIDs:

Code: Select all

$ sudo mdadm --stop /dev/mdX
Replace "/dev/mdX" with the RAID device(s) you want to rename.

3) Rename the RAID:

Code: Select all

$ sudo mdadm --assemble /dev/mdX --name=a_new_name --update=name /dev/disk/disks_of_this_raid
For renaming the RAID of 15 drives in a row of a Backblaze/45drives pod, I did this:

Code: Select all

$ sudo mdadm --assemble /dev/md1 --name=dlp_raid_1 --update=name /dev/disk/by-path/pci-0000\:02\:04.0-scsi-*-part1
Check if the name was updated with this:

Code: Select all

$ sudo mdadm --detail /dev/mdX | grep Name
4) Tell the RAID to be writable again:
Without this step, the RAID will be started, but set to "auto-read-only".

Code: Select all

$ sudo mdadm --readwrite /dev/mdX
5) Update partition/filesystem label:
The "/dev/disk/by-label" for accessing/mounting your RAID devices does not use the MD-RAID names, but the ones of the filesystem.
For XFS, you can update the filesystem label using "xfs_admin -L Name". For example:

Code: Select all

$ sudo xfs_admin -L dlp_raid_1 /dev/md1
After having done that for all affected partitions, you have 2 choices to update the links in "/dev/disk/by-label":
  1. Reboot
  2. Manually update the symlinks in /dev/disk/by-label to reflect your new name(s)
Now you should be able to mount and use your RAID again without re-sync or problems.

Thanks to:
Post Reply