How to create a Software RAID with mdadm on Debian

Table of contents

  • Before using mdadm, my friends are Smartmontools and GParted
    • Smartmontools to verify Hard Drives integrity
    • Prepare your hard drives with GParted
      • Install and launch GParted
      • Use GParted
  • Now, use mdadm
    • Installation
    • Verification
    • Create the RAID
    • Create the file system
    • Mount the RAID System
  • Going further in Software RAID management

Before using mdadm, my friends are Smartmontools and GParted

Before to create your RAID, it is better to :

  • verify the integrity of your hard drives. For this, smartmontools can be very usefull.
  • prepare your hard drives by formatting them. GParted will do the job.

Smartmontools to verify Hard Drives integrity

I advise you to visite this post where I describe how to use this great tool : How to verify hard drives integrity with Smartmontools on Debian

Prepare your hard drives with GParted

Install and launch GParted

sudo apt-get install gparted
sudo gparted

Use GParted

The principal is to have the same disk, with the same size, preferably formatted. So choose hard drives the most similar as possible and prepare them identically with the same formatting.

If you need help using GParted : https://gparted.org/display-doc.php?name=help-manual

Now, use mdadm

Installation

sudo apt-get install mdadm

Verification

If we keep the same example as above with 3 hard drives, the appropriate command line is :

sudo mdadm -E /dev/sd[a-c]

Create the RAID

In the following example, my target is :

  • to have a cluster named /dev/md0
  • to choose a RAID 5 type –level=5
  • to use 3 hard drives –raid-devices=3
  • to use the 3 hard drives sda, sdb and sdc /dev/sd[a-c]
sudo mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sd[a-c]1

You have also the possibility to write the final part of this command line as follows :

sudo mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sda /dev/sdb /dev/sdc

The creation can take time… maybe several hours. So a command line can track the creation progress and show you exactly the percent of achievement :

cat /proc/mdstat

Create the file system

Typically, the file system chosen is ext4 . So for the example of the cluster named /dev/md0 :

sudo mkfs.ext4 /dev/md0 

Mount the RAID System

Finally, you now just need to mount your RAID system following this steps :

  1. Create the folder where to mount the RAID
  2. Mount the RAID
sudo mkdir /mnt/myraidsystem
sudo mount /dev/md0 /mnt/myraidsystem

That’s all! Your Software RAID System is now created!

Going further in Software RAID Management

The folloing post will explain several cases to manage your Software RAID system : How to manage a Software RAID with mdadm on Debian

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *