If you’re looking for a balance of speed, reliability, and storage capacity for your Linux system, RAID 10 might be the perfect solution for you. RAID 10 combines the best of RAID 1 (mirroring) and RAID 0 (striping) to give you a fault-tolerant and high-performance storage solution. In this tutorial, we’ll guide you through creating a RAID 10 array in Linux using the mdadm tool.
Before we begin, you’ll need:
- A Linux system (we’ll be using Ubuntu in this tutorial, but the process is similar for other distributions)
- Four or more storage devices (hard drives or SSDs) of the same size
Step 1: Install mdadm
First, you’ll need to install the mdadm tool. On Ubuntu, you can do this by running:
sudo apt-get update sudo apt-get install mdadm
For other Linux distributions, consult their respective package managers (e.g.,
yum for Fedora or
zypper for openSUSE).
Step 2: Prepare the Storage Devices
To create a RAID 10 array, you’ll need to partition your storage devices. For this tutorial, we assume that you have four storage devices with device names /dev/sdb, /dev/sdc, /dev/sdd, and /dev/sde. Replace these names with the appropriate device names on your system.
fdisk utility to create partitions on each device:
sudo fdisk /dev/sdb
fdisk utility, follow these steps:
nto create a new partition.
pfor a primary partition.
1to create the first partition on the device.
Entertwice to accept the default start and end sector values.
tto change the partition type.
fdto set the partition type to Linux RAID autodetect.
wto write the changes and exit.
Repeat this process for the remaining devices: /dev/sdc, /dev/sdd, and /dev/sde.
Step 3: Create the RAID 10 Array
Now that the storage devices are prepared, it’s time to create the RAID 10 array using the
sudo mdadm --create --verbose /dev/md0 --level=10 --raid-devices=4 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1
This command creates a RAID 10 array named
/dev/md0 using the four partitions we created in the previous step. Adjust the number of
--raid-devices and device names as needed for your configuration.
Step 4: Save the RAID Configuration
After creating the RAID 10 array, you’ll want to save its configuration to ensure it’s recognized at system startup:
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf
This command appends the RAID configuration to the
Next, update your system’s initial RAM disk to include the RAID configuration:
sudo update-initramfs -u
Step 5: Create a Filesystem on the RAID Array
Now it’s time to create a filesystem on the RAID array. In this example, we’ll create an ext4 filesystem:
sudo mkfs.ext4 /dev/md0
You can choose a different filesystem type depending on your requirements (e.g., XFS or Btrfs).
Step 6: Mount the RAID Array
Create a mount point for the RAID array:
sudo mkdir /mnt/raid10
Mount the RAID array to the newly created mount point:
sudo mount /dev/md0 /mnt/raid10
To ensure the RAID array is mounted automatically at startup, add an entry to the
echo '/dev/md0 /mnt/raid10 ext4 defaults 0 0' | sudo tee -a /etc/fstab
ext4 with the filesystem type you chose in Step 5.
Congratulations! You’ve successfully created a RAID 10 array in Linux using the
mdadm tool. RAID 10 provides a combination of speed and redundancy, making it an excellent choice for many use cases. Be sure to explore other RAID configurations How to Create RAID 5 in Ubuntu and How to Create RAID 1 in Ubuntu