Setup RAID on the Raspberry Pi

Set Up RAID on Raspberry Pi: Step-by-Step Guide

If you click our links and make a purchase, we may earn an affiliate commission. Learn more

I often worry about what might happen if a drive fails when storing important files on my Raspberry Pi as a home server, media center, or personal project. One crash and poof, all my data is gone. But what if there were a way to protect your data so that, even if one drive fails, the system continues to function as if nothing happened?

RAID-1 can be configured on the Raspberry Pi using software tools like mdadm and Webmin. A RAID array can provide data redundancy through disk mirroring, ensuring continued operation in the event of a single drive failure.

In this guide, I’ll walk you through a step-by-step Raspberry Pi RAID-1 configuration, explain what RAID actually is (in plain English), and show you how to recover from drive failure like a pro. We’ll even use Webmin for an easier, click-based setup.

If you’re new to Raspberry Pi or Linux, I’ve got something that can help you right away!
Download my free Linux commands cheat sheet – it’s a quick reference guide with all the essential commands you’ll need to get things done on your Raspberry Pi. Click here to get it for free!

Understanding RAID Levels (Made Simple)

RAID stands for “Redundant Array of Independent Disks”. It might sound complicated, but the core idea is simple: we combine multiple drives to improve speed, redundancy, or both.

Not using RAID is like driving a car without a spare tire. If one blows out, you’re stuck. Some RAID configurations are even better because they keep running smoothly; you won’t even notice when a disk fails.

Let me break down the most common RAID levels so you can see why RAID 1 is the best fit for Raspberry Pi users.

RAID 0

RAID 0 splits (or stripes) data into multiple pieces stored across two or more drives. This feature makes reading and writing data quite faster.

However, RAID 0 offers no redundancy or backup. If one drive fails, all the data is lost, making it a risky and not recommended option for Raspberry Pi setups.

RAID 1

RAID 1 is way more interesting. It creates an exact copy (mirror) of your data on two drives.

Prefer reading without ads and popups?
Members get an ad-free version of every guide, plus exclusive project support.
Join the Community | Sign In

If one drive fails, the other still holds all your data. This level doesn’t improve performance, but it greatly improves reliability, which makes it ideal for Raspberry Pi users running home servers, NAS, or backup systems.

It looks like that, basically:

Why it works well on the Raspberry Pi:
RAID 1 is simple, doesn’t require high CPU resources, and provides peace of mind with minimal hardware (just two drives).

RAID 5

RAID 5 is a bit overkill for Raspberry Pi users. It splits your data across 3 drivers or more. It also adds parity, which is extra information that helps rebuild data if one disk fails.

It slows down disk usage a bit, but it’s more efficient with space and safer for large servers. As a sysadmin, I generally used that on traditional servers, but not on Raspberry Pi.

RAID 10

RAID 10 mirrors and stripes data across at least four drives for high performance and fault tolerance.

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

As we proceed, it’s good to note that there are many RAID levels, including nested or hybrid RAID levels and others, which are proprietary, such as HP’s ADG and ZFS RAID-Z.

What You’ll Need for RAID on Raspberry Pi

Below are the items you will need for this project.

Hardware Requirements

  • Raspberry Pi: In this post, I will use a Raspberry Pi 4 board. I highly recommend using a board like Raspberry Pi 3B, Raspberry Pi 4, or Raspberry Pi 5. Earlier models would still work, but they will struggle due to limited USB bandwidth and low CPU performance.

    While working on this project, my Raspberry Pi 4 broke down, and I tried using a Raspberry Pi 2 Model B. The performance was so poor (especially write speeds) that I decided to look for another powerful Raspberry Pi board. Use this article to determine your Raspberry PI model if you are unsure.
  • External drives (USB HDDs or SSDs): You’ll need a minimum of two drives to create a RAID 1 array. These can be traditional hard drives or SSDs connected via a USB port. In my case, I am using two 128GB SSDs.
  • Powered USB hub (if needed): Since the SSDs will draw more power than the Raspberry Pi’s USB ports can provide, you will need to use a powered USB hub. For this tutorial, I am using a TP-Link powered USB hub, which you can also get on Amazon.
  • Internet connection: A stable internet connection is required to install essential packages like mdadm and Webmin.
  • Heatsink/fan (optional): A fan is not a necessity. However, if you plan to run this operation for quite some time, a cooling solution will be necessary. You can read our articles on installing a fan, heat sinks, or casing with in-built cooling solutions.

