I was setting up a RAID 1 with mdadm at my RaspberryPi with two drives (both 2 TB and formatted with exFAT, both with independent power supplies), but I ran into an error.
Unfortunately I am not an expert at Linux und commands.
Here is what I've done:
- installed mdadm with apt-get install mdadm
- found both devices with
sudo fdisk -l
(as /dev/sda and /dev/sdb) - set up RAID 1 to /dev/md0 with
sudo mdadm -Cv /dev/md0 -l1 -n2 /dev/sd[ab]1
- formatted /dev/md0 with
sudo mkfs /dev/md0 -t ext4
- mounted /dev/md0 to /media/nas with
sudo mount /dev/md0 /media/nas
- edited /etc/fstab with
/dev/md0 /media/nas ext4 4 0 0
- added AUTOSTART=true to /etc/default/mdadm
- enabled samba in /etc/samba/smb.conf
Everything went well and I could upload my files to /media/nas with WinSCP.
Now my Problem:
The next day my uploads failed with error code 4 (no further error text).
When I run sudo fdisk -l
I found both devices sda and sdb.
Also there is /dev/md0 with size of 2000.3 GB, but there is also /dev/md127 with size 2000.3 GB.
When I run sudo mdadm --detail /dev/md0
I get the following:
/dev/md0: Version : 1.2 Creation Time : Fri Jan 5 12:23:50 2018 Raid Level : raid1 Array Size : 1953371712 (1862.88 GiB 2000.25 GB) Used Dev Size : 1953371712 (1862.88 GiB 2000.25 GB) Raid Devices : 2 Total Devices : 1 Persistence : Superblock is persistent
Update Time : Sun Jan 7 14:37:23 2018
State : clean, degraded
Active Devices : 1 Working Devices : 1 Failed Devices : 0 Spare Devices : 0
Name : raspberrypi:0 (local to host raspberrypi)
UUID : 926bc124:2945e335:1e79ab6c:06b12095
Events : 21
Number Major Minor RaidDevice State
0 0 0 0 removed
1 8 1 1 active sync /dev/sda1
The output of sudo mdadm --detail /dev/md127
is:
/dev/md127: Version : 1.2 Creation Time : Fri Jan 5 12:23:50 2018 Raid Level : raid1 Array Size : 1953371712 (1862.88 GiB 2000.25 GB) Used Dev Size : 1953371712 (1862.88 GiB 2000.25 GB) Raid Devices : 2 Total Devices : 1 Persistence : Superblock is persistent
Update Time : Sun Jan 7 14:38:47 2018
State : clean, degraded
Active Devices : 1 Working Devices : 1 Failed Devices : 0 Spare Devices : 0
Name : raspberrypi:0 (local to host raspberrypi)
UUID : 926bc124:2945e335:1e79ab6c:06b12095
Events : 27
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 0 0 1 removed
When I try to set up the RAID again with sudo mdadm -Cv /dev/md0 -l1 -n2 /dev/sd[ab]1
, I get the error:
mdadm: super1.x cannot open /dev/sda1: Device or resource busy
mdadm: failed container membership check
mdadm: cannot open /dev/sda1: Device or resource busy
How can I set the RAID up again, where does md127 come from and what causes this error?
(rebooting doesn't do anything)
Thanks in advance!
/etc/mdadm/mdadm.conf
before rebooting (e.g. blog.alexellis.io/hardened-raspberry-pi-nas/#30theraidarray or stewright.me/2017/08/create-raid-volume-raspberry-pi). Asmdadm.conf
does not describe your configuration, there will be a guess when finding raid info and the raid will be named frommd127
downwards. So just createmdadm.conf
as described, then modify it to readmd0
instead ofmd127
. After reboot it should work again.ARRAY /dev/md0 metadata=1.2 name=raspberrypi:0 UUID=97660f1c:97eabbc5:789d6f50:92703ab2