How to Start and Stop mdadm (soft RAIDs) in RHEL ?

In this article I am going to show the creation of RAID 5 soft RAID and how to start and stop the RAIDs.

Step 1 : I have created RAID 5 with name /dev/md0 using three disks.

[root@localhost ~]# mdadm –create –verbose /dev/md0 –level=5 –raid-devices=3 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: chunk size defaults to 512K
mdadm: size set to 204288K
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

Step 2 : We can check the status of created RAID using below methods, they will provide different level of information.

Method 1 :

[root@localhost ~]# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sde1[3] sdd1[1] sdc1[0]
408576 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3/3] [UUU]

unused devices: <none>

Method 2 :
[root@localhost ~]# mdadm –query /dev/md0
/dev/md0: 399.00MiB raid5 3 devices, 0 spares. Use mdadm –detail for more detail.

Method 3 :

[root@localhost ~]# mdadm –detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Sat Nov 15 07:58:01 2014
Raid Level : raid5
Array Size : 408576 (399.07 MiB 418.38 MB)
Used Dev Size : 204288 (199.53 MiB 209.19 MB)
Raid Devices : 3
Total Devices : 3
Persistence : Superblock is persistent

Update Time : Sat Nov 15 07:58:03 2014
State : clean
Active Devices : 3
Working Devices : 3
Failed Devices : 0
Spare Devices : 0

Layout : left-symmetric
Chunk Size : 512K

Name : localhost.localdomain:0  (local to host localhost.localdomain)
UUID : 97d0a58d:d6596b81:7cf045b2:3cc309f0
Events : 18

Number   Major   Minor   RaidDevice State
0       8       33        0      active sync   /dev/sdc1
1       8       49        1      active sync   /dev/sdd1
3       8       65        2      active sync   /dev/sde1

Step 3 : After that I created one file system on top of RAID5 device /dev/md0.

[root@localhost ~]# mkfs.xfs /dev/md0
log stripe unit (524288 bytes) is too large (maximum is 256KiB)
log stripe unit adjusted to 32KiB
meta-data=/dev/md0               isize=256    agcount=8, agsize=12672 blks
=                       sectsz=512   attr=2, projid32bit=1
=                       crc=0
data     =                       bsize=4096   blocks=101376, imaxpct=25
=                       sunit=128    swidth=256 blks
naming   =version 2              bsize=4096   ascii-ci=0
log      =internal log           bsize=4096   blocks=3120, version=2
=                       sectsz=512   sunit=8 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Step 4 : To make the changes persistent across reboot need to save them in configuration file.

[root@localhost ~]# mdadm –detail –scan
ARRAY /dev/md0 metadata=1.2 name=localhost.localdomain:0 UUID=97d0a58d:d6596b81:7cf045b2:3cc309f0
[root@localhost ~]# mdadm –detail –scan > /etc/mdadm.conf

Step 5 : If we want to stop the soft RAID its very simple process but to start it is not simple.

[root@localhost ~]# mdadm –stop /dev/md0
mdadm: stopped /dev/md0
[root@localhost ~]# mdadm –detail /dev/md0
mdadm: cannot open /dev/md0: No such file or directory

Method 1 : To start if we simple run the below command it will not be able to start it.

[root@localhost ~]# mdadm –run /dev/md0
mdadm: error opening /dev/md0: No such file or directory

We have to start using below method but it is little bit long command.

[root@localhost ~]# mdadm –assemble /dev/md0 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm: /dev/md0 has been started with 3 drives.

Method 2 : If you have noticed the UUID of md device or you can take it from configuration file. (/etc/mdadm.conf) we can use it for creation.

[root@localhost ~]# mdadm –assemble scan –uuid=97d0a58d:d6596b81:7cf045b2:3cc309f0
mdadm: /dev/md/scan has been started with 3 drives.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s