From Stupid IT
Jump to navigationJump to search




mdadm Recovering/Rebuilding
watch cat /proc/mdstat

Time :: <5 minutes

When adding a new - or replacing an old - drive, sometimes you need to verify what the dev is inside of Linux.

# lsblk
Will give you a breakdown of how each block device is used (or, not).
In the example to the right, you can see that /dev/sdg is empty. Before we go about adding it, let's double-check our array

# mdadm --detail /dev/md127
Gives a detailed view of the specified array
In the example, we can see that the array is running on 9 drives, and in a degraded state.

# mdadm --add /dev/md127 /dev/sdg
Add to the specified array the specified drive

This will add /dev/sdg to the array /dev/md127. You should see a response that the drive was added:
mdadm: added /dev/sdg

After this point, the array should start rebuilding by itself; you can verify with another:
# mdadm --detail /dev/mds127
The State should include recovering, and you should see your listed device something akin to:
spare rebuilding /dev/sdg

If, for whatever reason it doesn't, you can manually grow the array.
# mdadm --grow --raid-devices=10 /dev/md127
As long as the array isn't in a recovery/resync state, this should work. However, this can take a long time to do (days+) - as such, it is advisable to do a backup incase of, say, a power failure:
# mdadm --grow --raid-devices=10 --backup-file=/root/md127_date_grow.bak /dev/md127

# watch cat /proc/mdstat Displays mdadm status on a refresh interval - helpful to keep a gaze on the recovery process of the array.

Cheat Sheet

# mdadm --detail /dev/md127
Displays the status & health of the specified array.

# mdadm --create /dev/md127 --level=10 /dev/sdb /dev/sdc /dev/sdd /dev/sde
Creates a RAID10 with 4 drives

# mdadm --add /dev/md127 /dev/sdf
Adds to the specified array, the specified device.

# mdadm /dev/md127 --fail /dev/sdd --remove /dev/sdd
Fails & removes specified device from array - to do only one or the other, omit the offending.


Growing & Windows iSCSI Initiator :: If your array is the home of an iSCSI target, and that target is connected to a Windows system, you don't need to resize anything on the Linux system. Just log onto the Windows server connected to the iSCSI target, open Disk Management, and resize the partition there (or, diskpart, if that's your jazz).