Maker tech hub — AI · 3D print · Pi · ESP32 · plus the classic tech archive.

Free ESP32 kit · Books · Network Ninja · Archive

Classic tech archive. From the original averyjparker.com tech blog — historical context; pair with modern guides where noted. Full archive · Maker projects · Network Ninja

Classic tip · Linux

Linux software raid notes

Here are a few other notes on linux software raid. I created a directory called raidinfo to keep information in to make it easy to maintain the raid array. First... from the software raid howto, I've…

Written by

Avery J. Parker

IT veteran, maker educator, and author of Network Ninja, 3D Printing Mastery, and AI Workflow Mastery. Business IT: Diversified Tech Solutions.

Here are a few other notes on linux software raid. I created a directory called raidinfo to keep information in to make it easy to maintain the raid array. First... from the software raid howto, I've done the following....

sfdisk -d /dev/hda > /raidinfo/partitions.hda
sfdisk -d /dev/hde > /raidinfo/partitions.hde

So.... I've now got a good snapshot of the partitioning data. When I hooked up an external usb drive to add to the array, all I needed to do is this...

sfdisk /dev/sda < /raidinfo/partitions.hda


And.... I've got the drive partitioned.

Then I did a quick .... sudo mdadm --grow /dev/md0 -n 3 (previously 2)
and sudo mdadm --add /dev/md0 /dev/sda1

(for each partition and md0 device and things were happily syncing.) Actually, I've done a script to grow and add the partitions to the arrays and then to remove and "shrink" the array *(tip: - use the grow command with -n 2 to shrink.)

The master boot record is another issue (grub is used on this system.) I found a hint about grub's batch mode and did a quick try of the following....

#!/bin/bash

cat <<EOF | /sbin/grub --batch

device (hd0) /dev/sda

root (hd0,0)

setup (hd0)

quit

EOF

which seemed to do the trick, things are still syncing (/boot had already finished though.) I'll test once the sync is finished.

The software raid and grub how-to is excellent by the way...

The only other thing left seems to be to update the /etc/mdadm/mdadm.conf file...

cd /etc/mdadm

cp mdadm.conf mdadm.conf.`date +%y%m%d`

echo "DEVICE partitions" > mdadm.conf

mdadm --detail --scan >> mdadm.conf