RAID Array

Thursday, Jun 18, 2026

I made a RAID Array with my Raspberry Pi

I had a problem with my NAS on my Raspberry Pi, for some reason it was running very slow and causing the Pi to crash randomly. It was just a single usb hard drive using Samba. So I decided to replace it with a RAID, in order to actaully get the Pi back in working order I had to reimage it. (I think this actually fixed my issue.) Then I got started making the RAID drive

Steps

  1. Installed mdadm using apt
    1. sudo apt update
    2. sudo apt install mdadm
  2. Then I had to attach and reformat the drives, the Raspberry Pi automatically mounted them so I had to unmount first.
    1. sudo umount /dev/sdX
    2. sudo mkfs -t ext4 /dev/sdX
  3. Once I had them all formated and attached not mounted
    1. sudo mdadm --create --verbose /dev/md0 --level=6 --raid-devices=X /dev/sdX Fill in the X with the drive names that you have, and you can change the name /dev/md0 to something else if you like.
  4. In order to keep it across reboots you need to run
    1. sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf This adds the drive information to the configuration file. tee -a will add the output to the end of the file.
    2. sudo update-initramfs -u This updates the initial file system for the Raspberry Pi.
    3. echo '/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab This adds it to the fstab file, which is what the computer using to mount the file systems on start up. IMPORTANT! nofail is important! your system can fail to boot if it doesn't detect the file system with out it.
  5. Then it spends a long time resyncing, basically creating itself.

I'm still at the last step here and building it, I hope this can be a good way to keep my files safe and find a use for old usb drives that I have laying around. I used this guide a lot Digital Ocean Guide