> ## Documentation Index
> Fetch the complete documentation index at: https://help.freakhosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Check RAID Status and Replace a Disk with mdadm

> Check mdadm RAID status with cat /proc/mdstat and mdadm --detail, then replace a failed disk: --fail, --remove, copy the partition table, --add and rebuild.

To check software RAID on Linux, run `cat /proc/mdstat`: `[UU]` means every disk is working, `[U_]` means the array is **degraded** and a disk has failed. `sudo mdadm --detail /dev/md0` shows which one. To replace it, mark it failed and remove it (`mdadm --manage /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1`), have the disk swapped, copy the partition table to the new disk, then `--add` it and watch the rebuild.

| Difficulty | Time | Works on | Needs |
| - | - | - | - |
| Advanced | 15 minutes plus rebuild time (hours on large disks) | Dedicated servers running Ubuntu, Debian, AlmaLinux, Rocky Linux with mdadm | root or sudo, a current backup |

## Before you start

* This page is mainly for **dedicated servers** with two or more physical disks in Linux software RAID. On a **VPS** you see virtual disks, and `/proc/mdstat` normally lists no arrays. Protect VPS data with [panel backups](https://help.freakhosting.com/portals/vps-panel/how-to-schedule-and-restore-backups.md) and your own [off-server backups](https://help.freakhosting.com/portals/other/how-to-back-up-a-linux-server.md) instead.
* **RAID is not a backup.** It keeps the server running when a disk dies, but deletions, corruption and ransomware hit every disk at once. Back up before you touch a degraded array: a second disk can fail during a rebuild.
* Commands use `sudo`; root users can leave it out. Install mdadm if needed: `sudo apt install mdadm` or `sudo dnf install mdadm`.
* If your server uses a **hardware RAID controller**, mdadm does not manage it. [Open a ticket](https://freakhosting.com/clientarea/submitticket.php) if you are unsure which you have.

## How to check RAID status

```bash theme={null}
cat /proc/mdstat
```

A healthy two-disk RAID 1:

```text theme={null}
Personalities : [raid1]
md1 : active raid1 sdb2[1] sda2[0]
      1046528 blocks super 1.2 [2/2] [UU]

md2 : active raid1 sdb3[1] sda3[0]
      1919309824 blocks super 1.2 [2/2] [UU]
      bitmap: 3/15 pages [12KB], 65536KB chunk
```

| You see | Meaning |
| - | - |
| `[2/2] [UU]` | 2 disks expected, 2 working. Healthy |
| `[2/1] [U_]` | One disk missing or failed. **Degraded**: no redundancy left |
| `sdb3[1](F)` | That member has failed |
| `recovery = 12.6% … finish=95.1min` | A rebuild is running |
| `check = 40.0%` | A consistency check is running (normal, often monthly) |

For details on one array:

```bash theme={null}
sudo mdadm --detail /dev/md2
```

Look at `State :` (`clean` is good; `degraded` means a disk is missing), `Failed Devices :`, and the table at the bottom, which shows each member as `active sync`, `faulty` or `removed`.

## How to replace a failed disk in mdadm RAID 1

> [!WARNING]
>
> Mistakes here can destroy the **only good copy** of your data. Take a backup first, check every device name twice, and never run commands against the healthy disk. Only ever fail and remove the member that is already faulty, never one that shows `active sync`. When in doubt, stop and [open a ticket](https://freakhosting.com/clientarea/submitticket.php).

The examples assume `sda` is healthy and `sdb` has failed, with partitions `sdb2` in `md1` and `sdb3` in `md2`. Use your own names from `/proc/mdstat`.

**1. Identify the failed disk by serial number**

```bash theme={null}
lsblk -o NAME,SIZE,SERIAL,MODEL
ls -l /dev/disk/by-id/ | grep -v part
```

Write down the serial number of the failed disk **and** of the healthy disk. The data centre uses the serial to pull the right drive.

**2. Mark its partitions as failed and remove them**

Do this for every array the disk belongs to:

```bash theme={null}
sudo mdadm --manage /dev/md1 --fail /dev/sdb2
sudo mdadm --manage /dev/md1 --remove /dev/sdb2
sudo mdadm --manage /dev/md2 --fail /dev/sdb3
sudo mdadm --manage /dev/md2 --remove /dev/sdb3
```

If a partition is already gone, `mdadm` says so; continue with the next one.

**3. Ask for the disk to be replaced**

[Open a ticket](https://freakhosting.com/clientarea/submitticket.php) with the failed disk's serial number and the healthy disk's serial number, and ask when the swap will happen.

**4. Find the new disk**

After the swap, run `lsblk`. The new disk has no partitions. It may get a different name, so confirm by serial number.

**5. Copy the partition table from the healthy disk**

> [tab] GPT disks
>
> ```bash theme={null}
> sudo sgdisk -R /dev/sdb /dev/sda
> sudo sgdisk -G /dev/sdb
> ```
>
> `-R /dev/sdb /dev/sda` copies **from `sda` to `sdb`**. `-G` gives the copy new unique IDs. `sgdisk` is in the `gdisk` package.

> [tab] MBR (msdos) disks
>
> ```bash theme={null}
> sudo sfdisk -d /dev/sda | sudo sfdisk /dev/sdb
> ```

Check which type you have with `sudo parted /dev/sda print` (`Partition Table: gpt` or `msdos`).

> [!WARNING]
>
> Getting the order wrong overwrites the healthy disk's partition table. The **target** (new disk) comes right after `-R`; the **source** (healthy disk) comes last.

**6. Add the new partitions to the arrays**

```bash theme={null}
sudo mdadm --manage /dev/md1 --add /dev/sdb2
sudo mdadm --manage /dev/md2 --add /dev/sdb3
```

**7. Watch the rebuild**

```bash theme={null}
watch cat /proc/mdstat
```

Wait until every array shows `[UU]` again. Press `Ctrl+C` to leave `watch`. The server stays usable, but disk-heavy work is slower until the rebuild finishes.

**8. Install the boot loader on the new disk**

So the server can still boot if the other disk fails later. On BIOS (legacy) boot:

```bash theme={null}
sudo grub-install /dev/sdb     # Ubuntu / Debian
sudo grub2-install /dev/sdb    # AlmaLinux / Rocky
```

On UEFI servers the EFI system partition is set up differently per installation. [Open a ticket](https://freakhosting.com/clientarea/submitticket.php) if you are not sure how yours boots.

## How to get email alerts when a RAID disk fails

mdadm's monitor sends an email when an array degrades. It needs a working mail setup on the server (a mail transfer agent such as Postfix).

1. Set the address in the config file, `/etc/mdadm/mdadm.conf` on Ubuntu / Debian or `/etc/mdadm.conf` on AlmaLinux / Rocky:
   ```ini theme={null}
   MAILADDR you@example.com
   ```
2. Restart the monitor: `sudo systemctl restart mdmonitor`.
3. Send a test alert for each array:
   ```bash theme={null}
   sudo mdadm --monitor --scan --oneshot --test
   ```

You can also check `/proc/mdstat` from your own monitoring. See [get email alerts when your server goes down](https://help.freakhosting.com/portals/other/how-to-get-email-alerts-when-your-server-goes-down.md).

## How to run a RAID consistency check

A check reads every block and compares the disks:

```bash theme={null}
echo check | sudo tee /sys/block/md2/md/sync_action
cat /sys/block/md2/md/mismatch_cnt
```

On Ubuntu 24.04, the mdadm package already includes `mdcheck_start.timer`, which starts a check on the first Sunday of each month. Seeing `check = …%` in `/proc/mdstat` at that time is normal.

## Frequently asked questions

### Can I keep using the server while the array is degraded?

Yes, but you have no redundancy: if the remaining disk fails, the data is gone. Back up and replace the disk as soon as you can.

### How long does a RAID rebuild take?

It depends on disk size and speed. `/proc/mdstat` shows an estimate as `finish=`. Large hard disks can take many hours.

### How do I check if a disk is about to fail?

Use SMART data: see [check disk health with smartctl](https://help.freakhosting.com/portals/other/how-to-check-disk-health-with-smartctl.md). Reallocated or pending sectors are early warnings.

### Does software RAID exist on my VPS?

Normally you only see virtual disks inside a VPS, and `cat /proc/mdstat` shows no arrays. Protect VPS data with backups.

## Related guides

> [card] [VPS and dedicated server guides](https://help.freakhosting.com/portals/other/vps-and-dedicated-server-guides.md)
>
> Every guide in this section.

> [card] [Check disk health with smartctl](https://help.freakhosting.com/portals/other/how-to-check-disk-health-with-smartctl.md)
>
> Spot failing disks early.

> [card] [Back up a Linux server](https://help.freakhosting.com/portals/other/how-to-back-up-a-linux-server.md)
>
> RAID is not a backup.

> [card] [Use LVM on Linux](https://help.freakhosting.com/portals/other/how-to-use-lvm-on-linux.md)
>
> Flexible volumes on top of RAID.

> [card] [VPS vs dedicated server](https://help.freakhosting.com/portals/other/vps-vs-dedicated-server-differences.md)
>
> What changes with physical disks.

***

> [!NOTE]
>
> **Checked against the official [Red Hat Enterprise Linux guide to replacing a failed disk in RAID](https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/10/html/managing_storage_devices/replacing-a-failed-disk-in-raid) and the [Linux kernel md documentation](https://docs.kernel.org/admin-guide/md.html)** on 4 November 2026; the `sgdisk -R`/`-G` and `sfdisk` partition-table copy was tested on Ubuntu 24.04 LTS using loop devices, and the mdadm options were checked against mdadm 4.3's built-in help. Array commands could not be run in our test environment. Commands can differ on other distributions or releases.

> [!NOTE]
>
> ### Need Extra Help?
>
> If you encounter any issues, our support team is ready to assist:
>
> * **Live Chat:** Quick assistance via our website.
> * **Support Ticket:** [Open a Ticket](https://freakhosting.com/clientarea/submitticket.php)
> * **Discord:** [Join our Community](https://discord.gg/freakhosting)
> * **Email:** [support@freakhosting.com](mailto:support@freakhosting.com)

> [!TIP]
>
> ### Save on Your Hosting
>
> Ready to upgrade your hosting? Use code **KB20** at checkout for **20% off** your first order!

***

**Last Updated:** November 2026


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.