# Having issues setting up a RAID1 using mdadm

**URL:** <https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317>\
**Category:** Troubleshooting\
**Created:** [15 February 2024 11:49 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317 "2024-02-15T11:49:38Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![samyH](https://dietpi.com/forum/user_avatar/dietpi.com/samyh/32/2892_2.png) [@samyH](https://dietpi.com/forum/u/samyH)\
**Post date:** [15 February 2024 11:49 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/1 "2024-02-15T11:49:38Z")

</div>

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](https://dietpi.com/blog/?p=2239) tutorial - with 2 fresh 5tb 2.5" drives.

```auto
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:

```auto
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.

G\_DIETPI\_VERSION\_CORE=8  
G\_DIETPI\_VERSION\_SUB=22  
G\_DIETPI\_VERSION\_RC=3  
G\_GITBRANCH=‘master’  
G\_GITOWNER=‘MichaIng’  
bullseye 0  
Linux DietPi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux  
arm64  
RPi3b

---

<div class="post-metadata">

**Author:** ![Jappe](https://dietpi.com/forum/user_avatar/dietpi.com/jappe/32/1788_2.png) [@Jappe](https://dietpi.com/forum/u/Jappe)\
**Post date:** [15 February 2024 13:38 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/2 "2024-02-15T13:38:03Z")

</div>

> [@samyH](#):
>
> But just get an error when I try to format:
> 
> `ERROR: use the -f option to force overwrite of /dev/md0`

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.

> [@samyH](#):
>
> 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.

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

---

<div class="post-metadata">

**Author:** ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)\
**Post date:** [15 February 2024 14:54 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/3 "2024-02-15T14:54:07Z")

</div>

As a side note, we have a series of blog articles on raid setup [Using a RAID system with DietPi – part 1 – DietPi Blog](https://dietpi.com/blog/?p=2239)

---

<div class="post-metadata">

**Author:** ![samyH](https://dietpi.com/forum/user_avatar/dietpi.com/samyh/32/2892_2.png) [@samyH](https://dietpi.com/forum/u/samyH)\
**Post date:** [15 February 2024 16:13 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/4 "2024-02-15T16:13:13Z")

</div>

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

```auto
[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:

```auto
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?

```auto
# 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
MAILADDR root

# definitions of existing MD arrays

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

```

---

<div class="post-metadata">

**Author:** ![Jappe](https://dietpi.com/forum/user_avatar/dietpi.com/jappe/32/1788_2.png) [@Jappe](https://dietpi.com/forum/u/Jappe)\
**Post date:** [15 February 2024 16:55 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/5 "2024-02-15T16:55:34Z")

</div>

> [@samyH](#):
>
> What do you mean there is already a md0 RAID?

> [@samyH](#):
>
> ERROR: use the -f option to force overwrite of /dev/md0

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:

> [@samyH](#):
>
> `root@DietPi:~# sudo mkfs.btrfs -L -f "homecloud" /dev/md0`

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.

---

<div class="post-metadata">

**Author:** ![StephanStS](https://dietpi.com/forum/user_avatar/dietpi.com/stephansts/32/2522_2.png) [@StephanStS](https://dietpi.com/forum/u/StephanStS)\
**Post date:** [15 February 2024 19:01 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/6 "2024-02-15T19:01:37Z")

</div>

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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![samyH](https://dietpi.com/forum/user_avatar/dietpi.com/samyh/32/2892_2.png) [@samyH](https://dietpi.com/forum/u/samyH)\
**Post date:** [15 February 2024 23:01 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/7 "2024-02-15T23:01:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![samyH](https://dietpi.com/forum/user_avatar/dietpi.com/samyh/32/2892_2.png) [@samyH](https://dietpi.com/forum/u/samyH)\
**Post date:** [15 February 2024 23:04 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/8 "2024-02-15T23:04:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![samyH](https://dietpi.com/forum/user_avatar/dietpi.com/samyh/32/2892_2.png) [@samyH](https://dietpi.com/forum/u/samyH)\
**Post date:** [16 February 2024 08:27 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/9 "2024-02-16T08:27:58Z")

</div>

> [@Jappe](#):
>
> sudo mkfs.btrfs -f -L “homecloud” /dev/md0

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?

```bash
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.

```

---

<div class="post-metadata">

**Author:** ![Jappe](https://dietpi.com/forum/user_avatar/dietpi.com/jappe/32/1788_2.png) [@Jappe](https://dietpi.com/forum/u/Jappe)\
**Post date:** [16 February 2024 10:35 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/10 "2024-02-16T10:35:02Z")

</div>

> [@samyH](#):
>
> it just reverts to a block on the left

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.

edit:  
but you would need to wait until the rsync is finished

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

```

---

<div class="post-metadata">

**Author:** ![samyH](https://dietpi.com/forum/user_avatar/dietpi.com/samyh/32/2892_2.png) [@samyH](https://dietpi.com/forum/u/samyH)\
**Post date:** [16 February 2024 20:00 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/11 "2024-02-16T20:00:05Z")

</div>

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  
root@DietPi:~#

Don’t think this is going to work

---

<div class="post-metadata">

**Author:** ![Jappe](https://dietpi.com/forum/user_avatar/dietpi.com/jappe/32/1788_2.png) [@Jappe](https://dietpi.com/forum/u/Jappe)\
**Post date:** [16 February 2024 20:12 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/12 "2024-02-16T20:12:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![samyH](https://dietpi.com/forum/user_avatar/dietpi.com/samyh/32/2892_2.png) [@samyH](https://dietpi.com/forum/u/samyH)\
**Post date:** [16 February 2024 20:47 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/13 "2024-02-16T20:47:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![StephanStS](https://dietpi.com/forum/user_avatar/dietpi.com/stephansts/32/2522_2.png) [@StephanStS](https://dietpi.com/forum/u/StephanStS)\
**Post date:** [17 February 2024 10:04 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/14 "2024-02-17T10:04:48Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Jappe](https://dietpi.com/forum/user_avatar/dietpi.com/jappe/32/1788_2.png) [@Jappe](https://dietpi.com/forum/u/Jappe)\
**Post date:** [17 February 2024 10:18 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/15 "2024-02-17T10:18:58Z")

</div>

> [@samyH](#):
>
> ` [=>...................] resync = 5.2% (267649024/5119867904) finish=12881451.8min speed=6K/sec`

yes, did you wait to let it finish? Maybe a RPi3B is not a good choice to build a RAID 😅  
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.

---

<div class="post-metadata">

**Author:** ![StephanStS](https://dietpi.com/forum/user_avatar/dietpi.com/stephansts/32/2522_2.png) [@StephanStS](https://dietpi.com/forum/u/StephanStS)\
**Post date:** [17 February 2024 18:00 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/16 "2024-02-17T18:00:08Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![samyH](https://dietpi.com/forum/user_avatar/dietpi.com/samyh/32/2892_2.png) [@samyH](https://dietpi.com/forum/u/samyH)\
**Post date:** [18 February 2024 12:50 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/17 "2024-02-18T12:50:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![StephanStS](https://dietpi.com/forum/user_avatar/dietpi.com/stephansts/32/2522_2.png) [@StephanStS](https://dietpi.com/forum/u/StephanStS)\
**Post date:** [18 February 2024 20:52 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/18 "2024-02-18T20:52:57Z")

</div>

Can the slowdown be influenced by the formatting command?

---

<div class="post-metadata">

**Author:** ![StephanStS](https://dietpi.com/forum/user_avatar/dietpi.com/stephansts/32/2522_2.png) [@StephanStS](https://dietpi.com/forum/u/StephanStS)\
**Post date:** [18 February 2024 21:08 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/19 "2024-02-18T21:08:22Z")

</div>

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. 🙂

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.

---

<div class="post-metadata">

**Author:** ![samyH](https://dietpi.com/forum/user_avatar/dietpi.com/samyh/32/2892_2.png) [@samyH](https://dietpi.com/forum/u/samyH)\
**Post date:** [20 February 2024 10:05 UTC](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317/20 "2024-02-20T10:05:59Z")

</div>

I found a [post](https://forum.openmediavault.org/index.php?thread/45773-create-raid-1-on-a-blank-disk-copy-from-a-drive-and-grow-the-raid/) 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.

[Next page](https://dietpi.com/forum/t/having-issues-setting-up-a-raid1-using-mdadm/19317.md?page=2)
