Little Known Ways to configure RAID 1 in Linux

h3x0rh3x0r
2 min read

1. Using fdisk

List Disk Blocks Devices:

lsblk --scsi

List Disk Layout:

fdisk -l

There are 3 drives:

  1. /dev/sda

  2. /dev/sdb

  3. /dev/sdc

There are further 3 partitions of 1st Drive:

  1. /dev/sda1

  2. /dev/sda2

  3. /dev/sda3

Now we are going to use RAID 1 (mirrored drives) for /dev/sdb & /dev/sdc

RAID 1: Mirroring /dev/sdb & New partition creation

Start setup wizard

fdisk /dev/sdb

Now hit “n” for new partition.

And “p” for setting the newly created partition as a primary. And enter, enter for going with defaults

I have successfully created a new partition (/dev/sdb1) as a primary in the/dev/sdb drive.

Now hit “t” for changing the partition type. And “fd” for Linux RAID auto-detect.

And write all changes with “w”.

Same process for /dev/sdc

Now let's check the layout of newly configured partitions (/dev/sdb1 & /dev/sdc1) of (/dev/sdb & /dev/sdc) drives.

fdisk -l /dev/sdb /dev/sdc

Now we can notice /dev/sdb1 has the type of “Linux raid auto-detect”. And the same for /dev/sdc1.

We are all done with partitions. 🤩

Tool for mirrored RAID managing

sudo apt-get install mdadm

Mirroring RAID 1

Type the command and hit “y” to confirm.

mdadm --create /dev/md1 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1

Let's verify our work.

mdadm --detail /dev/md1

As we can see Re-sync Status: is 53% Complete. Which confirms that it’s working.

And our partitions are listed:

Making /dev/md1 usable

To make a newly created mirrored RAID 1 drive (/dev/md1) which is set of /dev/sdb1 and /dev/sdc1 usable we need to format it.

mkfs -t ext4 /dev/md1

Mounting drive /dev/md1

To mount mirrored drive we need to create a directory.

mkdir mirrored_drive/
mount /dev/md1 /mirrored_drive
1
Subscribe to my newsletter

Read articles from h3x0r directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

h3x0r
h3x0r

An aspiring cybersecurity student with a passion for keeping people and data safe. Constantly learning and adapting to the ever-changing landscape of cybersecurity to become a valuable asset to any organization.