In this tutorial you’ll learn, how to add HDD’s to your raspberry pi and create a raid array with themby using mdadm.
What you need
- Raspberry Pi 2 Model B or Banana Pi M1
- Ethernet connection or a supported USB Wifi adapter for the Pi
- SD or Micro SD Card
- SSH connection to the Pi
- USB Keyboard & USB Mouse
- HDMI Monitor
- A powered USB Hub
- 2 x USB HDD 1 TB
For the first three steps, you’ll need an HDMI Monitor, USB Mouse and an USB Keyboard.
And of course the Raspberry Pi and the SD Card. Make sure your Raspberry is connected to the internet (or at least internal network).
In order to follow the rest of the steps, you’ll need to install the Raspbian Distribution. You can read how on the official website, or in this tutorial for windows and mac.
Log into your Raspbian and enter the commands to update the Pi:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
Now reboot your Pi using
In order to let your “server” work headless, you need to set up SSH. Fortunately there are tutorials for this on the official page:
rootdelay=5 to the
cmdline.txt file in the
/boot directory to prevent issues with the raspberry booting up to fast for the raid.
Connect the USB HDDs via the powered USB-Hub to your Pi. To check if your drives are beeing recognized run
sudo fdisk -l. They should be called something like
/dev/sdb1 or similar.
If they are not shown, maybe this superuser post can help you!
To install run
sudo apt-get install mdadm. Then configure it following the steps below:
sudo mdadm -Cv /dev/md0 -l0 -n2 /dev/sd[ab]1 (or whatever your drives are called). This will create a raid0 array with the disks sda1 and sdb1. To create an other raid type change the flag
-l1for a raid1 and so on. (basicaly
-ln = raidn).
- As soon as mdadm is done, use
sudo fdisk -lto check if the raid drive exists. Look if
/dev/md0is the size of both your drives.
sudo mkfs /dev/md0 -t ext4to create an
ext4filesystem on the raid drive. You can change the type of filesystem according to your needs.
- Check the raid with
sudo mdadm --detail /dev/md0.
If you liked this tutorial, please check out Project Pi. My Source for this tutorial.