Power warning:

Before we continue, let me explain why we need to use a powered USB hub for this setup. I will use my setup as an example.

I am using two SSDs. Each SSD can draw up to 5 Watts at peak usage. Since they are two, that means they are drawing double the Watts.

2 SSDs × 5W = 10W

Now let’s add the Raspberry Pi board to this picture. I am using a Raspberry Pi 4, which needs around 6W under normal load, and it can spike to 8W when overclocked or pushed to its limits. For your information, I have overclocked my Raspberry Pi to increase its performance.

Now, if you have gone through our article on how to power a Raspberry Pi, you already know the official Raspberry Pi 4 power supply delivers 5.1V at 3.0A. That gives me:

5.1V × 3A = 15.3W total

It might seem like I am safe to plug the SSDs directly into the Raspberry Pi USB ports, but when I add the total Watts consumed by the Raspberry Pi board and the two SSDs, things start looking ugly.

10W (SSDs) + 8W (overclocked Pi) = 18W

That’s already more than the power adapter can handle.

Smart Move: Power your SSDs externally (using a powered USB hub or drives with their adapters). That way, your Pi can breathe and run smoothly without crashing under pressure.

Software Requirements

For the software requirements, we will only need two programs:

  • Webmin: a web interface for system management.
  • mdadm: the tool that will handle the RAID configuration.

In the next sections, I’ll show you how to install both.

Install Webmin

Webmin is a web-based tool used mainly in server management for Unix-like systems. It can be used to perform several operations, including managing users, configuring disk quotas and services, and managing configuration files. It also plays a key role in carrying out RAID operations.

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

The steps below give a step-by-step guide on installing Webmin on the Raspberry Pi.

  • Edit the sources.list file. You can learn more about the sources.list file in our article about repositories on Linux systems.
    sudo nano /etc/apt/sources.list
  • Once we have opened the sources.list file, we will copy and paste the line below:
    deb http://download.webmin.com/download/repository sarge contrib
    Once done, save the file (Ctrl + S) and close the editor (Ctrl + X).
  • Next, we will download the GPG (GNU Privacy Guard) key to verify that the package we are downloading hasn’t been tampered with by running the command below:
    wget -q -O- http://www.webmin.com/jcameron-key.asc | sudo apt-key add
  • Next, we will run the update command below to update the new repositories:
    sudo apt update
  • Once done, we will proceed to install Webmin using the command below:
    sudo apt install webmin
  • After a successful installation, we will set up a password for the root user, as we will need it to manage Webmin:
    sudo su
    passwd

If you need more details, please check out our full guide to Webmin.

Quick note: If you find it hard to remember all these commands, I’ve put them all on a one-page cheat sheet. You can download it for free here so you have it handy whenever you're working on a project.

Install mdadm

mdadm, an abbreviation for Multiple Device Admin, is a powerful Linux utility used to create, manage, and monitor software RAID arrays. We are mainly using mdadm because the Raspberry Pi doesn’t support hardware RAID.

mdadm allows us to implement software RAID which is especially useful for RAID 1 (mirroring). It is available in the Raspberry Pi official repositories, and we can easily install it using the command below:

sudo apt install mdadm

Process to Configure the RAID-1 Array

To this point, we have everything ready to proceed with setting up RAID 1 on the Raspberry Pi. The Raspberry Pi is up and running, we have connected the drives and installed the necessary software – webmin and mdadm.

Now let’ me take’s go through the step-by-step process of configuring a RAID-1 array.

Format Disks

First, we will need to format the two SSDs. You can use any tool, but I recommend Gnome Disks or Gparted. I will use Gnome Disks.

Use Webmin to Create RAID-1 Array

Next, we will open our browser and use the URL below to access the Webmin panel:

