Having issues setting up a RAID1 using mdadm

bug report: 569b8686-1009-4a0a-a2fe-d3394a4ec925;

So as the title suggests, I’m trying to setup a RAID1 to put our family photos etc currently creating the RAID1 and it’s going to take forever by the looks of it, but read somewhere that I should be able to format md0 and start putting files there.

I was following this tutorial - with 2 fresh 5tb 2.5" drives.

root@DietPi:~# cat /proc/mdstat
Personalities : [raid1] 
md0 : active raid1 sdc[1] sdb[0]
      5119867904 blocks super 1.2 [2/2] [UU]
      [>....................]  resync =  0.8% (42628096/5119867904) finish=10720.7min speed=7892K/sec
      bitmap: 39/39 pages [156KB], 65536KB chunk

But just get an error when I try to format:

ERROR: use the -f option to force overwrite of /dev/md0
root@DietPi:~# sudo mkfs.btrfs -L -f "homecloud" /dev/md0
btrfs-progs v5.10.1 

In drive_manager none of the drives sdb, sdc or md0 have any UUID’s that seems odd right?

Also if I reboot the cat /proc/mdstat no longer outputs anything like it’s just stopped and I have to start the whole process over again.

Any help is much appreciated.

bullseye 0
Linux DietPi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux

This message appears bc there is already a RAID md0. You would need to delete it before make a new one with the same name or, as stated in the error, use the -f option.

Did you save your mdadm config after creation to mdadm.conf and updated initramfs? Maybe you can tell us more about the process.

As a side note, we have a series of blog articles on raid setup Using a RAID system with DietPi – part 1 – DietPi Blog

1 Like

I tried using -f, but got the same message. What do you mean there is already a md0 RAID? How can I remove that - when I go to drive_manager it just shows 1 md0

[ INFO ] DietPi-Drive_Manager | Detecting drives, please wait...
[ INFO ] DietPi-Drive_Manager |  - Detected mounted physical drive: /dev/mmcblk0p2 > /
[ INFO ] DietPi-Drive_Manager |  - Detected mounted physical drive: /dev/mmcblk0p1 > /boot
[ INFO ] DietPi-Drive_Manager |  - Detected mounted physical drive: /dev/sda1 > /mnt/samsung500gb
[ INFO ] DietPi-Drive_Manager |  - Detected unformatted drive: /dev/sdb
[ INFO ] DietPi-Drive_Manager |  - Detected unformatted drive: /dev/md0
[ INFO ] DietPi-Drive_Manager |  - Detected unformatted drive: /dev/sdc

I followed the tutorial @Joulinar has linked to and ran:

mdadm --examine --scan --verbose >> /etc/mdadm/mdadm.conf

After that I checked the file by doing nano /etc/mdadm/mdadm.conf and there’s hardly anything in that file?

# mdadm.conf
# !NB! Run update-initramfs -u after updating this file.
# !NB! This will ensure that initramfs has an uptodate copy.
# Please refer to mdadm.conf(5) for information about this file.

# by default (built-in), scan all partitions (/proc/partitions) and all
# containers for MD superblocks. alternatively, specify devices to scan, using
# wildcards if desired.
#DEVICE partitions containers

# automatically tag new arrays as belonging to the local system
HOMEHOST <system>

# instruct the monitoring daemon where to send mail alerts

# definitions of existing MD arrays

# This configuration was auto-generated on Wed, 07 Feb 2024 09:43:55 +0000 by mkconf

This message appears only when there is already a device /dev/md0, bc of this you would need to force override it.
But I found the reason why the second command did not work:

The syntax is messed up. -L is for setting a label, but right after that you inserted the -f and then you specify the label name, this can not work.
Try sudo mkfs.btrfs -f -L "homecloud" /dev/md0
Also you would need to set up the RAID again with mdadm and then write to the config file before you reboot the machine. Also don’t forget to update the initramfs.

I propose two tests:

#1: Wait until the whole md0 is generated (monitor the 100% via /proc/mdstat). Maybe you need to wait with the mkfs.

#2: Try to use a partition based format. I.e., generate ext4 partitions sdb1 and sdc1 q(via dietpi-drive_manager) and do the mdadm create with these partitions instead using sdb and sdc (mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1).
I made some experiences that with my USB devices this seemed to run more stable. But I am not sure about this, so you could do this test.
This then looks like this:

