How To Raid In Linux With Mdadm?

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/raid-linux-mdadm/
PINTEREST
PINTEREST
INSTAGRAM

Hi, today I am gonna show you how to make raid ( redundant array of inexpensive disks ). Why wee need it? Think about that you have customer data stored in a server. Say one day disk is dead and then all of your data about customer are gone. This is a very bad new.  What if disk dies but the data remains the same.

This will be very good. You can think that will disk dies frequently. No but it is not impossible, especially in enterprise side or in personal use in home. RAID is a technology to backup disks with extra disks. Say we have 3 disks which are used separate projects. And we want to backup them with high availability in particular working hours. RAID can be done with separate hardware, firmware or software. Making raid with hardware is the best, fast and reliable way but it may be expensive or too much for project. Firmware raid is generally provided by motherboard manufacturers as a cheap option for hardware raid. Software raid is the cheapest and least reliable way to mail raid. But it can be suitable for home or unprofessional usage. I will not delve into details of raid levels. But you can find more about in wikipedia. In Linux software raid consist of kernel module and user space programs.

List Disk Drives

3 disks are used actively to store data but 4. disk the or spare disk  is used to backup for 3 disks. It doesn’t store all data of the 3 disks as it is impossible if 3 disks are near to full.

First list disks. We will make array with vdb,vdc,vdd and vde disks. I make this in my vm so your disk names maybe different like sda, sdb etc. All disk have 1 GB.

Install mdadm

Install mdadm in Ubuntu with this command

Load mdadm

mdadm is provides services via low level drivers. It has a kernel module named raid456 and can be loaded with the following command.

Create RAID

We should give count of disk with raid-devices level with level and the disk to be used in raid. Here meta data is optional it sets raid metada version After the command is executed we got a message that says our new disk which we named md0 is created . If you wab to create raid0 use level=stripe and raid1 level=mirror

Print mdadm Information

To see raid devices status.Shows total disk count and total usable size which is 3/4 of the total disk size. As you can see version is 1.2 where we set it while creating the array

LEARN MORE  Linux Mount Command Tutorial With Examples

Save/Backup mdadm Configuration

In order to save or backup mdadm with the --detail and --scan options like below.

List Disk Status and Array

We can list disk and array status with the -E option by providing the disk name.

Create File System For New Disk

We will use mkfs.ext4 command in order to create a file system to the /dev/md0 disk drive.

LEARN MORE  Windows Chkdsk Utility Tutorial with Examples To Fix File System Errors

Mount Disk

Mount the disk and create some files. Also show status of mounted disks.

Remove Disk From Array

Say disk vdd is corrupted. And we need to remove it.

Add Disk To Disk Array

We will use --add option disk vdf to the mdm drive md0 .

Restart or Initialize New Disk

To use raid after restart. Raid devices must reassembled every time to use.

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/raid-linux-mdadm/
PINTEREST
PINTEREST
INSTAGRAM