https://localhost:10000/

Now, since we have specified in the URL we want to use HTTPS, but we haven’t installed or configured any SSL certificate for our local Webmin installation, we will see a warning that “Your connection is not private.

However, since we are fully aware of the site we are accessing, all we need to do is click “Advanced” and then “Proceed” to access Webmin. Here, we will see a login screen.

We will need to log in with the credentials of the root user we set after installing Webmin. If you missed that step, please go and check the last step in the “Install Webmin” section.

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

The username is “root” while the password is the unique password that you set.

After a successful login, we will see the Webmin cPanel. First, refresh the modules by clicking the “Refresh Modules” button at the bottom of the left-hand panel. Next, expand the “Hardware Menu” and select “Linux RAID.”

On the new screen that appears, select RAID (Mirrored) from the drop-down menu and then click “Create RAID device of level.”

After a few minutes, Webmin will open the “RAID Device Options”. Here, we need to select the two disks in the “Partitions in RAID” section by holding the CTRL key and using the left mouse button to select each disk.

There is a radio button option for “Skip initialization of device.” Here, we will select “Yes” because initialization might take more than an hour for every 100GB, and in this case, we don’t have any data on these drives. Once done, click the “CREATE” button.

After a few minutes, Webmin will respond and show a screen with the newly created array. The two disks are listed as “Partitions in RAID.” You can see that in the image below, where we have SCSI device A and SCSI device B.

Another thing that we need to note here is that under the “File system status,” the partitions are “Active but not mounted.”

Mount the New RAID Array

Before mounting the new RAID, we first need to format it. As we did before, we can use GParted or Gnome-Disks. However, I recommend you use Gnome Disks so you can follow along in this section. Select the RAID-1 Array and Format Partition.

We will give the new partition a memorable name like “DATA.”

Since we are using it with the Raspberry Pi OS, which is a Linux distribution, we need to select the radio button for “Internal disk for use with Linux systems only (Ext4).” Once done, we need to click next and format the partition.

Now, this new array needs to be mounted every time the Raspberry Pi boots. Using GNOME Disks, right-click on the partition and select “Edit Mount Options.”

In the “Mount Options” window, we need to toggle the “User Sessions Defaults” button. You might see a prompt to enter the logged-in user’s password. Complete the authentication and click “Ok.” This process will proceed to edit the /etc/fstab file.

Once done, we will reboot the Raspberry Pi, and we should see the mounted array appear on the file system listed with the name you assigned it after formatting. In my case, it is “Data.”

Move the Home Directory to RAID-1 Array

Now that the RAID-1 array is running, it’s time to store something valuable on it. For this setup, we will use the home directory, where all our user files are stored. This step helps protect your data by mirroring it across two drives.

But here’s the trick. Instead of moving the home directory, we’ll copy it. We do this just in case something goes wrong and you need to rebuild the array later, having the original /home intact can make recovery easier.

Lost in the terminal? Grab My Pi Cheat-Sheet!
Download the free PDF, keep it open, and stop wasting time on Google.
Download now

