Hardware & Advanced Topics

How can we help?

Guides and technical documentation for your Server4You dedicated server or VPS.

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.

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).

1

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:

List disks
fdisk -l

Replicate the layout (GPT/Modern)

This command copies the structure from sdb to sda and gives the new disk a unique ID:

Copy layout
sgdisk -R=/dev/sda /dev/sdb sgdisk -G /dev/sda
2

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):

Add to RAID
mdadm /dev/md0 --add /dev/sda1 mdadm /dev/md1 --add /dev/sda3

Watch the progress

The system is now busy copying. Do not turn off the server until this is finished:

Check status
watch cat /proc/mdstat
3

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.

Install Bootloader
mount /dev/md1 /mnt mount /dev/md0 /mnt/boot mount --bind /dev /mnt/dev mount --bind /proc /mnt/proc mount --bind /sys /mnt/sys chroot /mnt grub-install /dev/sda update-grub exit

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.