Optimizing for Fault Tolerance with RAID

Updated on Apr 15, 2026
Kimberly N
10 MINS READ
Table of Contents
Optimizing for Fault Tolerance with RAID

Administrators often have significant concerns about keeping data safe and accessible on a Linux VPS, even when hardware fails. A single disk failure can cause downtime and data loss. This is where RAID (Redundant Array of Independent Disks) comes in. Here, you will learn a step-by-step guide about Optimizing for Fault Tolerance with RAID on a Linux VPS to keep your data safe in case a disk fails.

This guide focuses on RAID levels 1, 5, and 6, which are the most practical choices for fault tolerance in a Linux VPS. The topics covered in this guide include:

  • Choose the right RAID level for optimizing for fault tolerance
  • Prepare and configure disks
  • Build and monitor the RAID array
  • Handle failures and rebuilds

By the end of this guide on the PerLod Hosting, you will have a system that maximizes uptime and minimizes risk.

Note: RAID is not a backup solution. Always combine RAID with off-site backups, monitoring, and a tested recovery plan to protect your data.

Choose the Right RAID Level for Optimizing Fault Tolerance

At this point, there is a question of which RAID we should use for optimizing fault tolerance. In this guide, we will focus on RAID 1, RAID 5, and RAID 6. Here are the key points for these RAID levels:

RAID 1 (Mirroring): Makes a full copy of your data on two disks. It is simple and has robust redundancy.

  • Minimum disks: 2.
  • Capacity: 50% of raw.
  • Tolerance: 1 disk failure.
  • Performance: Reads can improve, and writes are roughly like a single disk.

RAID 5 (Striping with Single Parity): Spreads data across at least 3 disks, keeps one disk’s worth of backup info. It has a good balance of capacity and tolerance.

  • Minimum disks: 3.
  • Capacity: (N−1) × size_of_smallest_disk.
  • Tolerates: 1 disk failure.
  • Performance: Writes pay parity overhead; reads are strong. It can be slower under small random writes.

RAID 6 (Striping with Double Parity): Needs at least 4 disks. Best for large arrays where rebuild takes longer.

  • Minimum disks: 4.
  • Capacity: (N−2) × size_of_smallest_disk.
  • Tolerates: 2 disk failures.
  • Performance: Highest parity overhead on writes; excellent read scaling.

Optimizing for Fault Tolerance with RAID on Linux VPS

Depending on your needs, you can choose the RAID level. In this guide, we will explain all these levels for optimizing fault tolerance on a Linux VPS.

You need multiple separate block devices like /dev/vdb, /dev/vdc, and more. For safety-first arrays, we will create a dedicated data mount point like /data.

Let's dive into the details.

1. Make Sure Disks Are Ready for RAID

First, you must verify the disks with the lsblk command to confirm that your VPS sees the separate empty disks you will use for RAID.

Bash
lsblk -o NAME,SIZE,TYPE,MOUNTPOINT,FSTYPE,MODEL

In your output, you must see separate and unmounted disks like /dev/vdb, /dev/vdc, /dev/vdd, and /dev/vde.

2. Set Up the Required Tools on Linux VPS

At this point, you must install the required tools on your VPS. Depending on your OS, you can use the following commands.

Debian/Ubuntu:

Bash
sudo apt updatesudo apt install mdadm parted xfsprogs e2fsprogs fio -y

RHEL/AlmaLinux/Rocky:

Bash
sudo dnf update -ysudo dnf install mdadm parted xfsprogs e2fsprogs fio -y

3. Partition the Disks for RAID

You can use the whole disk for RAID, but it is recommended to partition the disks to have better maintenance. For RAID 1, partition 2 disks. For RAID 5, partition 3 disks. For RAID 6, partition 4 disks.

Here, each disk gets a GPT label and a RAID partition.

Partition 2 disks for RAID 1 with the following command:

Bash
for d in /dev/vdb /dev/vdc; do  sudo parted -s "$d" mklabel gpt  sudo parted -s -a optimal "$d" mkpart primary 1MiB 100%  sudo parted -s "$d" set 1 raid ondone

Partition 3 disks for RAID 5 with the following command:

Bash
for d in /dev/vdb /dev/vdc /dev/vdd; do  sudo parted -s "$d" mklabel gpt  sudo parted -s -a optimal "$d" mkpart primary 1MiB 100%  sudo parted -s "$d" set 1 raid ondone

