Re: add new disk with dd
From: Reindl Harald <hidden>
Date: 2021-04-29 15:51:17
Am 29.04.21 um 17:32 schrieb d tbsky:
Mateusz [off-list ref]quoted
Should in most cases [1], but IMHO it's good idea to mdadm --zero-superblock /dev/YOU_ARE_SURE_IS_ONE_YOU_WANT_TO_ADD before adding disk already used somewhere else."madam --zero-superblock" is great. I will add it to my procedure. thanks a lot for the hint!quoted
BTW, IMHO it's better to clone partition layout, and than install bootloaders instead of dding disk.yes. but sometimes dd is easy, especially for mbr layout. anyway I think your suggestion "--zero-superblock" make things safe with new and old disks
doing both for years on dozens of machines which have 3 RAID partitions
(boot, os, data) on 4 disks with a script
GOOD_DISK is a full working one and BAD_DISK the blank drive
[root@srv-rhsoft:~]$ cat /scripts/raid-recovery.sh
#!/usr/bin/bash
GOOD_DISK="/dev/sda"
BAD_DISK="/dev/sdd"
# --------------------------------------------------------------------------
echo "NOT NOW"
exit
# --------------------------------------------------------------------------
# clone MBR
dd if=$GOOD_DISK of=$BAD_DISK bs=512 count=1
# force OS to read partition tables
partprobe $BAD_DISK
# start RAID recovery
mdadm /dev/md0 --add ${BAD_DISK}1
mdadm /dev/md1 --add ${BAD_DISK}2
mdadm /dev/md2 --add ${BAD_DISK}3
# print RAID status on screen
sleep 5
cat /proc/mdstat
# install bootloader on replacement disk
grub2-install "$BAD_DISK"