Today we’ll look at creating software RAID devices with mdadm. For the example I will use /dev/sdb1 and /dev/sdb2
To create an array:
1234567891011121314
mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdb2
mdadm: /dev/sdb1 appears to be part of a raid array:
level=raid0 devices=0 ctime=Thu Jan 1 09:00:00 1970
mdadm: partition table exists on /dev/sdb1 but will be lost or
meaningless after creating array
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
mdadm: size set to 102272K
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
To view more information about the array:
123456
cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdb2[1] sdb1[0]
102272 blocks super 1.2 [2/2] [UU]
unused devices: <none>
For more detailed information:
12345678910111213141516171819202122232425
mdadm --detail /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Tue Feb 20 00:17:49 2018
Raid Level : raid1
Array Size : 102272 (99.88 MiB 104.73 MB)
Used Dev Size : 102272 (99.88 MiB 104.73 MB)
Raid Devices : 2
Total Devices : 2
Persistence : Superblock is persistent
Update Time : Tue Feb 20 00:17:53 2018
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0
Name : rhel7:0 (local to host rhel7)
UUID : a92e04f3:1652f291:8c68266d:6c760648
Events : 17
Number Major Minor RaidDevice State
0 8 17 0 active sync /dev/sdb1
1 8 18 1 active sync /dev/sdb2
Now format the RAID device:
1
mkfs.ext4 /dev/md0
You need to create the config file /etc/mdadm.conf and add to it the output of the below command: