How did I replace a failed drive in my RAID 1 array with a new one (2025-06-12)?

1. Checking the health of the new drive (sdb)

smartctl -a /dev/sdb

2. Checking the health of the current drive (sda)

smartctl -a /dev/sdb

3. Deleting sda4

My previous (failed) sdb was smaller than sda.
Because of that, I used the extra space of sda as sda4 (outside of the RAID).
The new sdb is of the same size as sda, so I delete sda4 to use its space in the RAID.

3.1.

umount /sda4

3.2.

I deleted the lines:

4. sfdisk

sfdisk -d /dev/sda | sfdisk --force /dev/sdb

5. mdadm --add

5.1.

mdadm --add /dev/md0 /dev/sdb1
mdadm --add /dev/md1 /dev/sdb2
mdadm --add /dev/md2 /dev/sdb3

5.2.

Wait for the RAID synchronization:

watch cat /proc/mdstat

6. parted

6.1. sda

parted /dev/sda
rm 4
resizepart 3
100%
quit

6.2. sdb

parted /dev/sdb
rm 4
resizepart 3
100%
quit

7. partprobe

partprobe

8. mdadm --grow

8.1.

mdadm --grow /dev/md2 --size=max

8.2.

Wait for the RAID synchronization:

watch cat /proc/mdstat

9. resize2fs

resize2fs /dev/md2

10. grub-install

grub-install /dev/sdb

11. update-initramfs

update-initramfs -u

12. df -h /

df -h /

13. reboot

reboot

How did I replace a failed drive in my RAID 1 array with a new one (2025-02-11)?