I plugged an old raid ARRAY to a new system and get this error on anything that I try to do with mdadm
.
# mdadm --detail --scan
ARRAY /dev/md/arch1:2021 metadata=1.2 UUID=c4c7cbde:5f6913a9:eb1c82ff:8fe6cd45
# mdadm --detail
mdadm: Value "arch1:2021" cannot be set as devname. Reason: Not POSIX compatible. Value ignored.
mdadm: No devices given.
Everything still works fine. I can mount and use the Array. And the "non-compliant" name appears as a device file just fine
# ls -la /dev/md/
total 0
drwxr-xr-x 2 root root 60 2024-08-09 03:16 .
drwxr-xr-x 20 root root 4580 2024-08-09 03:16 ..
lrwxrwxrwx 1 root root 8 2024-08-09 03:16 arch1:2021 -> ../md127
device file which i can use
# mdadm --detail /dev/md/arch1\:2021
/dev/md/arch1:2021:
Version : 1.2
Creation Time : Wed Jul 7 06:29:08 2021
Raid Level : raid1
What's the best way to just update the name in the safest way possible?
This colon separates owning host name from array name:
<hostname>:<name>
. It is stored asset_name
field in the MD 1.x superblock (also supported by the DDF external metadata format). It is the superblock the single source of truth about the name of the array, notmdadm.conf
. Entries in the latter must agree to whatever stored in the superblock for the system to activate the array. The easiest way to generate correct entries it is to use the output ofmdadm --examine --scan
. Or just omit that name parameter in the entries, useARRAY /dev/mdN UUID=...
instead, and only rely on filesystem UUIDs or LVM or whatever higher level structures are on your arrays.Upon creation, you give only the latter "name" part, while the hostname is picked up automatically, but you can also force it:
will store
arch1:2021
.During activation, if the current system hostname is the same as stored, symlinks in
/dev/md/
omit the hostname (looking just like/dev/md/<name>
), and they include it otherwise, as it is in your case. You can setHOMEHOST hostname
inmdadm.conf
, to use that hostname to strip from the names stored in superblock, instead of current system hostname.See also this wonderful answer
This error message was introduced in mdadm v4.3. Although the developer admitted it's a regression in some cases, they also made it clear it's not going away, so — just deal with it, I guess.
Besides special characters in names, mdadm v4.3 also takes offense to numbers >127. This was generously extended to 1024 in a recent patch — however before mdadm v4.3, you could use up to 1048575 (the kernel limit).
In your case, if
arch1:2021
was not intended to mean/dev/md2021
, but to use 2021 as a name, it's unfortunately the case that mdadm does not distinguish hostname, number (preferred minor) or names in its metadata link1 link2. It all goes into one and the same 32 byte string and is up to interpretation.So if you wish to use mdadm names, the name should avoid all special characters, and also avoid being numerical. So if possible, stick to a-z exclusively. If you must use digits, make sure it's not the first character in the name (use
foo123
instead of just123
).mdadm names (in metadata) can only be changed at assemble time. If the array is already running, you'd have to stop it first, which can only be done if not in use, so really never unless you boot a rescue system.
Then it should go like this, but…:
Segmentation fault??? Well, obviously that's not supposed to happen… this bug (fixed in git) is only triggered if you have
HOMEHOST <none>
set in your mdadm.conf, or your hostname is otherwise empty.So until this fix is released, you're more or less stuck with
mdadm
including your hostname in the array name. Unlesshostname:arrayname
is longer than 32 bytes, since metadata can't store longer strings.So you can cheat by passing a hostname that is 32 bytes long:
And it will come out as:
So if you wanted to get rid of
arch1:
in your name, that'd be the only way to do it for now.Change your
/etc/mdadm.conf
to either use/dev/md0
(numeric style with numbers in range0-127
since larger numbers are rejected for no reason). Or use the (symlink-)named style/dev/md/name
with a non-numeric name.When assembling named arrays,
mdadm
will pick a number on its own accord. For each number, mdadm parses/proc/mdstat
to check if it's already in use, until it finds a free one — this is fine for assembling 3 arrays, less fine for assembling 300 arrays since mdstat is parsed thousands of times then./dev/md/name
will then be a symlink to/dev/md127
(or other numbers). The named array will also show as/dev/md127
under/proc/mdstat
and these numbers can change, so take this into account when managing multiple arrays.There is also a third naming style:
This puts the name directly into the device name as
/dev/md_name
. This is very unusual since no other device driver does this. This is also the only style where a name is shown in/proc/mdstat
instead of the number.However this style is entirely undocumented in
man 4 md
. Andman 5 mdadm.conf
discourages its use since other tools may not expect this style. So it should be avoided.All in all,
mdadm
just has terribly poor support for names. You can't set them, you can't change them without a lot of hoop jumping, themdadm
utility does not use them or even show them. In fact it doesn't show anything, you're supposed to look at/proc/mdstat
instead, becausemdadm
itself can't even show you a pretty-printed list of arrays and their states.This is a long shot from how other utilities actually help you manage things and show names while doing so, to the point nobody even cares about numbers.