How to Set Up RAID on a Dedicated Linux Server

RAID can help protect your data or make your server faster. If you have more than one disk on your Linux server, you can use RAID to make the most of it. In this post, I’ll guide you through setting up RAID step by step, in a way that’s easy to understand. I’ll also share a few tips based on my own experience.

RAID stands for Redundant Array of Independent Disks. That sounds complicated, but it just means you connect multiple hard drives together to work as one system. Depending on how you set it up, RAID can help you:

  • Keep data safe if a disk fails.
  • Improve read and write speed.
  • Do both at the same time.

There are different kinds of RAID, and I’ll explain some of them here. We’ll also go through how to set up software RAID using a tool called mdadm on a Linux server.


What You Need Before You Start

Before jumping in, make sure you have:

  • A dedicated Linux server (I use Debian or CentOS most of the time).
  • At least two extra disks (more is better for certain RAID levels).
  • sudo or root access.
  • Backups. Always make a backup before touching your disks.

If your server is already running something important, be extra careful. RAID will delete all data on the disks you use.


What Is Software RAID?

There are two ways to set up RAID: hardware and software.

Hardware RAID needs a special card or motherboard that handles the setup. It’s faster, but more expensive. You usually find this in fancy servers.

Software RAID, which we’ll use, is set up using programs like mdadm. Your computer’s CPU handles everything. It’s a bit slower, but it works well and it’s free.

I’ve used software RAID for small personal servers and even a few work projects. It works great when done right.


Common RAID Types (and What They Do)

You don’t need to learn them all. Just pick one based on your goal. Here are three popular types:

1. RAID 0 (Striping)

  • Combines two or more disks into one big, fast disk.
  • Good for speed.
  • No safety — if one disk dies, you lose everything.

2. RAID 1 (Mirroring)

  • Copies data to two or more disks.
  • Great for safety — if one disk fails, the other keeps going.
  • But you lose half your space.

3. RAID 5 (Striping with Parity)

  • Needs at least 3 disks.
  • Gives both speed and safety.
  • One disk can fail, and you don’t lose data.

I usually use RAID 1 for small setups where I care about data. RAID 5 is better for larger servers.


Step-by-Step: How to Set Up Software RAID with mdadm

Let’s walk through making a RAID 1 setup (mirroring two disks). You can follow similar steps for other RAID types too.

Step 1: Install mdadm

First, update your system and install mdadm.

For Debian or Ubuntu:

sudo apt update
sudo apt install mdadm

For CentOS or RHEL:

sudo yum install mdadm

Step 2: Check Your Disks

Find the names of your disks:

lsblk

You might see something like this:

sda     100G
sdb     500G
sdc     500G

Let’s say sdb and sdc are your new, empty disks.

Check for any partitions:

sudo fdisk -l

If there are any, delete them using fdisk or wipefs.

Step 3: Create the RAID Device

Let’s create a RAID 1 array:

sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdb /dev/sdc

Here’s what this means:

  • /dev/md0: This is the new RAID device we’re making.
  • --level=1: This is RAID 1 (mirror).
  • --raid-devices=2: Two drives will be used.

After you run this, the RAID array will be created. It might take time to sync.

You can check the progress:

cat /proc/mdstat

Step 4: Save the RAID Configuration

To make sure your RAID works after reboot, save the config:

sudo mdadm --detail --scan >> /etc/mdadm/mdadm.conf

For CentOS or RHEL:

sudo mdadm --detail --scan >> /etc/mdadm.conf

Then update initramfs (on Debian/Ubuntu):

sudo update-initramfs -u

Step 5: Create a Filesystem and Mount It

Now, let’s format the new RAID device:

sudo mkfs.ext4 /dev/md0

Create a folder to mount it:

sudo mkdir /mnt/raid

Mount it:

sudo mount /dev/md0 /mnt/raid

To mount it automatically at boot, add it to /etc/fstab. First, get the UUID:

sudo blkid /dev/md0

Then edit /etc/fstab:

sudo nano /etc/fstab

Add a line like:

UUID=your-uuid-here  /mnt/raid  ext4  defaults,nofail  0  0

Step 6: Verify and Monitor

To check your RAID status anytime:

cat /proc/mdstat

Or get more detail:

sudo mdadm --detail /dev/md0

If something fails, you can replace a disk and re-sync it. mdadm has options for that.


Three Handy Lists for RAID Setup

Tools You’ll Use

  • lsblk — to list your disks
  • mdadm — to create and manage RAID
  • mkfs.ext4 — to format the RAID array
  • mount and fstab — to mount the new disk

Mistakes to Avoid

  • Don’t use RAID on disks with data you want to keep. It will erase them.
  • Double check disk names like /dev/sdb — wrong choices can destroy data.
  • Don’t forget to save the RAID config or it won’t come back after reboot.

Why Use RAID?

  • It protects your files if a disk fails.
  • It can boost disk speed (RAID 0, RAID 5).
  • It makes your server more stable.

My Thoughts and Experience

I first tried setting up RAID when I was learning how to build a home server. I made a lot of mistakes. I lost data once by not double checking the disk names. Since then, I always label my disks using lsblk and blkid.

RAID is powerful, but it’s not a backup. I still use cloud or external backups just in case. I see RAID as a safety net, not a solution for everything.

Would I use RAID on every server? Not always. For example, on VPS systems with only one disk, it doesn’t make sense. But on dedicated servers with multiple drives? Definitely.


Final Thoughts

Setting up RAID might sound hard at first. But once you understand the steps, it becomes just another useful tool. If you work with servers, learning RAID is a good skill to have.

Now you know how to:

  • Choose the right RAID level
  • Set up software RAID with mdadm
  • Format, mount, and save your configuration
  • Check and monitor your RAID

Do you have unused disks in your server? This could be a great time to try RAID. Just test it in a safe place first. Once you’re confident, you can use it in production.

Leave a Reply