2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-06-09 09:33:09 +00:00

Handle hostname-prefixed md device names and clear stale superblocks

Newer mdadm versions may load arrays under names like
`/dev/md/<hostname>:raid` after reboot instead of `/dev/md/raid`. Detect both
naming schemes when waiting for the array device and use the resolved
path consistently when determining the underlying md device name.

Also clear existing md superblocks before wiping signatures to avoid
stale RAID metadata interfering with array creation or assembly.
This commit is contained in:
Markus Hilger
2026-05-22 02:00:41 +02:00
parent 94eee92d36
commit 7d7f001826
+9 -2
View File
@@ -7,6 +7,7 @@ NUMDEVS=$(for dev in $DEVICES; do
echo wipefs -a -f $dev
done|wc -l)
for dev in $DEVICES; do
mdadm --zero-superblock $dev
wipefs -a -f $dev
done
# must use older metadata format to leave disks looking normal for uefi
@@ -15,9 +16,15 @@ mdadm -C /dev/md/raid $DEVICES -n $NUMDEVS -e 1.0 -l $RAIDLEVEL -b internal
mdadm -S -s
mdadm --assemble --scan
)
while [ ! -e /dev/md/raid ]; do
while :; do
# newer mdraid verions might have <hostname>:<raidname>
TARGET_RAID=$(ls /dev/md/raid /dev/md/*:raid 2>/dev/null | head -n 1)
[ -n "$TARGET_RAID" ] && break
echo 'Waiting on array to be linked...'
sleep 0.5
done
readlink /dev/md/raid|sed -e 's/.*\///' > /tmp/installdisk
# Extract the underlying block device name (e.g., md127) using the captured path
readlink "$TARGET_RAID" | sed -e 's/.*\///' > /tmp/installdisk