RAID1 Configuration On CentOS 7

Linuxtopic
0
         RAID1 Configuration On CentOS 7

RAID1 is also known as Disk Mirroring , It is the technique of writing the same data to more than one disk drive.

Requirement : minimum 2 Hdd

Step : 1

Install Required Package

CentOS/Rhel   

yum install mdadm

Ubuntu        

apt-get install mdadm


Step 2:


Examine Disk Drive

fdisk -l


mdadm /dev/sd[b-c]





Step 3:

Drive Partition

fdisk /dev/sdb


Follow the below instructions

Press ‘n‘ for creating new partition.


Then choose ‘P‘ for Primary partition.


Next select the partition number as 1.


Give the default full size by just pressing two times Enter key.


Next press ‘p‘ to print the defined partition.


Press ‘L‘ to list all available types.

Type ‘t‘ to choose the partitions.

Choose ‘fd‘ for Linux raid auto and press Enter to apply.

Then again use ‘p‘ to print the changes what we have made.

Use ‘w‘ to write the changes.


After ‘/dev/sdb‘ partition has been created Successfully , Follow the same instructions to create new partition on /dev/sdc drive.

fdisk /dev/sdc



Step 4:

Verify the changes on both sdb & sdc drive

mdadm /dev/sd[b-c]


mdadm /dev/sd[b-c]1


Step 5:

Create Raid1

mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sd[b-c]1


Check Process and %

cat /proc/mdstat



Step 6:

Check the raid devices type

mdadm -E /dev/sd[b-c]1

Raid Level : raid1
Raid Devices : 2


Check Device Array

mdadm --detail /dev/md0


Step 7:

Creating File System on RAID Device

mkfs.ext4 /dev/md0



Step 9:

Save Raid Configuration :

Ubuntu:

mdadm --detail --scan >> /etc/mdadm/mdadm.conf

CentOS

mdadm --detail --scan >> /etc/mdadm.conf

Step 9:

Mount Raid Partition : Temp
mkdir /raid1

mount /dev/md0 /raid1

df -h #verify

Mount Raid Partition : Permanent

vi /etc/fstab

/dev/md0    /raid1         ext4         defaults 0 0


mount -a


Raid devices don't really exist on their own; they have to be assembled each time you want to use them

Assemble Raid :
mdadm --assemble /dev/md0 /dev/sda1 /dev/sdb1
   

Auto Mount Raid1 using systemd service in CentOS 7 / Ubuntu 16... Click Here

1> Create raid1.mount  file on  /lib/systemd/system

vi  /lib/systemd/system/raid1.mount

[Unit]
Description=Mount Raid1 File System
Requires=raid1.service

[Mount]
What=/dev/md0                             
Where=/raid1
Type=ext4
Options=defaults


[Install]
WantedBy=multi-user.target

2> Create raid1.service  file on  /lib/systemd/system

vi  /lib/systemd/system/raid1.service

[Unit]
Description=Assemble Raid1 File System

[Service]
ExecStart=/usr/local/bin/raid1

[Install]
WantedBy=multi-user.target
3> Crate command to assemble raid device

vi  /usr/local/bin/raid1

#!/bin/bash
# Command to Start Raid1  assemble on Boot #
/usr/sbin/mdadm --assemble /dev/md0 /dev/sdb1  /dev/sdc1
               


Stopping a running RAID device

    > mdadm --stop /dev/md0

Starting RAID device

    > mdadm --run /dev/md0




Tags:

Post a Comment

0Comments

Post a Comment (0)

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Check Now
Ok, Go it!