Replacing a failed drive in an md raid1/raid10: Difference between revisions

From Notes to self
Jump to navigation Jump to search
No edit summary
No edit summary
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
*Check if the kernel already removed the faild drive from the arrays: <code># mdadm --detail /dev/md0</code>
*Check <code># mdadm --detail /dev/md0</code>
**If not, remove it by hand: <code># mdadm /dev/md0 --remove /dev/sda1</code>
**If in an array a partition of the failed drive is not marked as faulty, run <code># mdadm --manage /dev/md1 --fail /dev/sda2</code>
**If in an array a partition of the failed drive is not marked as faulty, before removing run <code># mdadm --manage /dev/md1 --fail /dev/sda2</code>
**If the kernel doesn't already removed the faild drive from the arrays, remove it by hand: <code># mdadm /dev/md0 --remove /dev/sda1</code>
*Insert a new physical disk
*Insert a new physical disk
*Copy the partition table to the new drive from its mirror:
*Copy the partition table to the new drive from its mirror:
**For gpt partition table:
**For gpt partition table:
***<code># sgdisk -R /dev/sda /dev/sdb</code> (from <code>sdb</code> to <code>sda</code>)
***<code># sgdisk -R /dev/sda /dev/sdb</code> (from <code>sdb</code> to <code>sda</code>)
***<code># sgdisk -G /dev/sdb</code> (to make the new disk's GUID different the mirror's one)
***<code># sgdisk -G /dev/sda</code> (to make the new disk's GUID different the mirror's one)
** For mbr partition table: <code># sfdisk --dump /dev/sdb | sfdisk /dev/sda</code>
** For mbr partition table: <code># sfdisk --dump /dev/sdb | sfdisk /dev/sda</code>
*Add the new drive into the arrays: <code># mdadm /dev/md0 --add /dev/sda1</code>
*Add the new drive into the arrays: <code># mdadm /dev/md0 --add /dev/sda1</code>
** In case of error
<pre>mdadm: Cannot open /dev/sda1: Device or resource busy</pre>
check if the md subsystem created <code>/dev/md127</code> from <code>/dev/sda1</code>. In this case run <code>mdadm --stop /dev/md127</code> and then re-run <code>mdadm /dev/md0 --add /dev/sda1</code>
* Update <code>/etc/smartd.conf</code>
*Observe the mirroring process with <code>$ watch cat /proc/mdstat</code>
*Observe the mirroring process with <code>$ watch cat /proc/mdstat</code>
Ref: http://wiki.hetzner.de/index.php/Festplattenaustausch_im_Software-RAID/en


[[Category: Linux]]
[[Category: Linux]]
[[Category: Hardware]]
[[Category: Hardware]]

Latest revision as of 21:05, 18 January 2023

  • Check # mdadm --detail /dev/md0
    • If in an array a partition of the failed drive is not marked as faulty, run # mdadm --manage /dev/md1 --fail /dev/sda2
    • If the kernel doesn't already removed the faild drive from the arrays, remove it by hand: # mdadm /dev/md0 --remove /dev/sda1
  • Insert a new physical disk
  • Copy the partition table to the new drive from its mirror:
    • For gpt partition table:
      • # sgdisk -R /dev/sda /dev/sdb (from sdb to sda)
      • # sgdisk -G /dev/sda (to make the new disk's GUID different the mirror's one)
    • For mbr partition table: # sfdisk --dump /dev/sdb | sfdisk /dev/sda
  • Add the new drive into the arrays: # mdadm /dev/md0 --add /dev/sda1
    • In case of error
mdadm: Cannot open /dev/sda1: Device or resource busy

check if the md subsystem created /dev/md127 from /dev/sda1. In this case run mdadm --stop /dev/md127 and then re-run mdadm /dev/md0 --add /dev/sda1

  • Update /etc/smartd.conf
  • Observe the mirroring process with $ watch cat /proc/mdstat