How to Create Software RAID on a Dedicated Server
This guide explains how to create a software RAID array manually on a Dedicated Server using mdadm.
In most cases, RAID should be configured during the operating system reinstall from the Client Area. The reinstall form allows you to choose the RAID layout before the system is installed.
If you want to reinstall your server and use a standard RAID layout, we recommend configuring RAID directly from the Client Area during OS reinstall.
Manual RAID configuration is usually needed only in special cases, for example:
- you want to change the disk layout after the OS has already been installed,
- you want to create RAID only for a data partition such as /home,
- your server has different disk types, for example SSD + HDD, NVMe + SSD or multiple separate disk groups,
- you want to create a custom RAID layout not covered by the automatic reinstall options.
This guide is for advanced users. Creating or formatting RAID arrays can permanently remove data from the selected disks or partitions. Make sure you have a full backup before continuing.
Important Notes Before You Start
You should not create a new RAID array from the system partition while the operating system is running from it.
In most cases, manual RAID should be created only for a data partition, for example /home.
The commands below will overwrite data on the selected partitions. Double-check disk names and partition names before running any command.
RAID0 provides no redundancy. If one disk in a RAID0 array fails, all data on the RAID0 array will be lost. Use RAID0 only if you understand the risk and have your own backups.
Install Required Packages
First, install the required tools.
On Debian or Ubuntu:
apt update apt install -y gdisk mdadm
On AlmaLinux, Rocky Linux or CentOS:
dnf install -y gdisk mdadm
On older CentOS systems:
yum install -y gdisk mdadm
Check Available Disks
List all disks and partitions:
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT
Example output:
NAME SIZE TYPE FSTYPE MOUNTPOINT sda 1.8T disk ├─sda1 512M part vfat /boot/efi ├─sda2 1G part ext4 /boot ├─sda3 50G part ext4 / └─sda4 1.7T part ext4 /home sdb 1.8T disk
In this example, /dev/sda4 is the existing /home partition and /dev/sdb is the second disk.
The disk and partition names on your server may be different. Do not copy the example commands blindly. Always replace disk names with the correct ones from your server.
Copy Partition Table to Another Disk
If you want both disks to have the same partition layout, you can copy the partition table from one disk to another using sgdisk.
Command format:
sgdisk -R=/dev/sdX /dev/sdY
In this command:
- /dev/sdX is the target disk where the partition table will be copied to.
- /dev/sdY is the source disk where the partition table will be copied from.
For example, to copy the partition table from /dev/sda to /dev/sdb, run:
sgdisk -R=/dev/sdb /dev/sda
After copying the partition table, randomize the disk GUID on the target disk:
sgdisk -G /dev/sdb
Then ask the system to reload the partition table:
partprobe /dev/sdb
Check the result:
lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT
Create a RAID Array
You can create different RAID levels with mdadm. The examples below use partitions, not whole disks.
Use the correct partition names for your server. For example, if you want to create RAID from the /home partitions, use the matching data partitions such as /dev/sda4 and /dev/sdb4.
Create RAID0
RAID0 combines disks for performance and capacity, but it does not provide redundancy.
mdadm --create /dev/md0 --verbose --level=0 --raid-devices=2 /dev/sda4 /dev/sdb4
Create RAID1
RAID1 mirrors data between disks. It provides redundancy because the same data is stored on both disks.
mdadm --create /dev/md0 --verbose --level=1 --raid-devices=2 /dev/sda4 /dev/sdb4
Create RAID5
RAID5 requires at least 3 disks. It provides redundancy and usable capacity higher than RAID1.
mdadm --create /dev/md0 --verbose --level=5 --raid-devices=3 /dev/sda4 /dev/sdb4 /dev/sdc4
Create RAID6
RAID6 requires at least 4 disks. It can survive two disk failures, but write performance may be lower than RAID5.
mdadm --create /dev/md0 --verbose --level=6 --raid-devices=4 /dev/sda4 /dev/sdb4 /dev/sdc4 /dev/sdd4
Create RAID10
RAID10 requires at least 4 disks. It combines mirroring and striping and is usually a good option for performance and redundancy.
mdadm --create /dev/md0 --verbose --level=10 --raid-devices=4 /dev/sda4 /dev/sdb4 /dev/sdc4 /dev/sdd4
Check RAID Status
After creating the RAID array, check its status:
cat /proc/mdstat
You can also check detailed information with:
mdadm --detail /dev/md0
Create Filesystem
After the RAID array is created, format it with a filesystem.
Example for ext4:
mkfs.ext4 -m1 /dev/md0
Example for XFS:
mkfs.xfs /dev/md0
Formatting the RAID array removes all data from it. Make sure you are formatting the correct device.
Mount the RAID Array
Create a mount point if needed:
mkdir -p /home
Check the UUID of the new RAID filesystem:
blkid /dev/md0
Example output:
/dev/md0: UUID="11111111-2222-3333-4444-555555555555" TYPE="ext4"
Edit /etc/fstab:
vi /etc/fstab
Add a line for the new RAID array.
Example for ext4 mounted as /home:
UUID=11111111-2222-3333-4444-555555555555 /home ext4 defaults,noatime 0 2
Example for XFS mounted as /home:
UUID=11111111-2222-3333-4444-555555555555 /home xfs defaults,noatime 0 2
Test the Mount
Before rebooting the server, test the fstab configuration:
mount -a
Then check if the RAID array is mounted:
df -h
You can also check with:
mount | grep /home
If mount -a returns an error, do not reboot the server until the issue is fixed. An incorrect /etc/fstab entry may prevent the system from booting correctly.
Save mdadm Configuration
After creating the RAID array, save the mdadm configuration.
On Debian or Ubuntu:
mdadm --detail --scan >> /etc/mdadm/mdadm.conf update-initramfs -u
On AlmaLinux, Rocky Linux or CentOS:
mdadm --detail --scan >> /etc/mdadm.conf dracut -H -f
Reboot and Verify
After everything is configured and tested, reboot the server:
reboot
After the server comes back online, check the RAID status:
cat /proc/mdstat
Check the mount point:
df -h
Check RAID details:
mdadm --detail /dev/md0
Verification
If /dev/md0 is active, mounted correctly and visible after reboot, the software RAID array has been configured successfully.
RAID is not a backup. RAID can protect against some disk failures depending on the RAID level, but it does not protect against accidental deletion, filesystem damage, software issues or multiple disk failures. Always keep your own backups.