pondělí 31. července 2023

in-place replacement failing drive from md array

failing drive sdd1:

/dev/sdd
 Number  Start (sector)    End (sector)  Size       Code  Name
    1            2048     11721045134   5.5 TiB     FD00  Linux RAID

create temporary replacement virtual drive:
truncate -s $(((11721045134-2048)*512)) fake-sdd1-file
losetup -f fake-sdd1-file
replace the failing drive with the virtual spare space
mdadm --manage /dev/md0 --add /dev/loop0
mdadm /dev/md0 --replace /dev/sdd1 --with /dev/loop0
wait for data replication (see /proc/mdstat), then remove the failed drive
mdadm /dev/md0 --remove /dev/sdd1
eventually, destroy all md data from the drive and delete the partition
mdadm --zero-superblock /dev/sdd1
gdisk /dev/sdd
or use wipefs