OpenWrt x86/64 can't raid /dev/md0



reboot this x86/64 device

I can't fix this.Please help me solve this problem
version:openwrt-22.03.3 for imagebuilder-22.03.3-x86-64.Linux-x86-64
mdadm version:4.1-2018-10-01
Installed packages:blockd、mdadm、kmod-fs-ext4

And kmod-md-raid0 ?

yes

Not that it has anything to do with the problem at hand, but running raid0 on a boot drive is a really bad idea.

It doesn't matter. Importantly, after RAID 0 succeeds, reboot the x86-64 device, /dev/md0 disappears

  • Is the raid0 module loaded after reboot (lsmod | fgrep raid) and does a mdadm config file exist?
  • Further what is the output of cat /proc/mdstat before and after the reboot?
  • Can you manually try to assemble the raid0 after reboot, like mdadm --assemble --scan or mdadm --assemble /dev/md0 /dev/sda /dev/sdc (see Linux RAID setup)

There is cat /proc/mdstat before reboot: md0: raid0 sda[1] sdc[1], not after reboot.
mdadm.conf:ARRAY /dev/md0 raid0 uuid=52c5c44a:d2162820:f75d3464:799750f8
raid0 disappear , mdadm --assemble --scan or mdadm --assemble /dev/md0 /dev/sda /dev/sdc is not work.
I looked at mdadm's Makefile and found the following:
image

image
I think they caused raid0 to disappear.Even though I used mdadm --detail --scan >> /var/etc/mdadm.conf, raid0 disappeared after rebooting

Is the screenshot of /etc/conf/mdadm.conf from your installation?

I guess /etc/conf/mdadm.conf is where you put the config for your RAID in OpenWrt (the same as for network etc) and that will generate the correct system (/var/etc/ ?) mdadm.conf.

Does /etc/config/mdadm.conf change after reboot? /var/etc is probably not a permanent storage (check df -h /var/etc) and you would have to set the correct settings in /etc/config/mdadm.conf. Like in the screenshot but change # list devices /dev/sda1 to your settings.

I'll see if I can test that in a VM, never used RAID with OpenWrt.

What I'm a bit confused is that assemble and scan don't work. The disks would have a Linux RAID signature on them which mdadm should find.

What does file -s /dev/sda and file -s /dev/sdc say?

Before rebooting,mdamd -D /dev/md0 can display information about /dev/md0
next: mkfs.ext4 /dev/md0
next: mount /dev/md0 /mnt/md0
After reboot, /dev/md0 disappeared.

I was able to reproduce it in a virtual machine. You have to edit /etc/config/mdadm and if that is correct OpenWrt will create the /var/etc/mdadm.conf.

For me mdadm --assemble --verbose /dev/md0 /dev/sdb /dev/sdc did work (and file -s /dev/sdb outputed: /dev/sdb: Linux Software RAID version 1.2 (1) UUID=494c0da0:fb8989b4:439fcede:21a5374f name=OpenWrt:0 level=0 disks=2)

  • The name seems important, raid:0 didn't work but OpenWrt:0 did work. And removing the name option did also work.
  • Get the UUID of your raid0 by file -s /dev/sda or file -s /dev/sdc

In my setup the disks used for raid0 where sdb and sdc. You have to change the disks to fit yours and insert your UUID of the raid.

The following config worked for me and the RAID0 was assembled automatically after reboot:

$ cat /etc/config/mdadm
config mdadm
	option email root

config array
	option uuid <insert your UUID here>
	option device /dev/md0
2 Likes

I really appreciate you help!

1 Like

Btw: if you want to add more RAIDs just add another array section after you created additional RAIDs:

$ cat /etc/config/mdadm
config mdadm
	option email root

config array
	option uuid <UUID of /dev/md0>
	option device /dev/md0

config array
	option uuid <UUID of /dev/md1>
	option device /dev/md1
1 Like

Thank you for you help ,patient0. :+1:
If I want to add hard drives, I would consider building RAID X>0.

1 Like

I ran raid1 on arm router. I had numerous problems until I started using kernel command line to activate the raid.

This will scan first 4 drives and create md0 from them:
md=0,/dev/sda,/dev/sdb,/dev/sdc,/dev/sdd

This way /dev/md0 will be available even before OpenWrt preinit starts and it works with no other OpenWrt configuration, even without mdadm installed. You only need mdadm for administration/maintenance tasks.

Note that you can write in the command line even drives that are not part of an array! Kernel will choose only those needed. I had a raid1 with 2 drives, but I added all 4 because USB device order may change unexpectedly.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.