Partition 4 disks for RAID 6 with the following command:

Bash
for d in /dev/vdb /dev/vdc /dev/vdd /dev/vde; do  sudo parted -s "$d" mklabel gpt  sudo parted -s -a optimal "$d" mkpart primary 1MiB 100%  sudo parted -s "$d" set 1 raid ondone

After partitioning, you can verify them with the following command:

Bash
lsblk -o NAME,SIZE,TYPE,PARTTYPENAME /dev/vdb /dev/vdc /dev/vdd /dev/vde

4. Build the RAID Array for Optimizing Fault Tolerance

At this step, you must build the RAID array. Parity arrays benefit from a chunk size. 512 KiB is a practical default for mixed workloads.

RAID 1: Mirrors data across 2 disks.
RAID 5: Striped data plus single parity across 3 disks.
RAID 6: Striped data plus double parity across 4 disks.

Create a RAID 1 array with 2 disks by using the following command:

Bash
sudo mdadm --create /dev/md0 \  --level=1 \  --raid-devices=2 \  /dev/vdb1 /dev/vdc1

It mirrors the two members, which is simple and fast to rebuild.

Create a RAID 5 array with 3 disks by using the following command:

Bash
sudo mdadm --create /dev/md0 \  --level=5 \  --raid-devices=3 \  --chunk=512 \  /dev/vdb1 /dev/vdc1 /dev/vdd1

It stripes data across all members with one parity block per stripe.

Create a RAID 6 array with 4 disks by using the following command:

Bash
sudo mdadm --create /dev/md0 \  --level=6 \  --raid-devices=4 \  --chunk=512 \  /dev/vdb1 /dev/vdc1 /dev/vdd1 /dev/vde1

It is like RAID 5 but with two parity blocks. It tolerates two failures.

Monitor the build process and display detailed info with the following commands:

Bash
cat /proc/mdstatsudo mdadm --detail /dev/md0

5. Format the RAID for Storage - Make a Filesystem

At this step, you must create the filesystem. You can use XFS, which is best for RAID 5 and RAID 6 and handles large files well. Also, you can use ext4, but it needs tuning for stripes and parity. Let's see how to create them.

XFS (recommended on parity):

RAID 1: No special parameters needed. Use standard mkfs:

Bash
sudo mkfs.xfs -f /dev/md0

RAID 5 with 3 disks and data devices = 2. Parameters: su=512k, sw=2.

Bash
sudo mkfs.xfs -f -d su=512k,sw=2 /dev/md0

RAID 6 with 4 disks and data devices = 2. Parameters: su=512k, sw=2.

Bash
sudo mkfs.xfs -f -d su=512k,sw=2 /dev/md0

ext4 (alternative): With --chunk=512 and 4 KiB blocks: stride = 128.

RAID 1:

Bash
sudo mkfs.ext4 /dev/md0

RAID 5/6 with 2 data devices: stripe-width = 128 × 2 = 256:

Bash
sudo mkfs.ext4 -E stride=128,stripe-width=256 /dev/md0

6. Mounting the RAID Array - Use New RAID Disk

Now you need to create a mount point like /data and mount the RAID array there. To do this, you can run the following commands:

Bash
sudo mkdir -p /datasudo mount /dev/md0 /data

Also, you can add it to /etc/fstab so it mounts automatically after reboot. To do this, you must find the disk UUID with the command below:

Bash
sudo blkid /dev/md0

Then, add it to /etc/fstab with your filesystem.

For XFS:

Bash
echo 'UUID=YOUR-UUID /data xfs defaults,nofail 0 2' | sudo tee -a /etc/fstab

For ext4:

Bash
echo 'UUID=YOUR-UUID /data ext4 defaults,nofail 0 2' | sudo tee -a /etc/fstab

7. Enable Monitoring and Alerts for mdadm

To get early warnings, it is recommended to enable mdmonitor so you get email alerts if a disk fails. You need a working mail relay for email alerts.

On Debian / Ubuntu: Ensure mdadm scans arrays at boot and mdmonitor is enabled. You can add your email inside /etc/mdadm/mdadm.conf, for example MAILADDR you@example.com.

Bash
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.confsudo systemctl enable --now mdmonitor || true

On RHEL / AlmaLinux / Rocky Linux: Do the same with the following commands:

