09/01/2021 - mdadm,linux,kb,storage
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
# 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
Displays mdadm status on a refresh interval – helpful to keep a gaze on the recovery process of the array.
# watch cat /proc/mdstat
There's nothing here, yet. Feel free to submit your own comment below.