• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Replacing a Failed Mirror Disk in a Software RAID Array (mdadm)

by admin

The post describes the steps to replace a mirror disk in a software RAID array. In this example, we have used /dev/sda1 as the known good partition, and /dev/sdb1 as the suspect or failing partition. Before proceeding, it is recommended to backup the original disk. Before removing raid disks, please make sure you run the following command to write all disk caches to the disk:

# sync

1. Mark the disk as failed

# mdadm --manage /dev/md0 --fail /dev/sdb1

To verify that the disk is failed, check /proc/mdstat:

# cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid5] [raid4] [raid6] [raid10]
md0 : active raid1 sda1[0] sdb1[2](F)
      976773168 blocks [2/1] [U_]

md1 : active raid1 sda2[0] sdb2[1]
      976773168 blocks [2/2] [UU]

Failed disk will be marked as “(F)”.

2. Remove the disk by mdadm

# mdadm --manage /dev/md0 --remove /dev/sdb1

3. Replace the disk

Replace the faulty disk with new one.

4. Copy the partition table to the new disk

Copy the partition table to the new disk (Caution: This sfdisk command will replace the entire partition table on the target disk with that of the source disk – use an alternative command if you need to preserve other partition information):

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

5. Create mirror

Create the mirror of the disk:

# mdadm --manage /dev/md0 --add /dev/sdb1

6. Verify

To test the setup, enter the below command:

# /sbin/mdadm --detail /dev/md0

The following command will show the current progress of the recovery of the mirror disk:

# cat /proc/mdstat
RedHat / CentOS : Managing software RAID with mdadm

Filed Under: Linux

Some more articles you might also be interested in …

  1. How to Compress and Decompress .bz2 files in Linux Using bzip2 Command
  2. Understanding the /etc/fstab file in Linux
  3. How to Set Environment Variables for a systemd Service in CentOS/RHEL 7
  4. How to Use iptables instead of firewalld on CentOS/RHEL 7 and 8
  5. How to enable md5 Hashing in Linux
  6. Setting up an NFS server with Turnkey Linux
  7. How to Verify if a Disk/Partition is in Use by Oracle ASM, was used by Oracle ASM or is never used by Oracle ASM
  8. How to exclude a file/directory from auditd rules
  9. 6 Useful journalctl Command Examples in CentOS / RHEL 7 (Cheat Sheet)
  10. runlevel Command Examples in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright