Rebuilding a Software RAID 1 Array
This guide shows how to integrate a replacement drive into a Linux software RAID 1 (mdadm) after a drive failure: copy the partition table, resync the array, and reinstall the GRUB bootloader. It is intended for dedicated servers on which a defective drive has just been replaced.
Warning: This process requires absolute focus. You must correctly distinguish between your healthy drive (source) and the new empty drive (target). Mixing them up will result in total data loss.
How it works
Think of your RAID as two identical books. If one is destroyed, you buy a new one with empty pages. To restore your RAID, you must first draw the same lines (Partitioning) on the empty pages and then copy the text (Syncing) from the original book. Finally, you ensure the new book can be "read" at startup (Bootloader).
Step 1: Preparing the empty drive
A RAID only works if the partitions on both disks are identical. We copy the "blueprint" from your healthy disk (e.g., sdb) to the new disk (e.g., sda). For disks with an MBR partition table, use sfdisk -d /dev/sdb | sfdisk /dev/sda instead of sgdisk.
Identify your drives
Check which drive has partitions and which is empty:
Replicate the layout (GPT/Modern)
This command copies the structure from sdb to sda and gives the new disk a unique ID:
Step 2: Copying the data
Now that the new disk has the right "slots" (partitions), we tell the system to start copying the actual data into them.
Join the partitions to the RAID
Add the new partitions (sda1, sda3, etc.) to your existing RAID arrays (md0, md1):
Watch the progress
The system is now busy copying. Do not turn off the server until this is finished:
Step 3: Making the drive bootable
A mirror copies your files, but not the hidden "start-up code" (Bootloader). Without this step, your server will not start if the other disk fails. On the running system, grub-install /dev/sda and update-grub are sufficient. The commands below are for rescue mode, where you first mount the system and switch into it with chroot. On AlmaLinux and Rocky Linux, use grub2-install and grub2-mkconfig -o /boot/grub2/grub.cfg instead.
Hardware defect confirmed?
In the event of a technical defect, we will replace your hard drive free of charge. To do so, please open a hardware ticket in your PowerPanel.