Linux: Rename SoftRAID device name from md127 to md0
Posted: Tue Dec 16, 2014 4:37 pm
[PROBLEM]
After re-installing Debian 7 (Wheezy) on a server with re-integrating existing Kernel software RAIDs, I ended up with "ugly" device names, such as:
/dev/md127 instead of /dev/md0
I don't know where Linux stores the device names it assigns to software RAIDs, but in my case it wasn't "/etc/mdadm/mdadm.conf", because in there, I used the md-labels, like this:
[SOLUTION]
There are 2 options:
In my mdadm.conf I used the md-labels "/dev/md/xxx", which work regardless of the actual /dev/mdXXX device name, but that parameter can be used to tell the kernel which device names to actually create.
So edit/adjust the "ARRAY" parameter accordingly.
Here's my edited config, for example:
Once that's done, you must update your Kernel's initramfs to reflect the changes after reboot:
If you can reboot the server, do so now, and your md-devices should be named properly.
If you can not reboot at the moment, the following steps describe how to change stuff in runtime (except if the OS-partition itself is on the RAID, because you can't do that without unmounting, etc).
1) Stop the affected array(s):
NOTE: This only works for arrays which are not your system disk!
2) Assemble the arrays and give them the desired device name:
In a nutshell, it's like this:
In my setup (Backblaze 45drives pod v3), each array is RAID6 and has 15 disks: 14 active + 1 spare, so I use a wildcard-mask on "/dev/disk/by-path/pci-0000..." to list all the drives that belong to that RAID array.
The "--no-degraded" option is very important: In case not all disks were properly found/assembled, it will not start the array.
Without this, you might end up with an automatic re-sync that would actually not be necessary...
3) Verify array status using /proc/mdstat:
If the above assemble-command worked properly, you should now see this array with the desired device name, when looking at /proc/mdstat:
For example, mine now looks like this:
Excellent!
4) Repeat steps 1-3 for all affected arrays.
Links:
After re-installing Debian 7 (Wheezy) on a server with re-integrating existing Kernel software RAIDs, I ended up with "ugly" device names, such as:
/dev/md127 instead of /dev/md0
I don't know where Linux stores the device names it assigns to software RAIDs, but in my case it wasn't "/etc/mdadm/mdadm.conf", because in there, I used the md-labels, like this:
Code: Select all
ARRAY /dev/md/dlp_raid_1 metadata=1.2 UUID=957faa4b:899b682b:a6b7e34b:b247dd85 name=bb2:dlp_raid_1
ARRAY /dev/md/dlp_raid_2 metadata=1.2 UUID=2c51e39a:291e5fe2:4f3586d4:fa543b72 name=bb2:dlp_raid_2
ARRAY /dev/md/dlp_raid_3 metadata=1.2 UUID=43e76209:1f7f56a8:ef426abe:e574b892 name=bb2:dlp_raid_3
There are 2 options:
- Modify /etc/mdadm/mdadm.conf (requires reboot)
- Stop/re-assemble arrays during runtime (no reboot required)
In my mdadm.conf I used the md-labels "/dev/md/xxx", which work regardless of the actual /dev/mdXXX device name, but that parameter can be used to tell the kernel which device names to actually create.
So edit/adjust the "ARRAY" parameter accordingly.
Here's my edited config, for example:
Code: Select all
ARRAY /dev/md1 metadata=1.2 UUID=957faa4b:899b682b:a6b7e34b:b247dd85 name=bb2:dlp_raid_1
ARRAY /dev/md2 metadata=1.2 UUID=2c51e39a:291e5fe2:4f3586d4:fa543b72 name=bb2:dlp_raid_2
ARRAY /dev/md3 metadata=1.2 UUID=43e76209:1f7f56a8:ef426abe:e574b892 name=bb2:dlp_raid_3
Code: Select all
$ update-initramfs -k all -u
If you can reboot the server, do so now, and your md-devices should be named properly.
If you can not reboot at the moment, the following steps describe how to change stuff in runtime (except if the OS-partition itself is on the RAID, because you can't do that without unmounting, etc).
1) Stop the affected array(s):
NOTE: This only works for arrays which are not your system disk!
Code: Select all
$ mdadm --stop /dev/mdXXX
In a nutshell, it's like this:
Code: Select all
$ mdadm --assemble --no-degrated /dev/md0 /dev/sda1 /dev/sdb1 ...
The "--no-degraded" option is very important: In case not all disks were properly found/assembled, it will not start the array.
Without this, you might end up with an automatic re-sync that would actually not be necessary...
3) Verify array status using /proc/mdstat:
If the above assemble-command worked properly, you should now see this array with the desired device name, when looking at /proc/mdstat:
Code: Select all
$ cat /proc/mdstat
Code: Select all
md0 : active (auto-read-only) raid6 sda1[0] sdo1[14](S) sdn1[13] sdm1[12] sdl1[11] sdk1[10] sdj1[9] sdi1[8] sdh1[7] sdg1[6] sdf1[5] sde1[4] sdd1[3] sdc1[2] sdb1[1]
35161602048 blocks super 1.2 level 6, 512k chunk, algorithm 2 [14/14] [UUUUUUUUUUUUUU]
bitmap: 0/11 pages [0KB], 131072KB chunk
4) Repeat steps 1-3 for all affected arrays.
Links: