Linux mdadm does not assemble array, but recreation of array does it
Resolution
ππΈββπβπΎ: The instructions below delete your existing RAID setup and create a new md RAID 1 array with two entire block devices,
/dev/sdc
and/dev/sdd
.
-
Ensure that your kernel has the RAID 1 md module loaded with either of these commands:
lsmod | grep 'raid1\s' grep 'Personalities : .*\[raid1\]' /proc/mdstat
-
If you do not get an output above, load the RAID 1 md module:
sudo modprobe raid1
-
Make md forget your existing corrupt array by zapping the disks:
sudo sgdisk -Z /dev/sdc sudo sgdisk -Z /dev/sdd
Note that
mdadm --zero-superblock /dev/sd{c,d}
might not operate ifmdadm
doesn't detect an existing array properly. -
Recreate your RAID 1 array using the entire devices
/dev/sdc
and/dev/sdd
:sudo mdadm --create /dev/md0 -n 2 -l 1 /dev/sdc /dev/sdd
-
To make the new array assemble automatically, add the contents of the following command to the bottom of your
/etc/mdadm/mdadm.conf
file:sudo mdadm --detail --scan
See also: How can I make mdadm auto-assemble RAID after each boot?
Explanation
Your two mdadm --misc -E
commands reveal that mdadm
is not seeing the metadata for your RAID devices. Your example:
β ~ sudo mdadm --misc -E /dev/sdc
/dev/sdc:
MBR Magic : aa55
Partition[0] : 3907029167 sectors at 1 (type ee)
It looks like /dev/sdc
has a partition /dev/sdc1
. If you're using a whole device as the md RAID device, you would not have /dev/sdc1
. (The same goes for your /dev/sdd
.)
Furthermore, when you try recreating the array, mdadm
detects this strange information:
mdadm: /dev/sdc appears to be part of a raid array:
level=raid0 devices=0 ctime=Thu Jan 1 07:00:00 1970
You're trying to use RAID 1 with two devices today, but mdadm
reports RAID 0 with no devices at epoch 0. This is clearly not right.
Maybe at some point you tried creating an array on /dev/sdc1
and /dev/sdd1
(the partitions) rather than on /dev/sdc
and /dev/sdd
(the entire devices), and the md superblocks got muddled while you struggled to figure out the issue.
For this reason, I believe that you should zap the disks and start over.
Related videos on Youtube
IlyaGulya
Updated on September 18, 2022Comments
-
IlyaGulya over 1 year
Maybe i'm not very clear in the title. When i'm trying to assemble my raid1 array with mdadm:
sudo mdadm --assemble /dev/md0 /dev/sdc /dev/sdd
It tells me that
mdadm: Cannot assemble mbr metadata on /dev/sdc mdadm: /dev/sdc has no superblock - assembly aborted
If i reorder devices in command:
sudo mdadm --assemble /dev/md0 /dev/sdd /dev/sdc
It tells the same for
sdd
:mdadm: Cannot assemble mbr metadata on /dev/sdd mdadm: /dev/sdd has no superblock - assembly aborted
Here's some info about drives:
β ~ sudo mdadm --misc -E /dev/sdc /dev/sdc: MBR Magic : aa55 Partition[0] : 3907029167 sectors at 1 (type ee) β ~ sudo mdadm --misc -E /dev/sdd /dev/sdd: MBR Magic : aa55 Partition[0] : 3907029167 sectors at 1 (type ee)
But! When i'm recreating array with
β ~ sudo mdadm --create /dev/md0 -n 2 -l 1 /dev/sdc /dev/sdd mdadm: /dev/sdc appears to be part of a raid array: level=raid0 devices=0 ctime=Thu Jan 1 07:00:00 1970 mdadm: partition table exists on /dev/sdc but will be lost or meaningless after creating array mdadm: Note: this array has metadata at the start and may not be suitable as a boot device. If you plan to store '/boot' on this device please ensure that your boot-loader understands md/v1.x metadata, or use --metadata=0.90 mdadm: /dev/sdd appears to be part of a raid array: level=raid0 devices=0 ctime=Thu Jan 1 07:00:00 1970 mdadm: partition table exists on /dev/sdd but will be lost or meaningless after creating array Continue creating array? yes mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md0 started.
Instead of making the new array, it starts my array!
β ~ ls -l /dev/mapper/MisakaMirror-alldata lrwxrwxrwx 1 root root 7 ΠΌΠ°ΠΉ 19 01:48 /dev/mapper/MisakaMirror-alldata -> ../dm-2
But i want to achieve this with
mdadm --assemble
To do it automatically. Thanks.