Disk managements

In our last article we have created a raid device md0 from three hard disk partition. In this article we would manage raid device. This guide is the second part of our tutorial on raid device if you have missed first part then read that first.

How to create raid partition in Linux example and implementations

Verify that all raid partition which we have created in our pervious article are working properly and in active state.

 #mdadm --detail /dev/md0 


mdadm Linux commands

You can also use cat /proc/mdstat command to see run time status of raid device

raid devices linux

raid devices are mainly used for data backup. Data will be safe even if any hard disk get fail from raid device. To test it first copy some data in /data directory which is the mount point of md0 raid devices.

 #cp * /data #ls /data 

Now assume that one hard disk form raid device gets fail. This can be done by mdadm command with --fail options. Verify data it should be safe

mdam --fail

you can verify fail device status via mdadm commands with -- detail switch also


mdadm --detail

run time process can be checked via cat /proc/mdstat commands

cat /proc/mdstat

At this point you should have understand what exactly raid device do?. raid device keep your data safe even if hard disk got crashed. its give you enough time to replace faulty hard disk without losing data.

Now remove faulty devices.[ Note:- you must have to set fail status before removing it form raid devices ]

mdadm --remove

now replace faulty hard disk with good one. To add new disk in raid devices use --add options with mdadm commands

mdadm --add

Congratulations you have successful created raid device and changed faulty hard disk. We suggest you to clean these partition before doing further practical.

How to remove raid devices

First un-mount the raid partitions from /data directory

umount /data

Now stop /md0 devices and remove it form mdadm commands

mdadm --remove

Now remove entry form /etc/fstab

vi /etc/fstab

file /etc/fstab

use fdisk command to remove raid partition form hard disk

fdisk command with d options