Bash
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm.confsudo systemctl enable --now mdmonitor

If you want the RAID array to be available early in boot, you must update the initramfs.

Debian/Ubuntu, run:

Bash
sudo update-initramfs -u

RHEL, run:

Bash
sudo dracut -H -f

8. Handle Failure and Rebuild Disks

If a disk fails, you can check its health, simulate failure for practice, replace the failed disk, and rebuild the array. Also, you can run filesystem checks if needed.

Check array health regularly:

Bash
cat /proc/mdstatsudo mdadm --detail /dev/md0

Simulate a failure:

Bash
sudo mdadm /dev/md0 --fail /dev/vdb1sudo mdadm /dev/md0 --remove /dev/vdb1

Replace with a new disk: Attach and partition the replacement the same way. Then, add it to the array and monitor rebuild:

Bash
sudo mdadm /dev/md0 --add /dev/vdf1cat /proc/mdstatsudo mdadm --detail /dev/md0

Filesystem integrity checks:

For ext4: unmount, or remount read-only, then run:

Bash
sudo fsck.ext4 -f /dev/md0

For XFS: You can use xfs_repair only when unmounted or read-only.

9. Expand the RAID Array Safely

If you plan to expand RAID storage, have a backup before reshaping the array.

  • RAID 1: Replace with bigger disks one by one.
  • RAID 5 and RAID 6: Add new disks, then reshape the array.

RAID 1: Replace one disk at a time with a larger one, let it rebuild, then grow:

Bash
sudo mdadm --grow /dev/md0 --size=max
Bash
sudo resize2fs /dev/md0 #ext4sudo xfs_growfs /data   #XFS

RAID 5 and RAID 6: You can add a device and reshape. For example, add /dev/vdf1 to a RAID 5:

Bash
sudo mdadm /dev/md0 --add /dev/vdf1sudo mdadm --grow /dev/md0 --raid-devices=4

Monitor until reshape completes:

Bash
watch -n5 cat /proc/mdstat

Then, grow the filesystem ext4 or XFS as above.

10. Performance Tips and Test RAID Speed with fio

Here are performance expectations and tuning notes you can consider:

RAID 1: Best for simple redundancy. Reads are fast, writes are the same as one disk.

RAID 5: Good capacity efficiency. Parity makes small random writes slower. Consider a larger chunk like 512 KiB and XFS.

RAID 6: Safest parity level. Slightly slower writes than RAID 5. Recommended for larger arrays.

Scheduler and queue depth: On some VPS platforms that are NVMe-backed, increasing I/O depth with fio --iodepth and using XFS can help.

You can also run fio for sequential and random read/write tests.

For the sequential test, you can run:

Bash
fio --name=seqrw --directory=/data --size=2G --bs=1M --rw=readwrite --rwmixread=70 --direct=1 --iodepth=16

For random 4k mixed, you can run:

Bash
fio --name=randrw --directory=/data --size=1G --bs=4k --rw=randrw --rwmixread=50 --direct=1 --iodepth=32

Note: If a rebuild is in progress, expect slower results. On parity arrays, small random writes are the slowest path, while reads should be strong.

That's it, you are done with optimizing for fault tolerance with RAID on a Linux VPS. Use RAID 1 if you only have 2 disks, use RAID 6 for large arrays, and use RAID 5 for read-heavy workloads where storage efficiency matters. Always remember to keep off-site backups.

Conclusion

RAID is a smart way to protect your data from disk failures and keep your VPS running smoothly. Whether you choose RAID 1 for simple safety, RAID 5 for a balance of space and speed, or RAID 6 for maximum protection, each option helps improve reliability. We hope this guide on Optimizing for Fault Tolerance with RAID on a Linux VPS is useful.

With PerLod VPS Hosting Service, you will get reliable Linux VPS hosting combined with the flexibility to set up RAID for extra fault tolerance.

Subscribe to X and Facebook channels to get the latest updates and articles on a Linux VPS.

For further reading:

Install K3s Lightweight Kubernetes on Ubuntu 24.04

Move from Shared Hosting to VPS without Downtime

RAID 1 is best if you only have 2 disks.

Yes, but it’s more complex. It is recommended to create a dedicated data mount point instead.

You will see warnings from mdadm or mdmonitor. That’s why enabling alerts is essential.