sdb       8:0    0  1,8T  0 disk
└─sdb1    8:1    0  1,8T  0 part
  └─md0   9:0    0  5,5T  0 raid5 /mnt/raid
sdc       8:16   0  1,8T  0 disk
└─sdc1    8:17   0  1,8T  0 part
  └─md0   9:0    0  5,5T  0 raid5 /mnt/raid

Myself, I ended up switching from USB devices to SATA interface on an AsRock J4125 mini ITX board due to a mounting of all into a small PC housing. I use a RAID5 like in my blog post running very stable.

Thanks for explaining @Jappe I’ll give that a go in the morning - I did try putting the -f at the end, but then it looked like it just hung with a white block showing on the left

I can’t really wait till it completes - I think it’s going to take over a week and the amount of times this rpi needs rebooting that’s not going to happen.

The partition plan might be an idea but the tutorial says to remove all partitions, but hey if the other suggestion doesn’t work in the morning I’ll give this a go - cheers

Tried that and like I said before it just reverts to a block on the left after the see for more info line. Does that mean it’s doing something? Is there anyway to check the progress?

md0 : active raid1 sdc[1] sdb[0]
      5119867904 blocks super 1.2 [2/2] [UU]
      [=>...................]  resync =  5.2% (267649024/5119867904) finish=12881451.8min speed=6K/sec
      bitmap: 38/39 pages [152KB], 65536KB chunk

unused devices: <none>
root@DietPi:~# sudo mkfs.btrfs -f -L "homecloud" /dev/md0
btrfs-progs v5.10.1
See http://btrfs.wiki.kernel.org for more information.

If you see root@DietPi:~# again this step has finished.
There is no out-of-the-box way to show the progress. You can check with htop or ps aux | grep mkfs.btrfs if it is still running, but when it’s finished you will see root@DietPi:~# and you can provide new inputs.

but you would need to wait until the rsync is finished

resync =  5.2% (267649024/5119867904) finish=12881451.8min speed=6K/sec

Ah I left it to format for 10 hours tried to check drive_manager and it just stopped. Exited that ssh session, ssh back in ran drive manager again this time it worked, but no md0 showing - tried to get a progress update on the raid creation and nada

root@DietPi:~# cat /proc/mdstat
cat: /proc/mdstat: No such file or directory

Don’t think this is going to work

I tried to replicate this, but I tried to use two 2,5" HDDs and I have no powered USB hub so my device gets unresponsive when undervoltage appears…
But I can try next week, a powered hub is already on it’s way.

Yeah I had the same issue got the powered hub Thursday, but still no dice - think I might give OMV a go.

Might just have bought 2 dodgy drives - don’t understand why it’s such a big deal though can format on windows in seconds

Regarding the format duration you have to take into account the running RAID build process which slows down the formatting.
To see how quick a format procedure runs you could do an ext4 formatting w/o having a RAID and compare this to Windows.

I would prefer to let mdadm run the RAID build to its end before formatting and using the RAID.

yes, did you wait to let it finish? Maybe a RPi3B is not a good choice to build a RAID :sweat_smile:
I just realized this right now. I’m trying to build the raid on laptop, 8 core CPU but just connected with USB 2 hub (which is the limiting factor here?)
Would take around 6 hours.

1 Like

If the figure 12,881,451 min is the duration to finish your RAID build, it would last about 24 years.
I don’t think it’s a good idea to build a raid on this base.
From these figures I assume a 4 TB disk, right?

On your first screenshot, the RAID builds with a speed of about 7.9 MB/sec which would last about 6 days (if I calculated right the 4 TB).

Yeah started out at 7/8,000k/sec down to 6k/sec - finally time to ditch the pi then - guess a n100 would be the next mini pc up?

Can the slowdown be influenced by the formatting command?

An AsRock N100 board is fine.
Plenty of power, M.2 for boot disk.
One disadvantage is, that only 2 SATA ports are onboard.

My J4125 has 4 SATA ports, but no M.2 to boot. Therefore I boot from an USB stick. :slight_smile:

The N100 is faster, newer and has a lower TDP.
Additional SATA ports can be extended via the PCIe slot.
I am using a “small” power supply with a Mini ITX psu which consumes little power.

I found a post on OMV forum that says that you can do backups using rsync or rsnapshot - does dietpi have any similar functionality - then I can avoid the whole RAID1 setup altogether - don’t really want to start from scratch again.