mdadm Quick Start Guide

Usage:

# mdadm [mode] <raiddevice> [options] <component-devices>

Assemble – Assemble previously created array into an active array

# mdadm -A -s

Scan and assembly all the RAID volume based on config file.

# mdadm -A /dev/md/imsm0 -e imsm /dev/ <member drives>

Assemble imsm0 container manually if without config file.

# mdadm -A /dev/md/md0 /dev/md/imsm0

Assemble md0 array

manually if without config file.

Create/Grow/Misc – Create new array with metadata/change active size or number of active devices

# mdadm -C /dev/md/imsm0 /dev/nvme[0-3]n1 -n 4 -e imsm

Create imsm0 container with 4 nvme0-3 drives.

# mdadm -C /dev/md/md0 /dev/md/imsm0 -n 4 -l 5

Create md0 as 4DR5 in

imsm0 container.

# mdadm -C /dev/md/md0 /dev/md/imsm0 - n 4 -l 5 --consistency- policy=ppl

Create md0 as 4DR5 in imsm0 container with RWH enabled.

# mdadm -C /dev/md/md0 /dev/md/imsm0 -n 4 -l 5 -z

$((100*1024*1024))

Create 4DR5 with 100GB size for each drive. 300GB size created with this example command.

# mkfs.ext4 /dev/md/md0

Create ext4 filesystem in

md0 RAID volume.

# mount /dev/md/md0 /mnt/<mountpoint>

Mount md0 RAID volume in the file system.

# mdadm -a /dev/md/imsm0 /dev/<nvmeXn1>

Add hot-spare drive to

imsm0 container.

# mdadm -Ebs > /etc/mdadm.conf

Export device metadata to

mdadm.conf file.

# mdadm -S /dev/md/md0

Stop and deactivate md0

array.

# mdadm -S /dev/md/imsm0

Stop and deactivate imsm0

container.

# mdadm -S -s

Stop and deactivate all.

# mdadm -f /dev/md/md0 /dev/nvme0n1

Fail nvme0n1 drive in md0

array.

# mdadm -r /dev/md/imsm0 /dev/nvme0n1

Detached nvme0n1 drive in imsm0 container.

# mdadm --zero-superblock /dev/nvme0n1

Clear and zero the superblock in nvme0n1 drive.

# mdadm -G /dev/md/md0 -l 0

Grow existing 2DR1 to 1DR0.

# mdadm -G /dev/md/imsm0 -n 2

Grow 2DR0 to container.

# mdadm -a /dev/md/imsm0 /dev/nvme2n1

Add one more drive into container.

# mdadm -G /dev/md/md0 -l 5 --layout=left-asymmetric

Grow 2DR0 to 3DR5.

# mdadm -G /dev/md/md0 --size=128G

Grow component size md0

to the 128GB.

# mdadm -G /dev/md/md0 --consistency-policy=resync

Switch RWH closure policy to resync on the running md0.

# mdadm -G /dev/md/md0 --consistency-policy=ppl

Enable RWH closure mechanism on the running

md0.

Volume, Member, Hardware Information

# mdadm --detail-platform

Print detail of platform’s RAID capabilities.

# mdadm -D /dev/md/md0

Print detail of md0 device.

# mdadm -E /dev/nvme0n1

Print contents of metadata store in nvme0n1.

# cat /proc/mdstat

List all active md devices with information.

Follow/Monitor/Misc – Monitor one or more devices on state changes

# systemctl status mdmonitor.service

Check mdmonitor service.

# systemctl start mdmonitor.service

Start mdmonitor service.

# systemctl stop mdmonitor.service

Stop mdmonitor service.

# systemctl enable mdmonitor.service

Enable mdmonitor service for next boot auto start.

Last updated