debian mdadm md – Linux md RAID: /dev/md0 vs. /dev/md/0

debianmdmdadm

On newer systems /usr/share/mdadm/mkconf (the script that is used to generate /etc/mdadm/mdadm.conf) tends to use the device name /dev/md/0 instead of /dev/md0:

new-system ~ # /usr/share/mdadm/mkconf | grep ARRAY
ARRAY /dev/md/0 metadata=1.2 UUID=a0021927:0e4f10bf:2c47dc72:ca0b352e name=unassigned:0

This may cause some irritation for users who expect /dev/md0 there, but apparently it works fine because the server boots without problems.

In /proc/mdstat the device is still called /dev/md0:

new-system ~ # cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb2[2] sda2[0]
      1953381184 blocks super 1.2 [2/2] [UU]

unused devices: <none>

ls shows that /dev/md/0 is a symlink to /dev/md0:

new-system ~ # ls -l /dev/md/0 
lrwxrwxrwx 1 root root 6 Nov 20 14:06 /dev/md/0 -> ../md0

On another older system mkconf still uses /dev/md0 instead, and /dev/md is empty:

old-system ~ # /usr/share/mdadm/mkconf | grep ARRAY
ARRAY /dev/md0 UUID=76472cf5:83fd8e5a:ad617046:69b2ebf1
old-system ~ # ls -l /dev/md
total 0

I'd like to know the difference between these device names, and I can't find any explanation on Google. Is /dev/mdN the old name, and md is planning to move to /dev/md/N device names? Is this change related to the 1.2 metadata (I've noticed that the new server is using md 1.2, while the old one is still using 0.90)?


EDIT 2017-09-11: I think Krzysztof Stasiak's answer is the correct one. I had by now totally forgotten about this question. While playing with a test RAID last friday I thought "why not name my array instead of memorizing what md0, md1, md2, … etc. does in complex setups?", and so I tried:

test-server ~ # mdadm --assemble /dev/mdfoobar /dev/loop[01]
mdadm: /dev/mdfoobar is an invalid name for an md device.  Try /dev/md/mdfoobar

And indeed that works:

test-server ~ # mdadm --assemble /dev/md/foobar /dev/loop[01]
mdadm: /dev/md/foobar has been started with 2 drives.

test-server ~ # ll /dev/md/foobar 
lrwxrwxrwx 1 root root 6 Sep 11 10:45 /dev/md/foobar -> ../md0

test-server ~ # cat /proc/mdstat 
Personalities : [raid1]
md0 : active (auto-read-only) raid1 loop0[0] loop1[1]
      102272 blocks super 1.2 [2/2] [UU]

unused devices: <none>

(You can also do mdadm --assemble foobar DEV...).

There's a detailed explanation in man mdadm, section DEVICE NAMES.

Best Answer

you can name array as own name (not only 0-127) and since mdadm 3.0.3 you can use only name. If think path was changed to use subfolder /dev/md/$name to make more flexibility or some kind of clean or group arrays. If md array is created in format /dev/mdX there is added symlink to make compability to new format.

Related Question