How to create RAID 0 (disk striping)

How To Create RAID 0 (Disk Striping)

RAID 0 (disk striping) is the process of dividing a body of data into blocks and spreading the data blocks across multiple storage devices, such as hard disks or solid-state drives (SSD), in a redundant array of independent disks (RAID) group.


About RAID-0 

RAID-0 is usually referred to as “striping.” This means that data in a RAID-0 region is evenly distributed and interleaved on all the child objects. For example, when writing 16 KB of data to a RAID-0 region with three child objects and a chunk-size of 4 KB, the data would be written as follows:

4 KB to object 0
4 KB to object 1
4 KB to object 2
4 KB to object 0

  • Requirements

The minimum number of disks is allowed to create RAID 0 is 2, but you can add more disk but the order should be twice as 2, 4, 6, 8. If you have a Physical RAID card with enough ports, you can add more disks.

To create RAID 0 follow the nest steps:

  • Update the system and install “mdadm” package:

    The mdadm is a small program, which will allow us to configure and manage RAID devices in Linux.

    Creating partitions for RAID

Now create 2 partitions for raid, with the help of following commands.

#fdisk /dev/sd

  1. Press ‘n‘ for creating a new partition.

  2. Then choose ‘P‘ for Primary partition.

  3. Next, select the partition number as 4.

  4. Give the default value by just pressing two times Enter key.

  5. Next press ‘P‘ to print the defined partition.

Please follow the same above instructions to create a partition on sd*(2) drive.

After creating partitions, verify both the drivers are correctly defined for RAID using the following commands.

#mdadm –examine /dev/sd[*-*]

#mdadm –examine /dev/sd[*-*]1


Creating RAID md devices 

Now since we have all the partitions with us, we will create RAID 0 array on those partitions, with the help of following commands.

# mdadm -Cv -l0 -c64 -n2 /dev/md0 /dev/sd{*,*}1

    -C, –create (Create a new array.)

    -v, –verbose (Be  more  verbose about what is happening.)

    -l, –level=  (Set RAID level.)

    -c, –chunk= (Specify chunk size of kilobytes.)


    -n, –raid-devices= (Specify  the number of active devices in the array.)

Now since our raid 0 array is created successfully. Verify the changes using below command

# cat /proc/mdstat


Create file-system and mount point

Raid 0 array is ready, we will create a filesystem on top of /dev/md0 so it can be used for storing data.

#mkfs.xfs /dev/md0

Once xfs filesystem has been created for Raid device, now create a mount point directory and mount the device /dev/md0 under it.


# mkdir /raid0
# mount /dev/md0 /raid0/
Next, verify that the device /dev/md0 is mounted under /raid0 directory.

#df -hTOnce

You’ve verified mount points, it’s time to create an fstab entry in /etc/fstab file.

# vim /etc/fstab

Add the following entry as described. May vary according to your mount location and filesystem you using.

/dev/md0                /raid0              xfs    defaults         0 0

Run mount ‘-a’ to check if there is any error in fstab entry.

# mount -a