Raspberry Pi Raid 5 Array Using ROCK Pi Quad SATA Hat
I bought the Quad SATA Hat after watching a review of it from NovaSpirit Tech on Youtube. It took me a while to get the raid5 array set up, but it appears to be working after going through the process a couple times. Looking back, additional research before getting started would have been useful.
I used four 1 TB 2.5" WD Red NAS drives connected to the hat, and it makes a nice little package when all assembled. I decided to go with a raid5 array to provide some redundancy in case of drive failure.
The first step was to create the actual raid array. All four drives were recognized when the device booted up, so I reformatted all of the drives using the default fdisk settings.
One of the drives I received had apparently been a part of a previous raid array, so I had to issue the following command to before I could add it to my soon-to-be-create array
sudo mdadm --stop /dev/md127
Then I issued the command to create the raid array.
sudo mdadm --create /dev/md0 --level=5 --raid-devices=4 /dev/sda /dev/sdb /dev/sdc /dev/sdd
This was pretty quick process, and resulted in a 3TB raid array. I then had to create a mounting point for the array.
sudo mkdir -p /mnt/raid0
and create a filesystem on the raid.
sudo mkfs.ext4 /dev/md0
I was then ready to mount the raid device to my Pi.
sudo mount /dev/md0 /mnt/raid0/
### Issues I Encountered
One of the pages I went to suggested running this command to enter the new array into /etc/fstab.
echo "UUID=b9b10b2d-f2f8-4af5-b5e8-7bd516f4e194 /mnt/raid0/ ext4 defaults,noatime 0 2" | sudo tee -a /etc/fstab
I did this, but kept having boot issues. Eventually, I discovered that the fstab entry was being added automatically, so I didn’t need to create one on my own. When I ran that command, I was adding a second entry into /etc/fstab for the same raid array. Obviously, that won’t work, so I removed the “manual” entry.
This same site recommended running the following command to add the array to the /etc/mdadm/mdadm.conf file.
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
Because I had to create the array a couple times, I ended up with multiple entries in the conf file, and the array wouldn’t mount. This was clearly my fault for not checking the mdadm.conf file before running the command. To fix the issue, I ended up having to run the command below to find which UUID the drives were associated with, and only keep that one entry in the mdadm.conf file.
mdadm --examine /dev/sd*
Once that was cleared up, the raid array worked just fine. The Pi boots and the raid array mounts as expected.