Follow the steps below.

  • First, let’s check what’s mounted under /mnt:
    ls /mnt
    Here, we see a folder with a long string of characters. Yours might look different but also just a bunch of characters:
    6256d81c-c23c-42c4-aea3-d194466c6c33
    That’s the RAID mount point. Copy that name.
  • Next, we will copy everything from the /home directory to the RAID array using rsync command shown below.
    Remember to replace the long UUID with your own:
    sudo rsync -av /home/* /mnt/6256d81c-c23c-42c4-aea3-d194466c6c33/

    This will copy all files while preserving permissions and timestamps.
  • Next, we need to point the system to use this RAID array as the new /home directory. To do that, we will need to open and edit the fstab file. Use the command below:
    sudo nano /etc/fstab
    Once open, we need to look for the line that mounts the RAID array (it’s likely near the bottom). Change the mount point from /mnt/… to /home as shown in the image below.
  • Once done, we need to reboot the Raspberry Pi. You can use the command below:
    sudo reboot now

After reboot, the home directory will live on the RAID-1 array, and any changes will be mirrored across both drives.


🛠 This tutorial doesn't work anymore? Report the issue here, so that I can update it!

Want to connect with other Raspberry Pi fans? Join the RaspberryTips Community. Ask questions, share your projects, and learn from each other. Join now.

Handling RAID Failures

Even with RAID in place, failures can still happen, like a drive dying or getting disconnected. The good news is that RAID is built for resilience, and the recovery process is usually easy when you know what to do.

Let’s look at some of the ways you can use to handle RAID failures.

Detecting a Degraded RAID Array

To check if your RAID array is healthy or degraded, we can use the command below:

cat /proc/mdstat

If everything is fine, we will see both drives listed as [UU]. If one is missing, it will show as [U_], meaning the array is degraded and running on a single disk.

If that is the case, there are two options that we can use to rebuild the degraded array:

  • Mount and Rebuild the Degraded Array:
    If the system still boots fine and the array is mounted, we can rebuild it without unmounting. Follow the steps below:
    • Plug in the replacement drive.
    • Partition it to match the existing RAID setup (use fdisk or parted).
    • Add it back to the array:
      sudo mdadm --add /dev/md0 /dev/sdX
      Please, remember to replace /dev/sdX with your new drive.
  • Rebuild Without Mounting:
    If we don’t want to risk mounting a degraded array, we can use the steps below:
    • Boot the system, but don’t mount the RAID manually or via /etc/fstab.
    • Add the replacement disk to the array using mdadm shown in the previous section.
    • Wait for the rebuild to complete first, then mount the array normally.
      This option is safer if you’re worried about potential data corruption or instability.

Simulating/Testing Failure

If we want to test our RAID setup for any problems, we can follow the steps below.

  • Unplug one of the drives while the system is running.
  • Run the command below:
    cat /proc/mdstat
  • If we see [U_], that means the array is now degraded.
  • Plug the drive back in and attempt a rebuild to confirm the process works.

Accessing Data While a Drive Has Failed

RAID-1 can still serve data from the surviving drive. So yes, we can still access our files even if one drive fails and we haven’t replaced it yet.

But we need to keep in mind that we’re no longer protected. Any issue with the second drive could lead to permanent data loss.

Rebuilding the Array (Step-by-Step)

When one of the drives fails, the only option left is to replace it and completely rebuild the array.

Below are the steps to rebuild the array.

  • Identify the failed disk:
    sudo mdadm --detail /dev/md0
  • Remove the bad drive from the array:
    sudo mdadm --fail /dev/md0 /dev/sdX
    sudo mdadm --remove /dev/md0 /dev/sdX
  • Prepare the new disk (create the same partition layout).
  • Add the new drive to the array:
    sudo mdadm --add /dev/md0 /dev/sdX
  • Watch the rebuild process:
    watch cat /proc/mdstat

That’s it! We have looked at how to set up RAID-1 on the Raspberry Pi and how to handle failures. With a RAID-1 setup, your data is better protected, and your Raspberry Pi becomes more reliable even for daily use.

I would, however, like to be honest with you. If it is your first time, you might encounter some processes that might take a while to execute. So, don’t think that at any point, maybe your Raspberry Pi has stalled. In my case, I didn’t skip “disk initialization,” and that process took nearly an hour and a half to complete.

Whenever you’re ready, here are other ways I can help you:

Test Your Raspberry Pi Level (Free): Not sure why everything takes so long on your Raspberry Pi? Take this free 3-minute assessment and see what’s causing the problems.

The RaspberryTips Community: Need help or want to discuss your Raspberry Pi projects with others who actually get it? Join the RaspberryTips Community and get access to private forums, exclusive lessons, and direct help.

Master your Raspberry Pi in 30 days: If you are looking for the best tips to become an expert on Raspberry Pi, this book is for you. Learn useful Linux skills and practice multiple projects with step-by-step guides.

Master Python on Raspberry Pi: Create, understand, and improve any Python script for your Raspberry Pi. Learn the essentials step-by-step without losing time understanding useless concepts.

You can also find all my recommendations for tools and hardware on this page.

Similar Posts