{"id":528,"date":"2025-10-31T14:01:10","date_gmt":"2025-10-31T11:01:10","guid":{"rendered":"https:\/\/admin.danychrys.ro:4433\/?p=528"},"modified":"2025-10-31T15:03:48","modified_gmt":"2025-10-31T12:03:48","slug":"528-2","status":"publish","type":"post","link":"https:\/\/danychrys.go.ro\/web\/528-2\/","title":{"rendered":"Replacing a Faulty Disk in a RAID 1 Array (mdadm on Ubuntu 24.04)"},"content":{"rendered":"<h2 dir=\"auto\"><span style=\"color: #ffffff;\">1. Check RAID Status<\/span><\/h2>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">Use the following command to inspect the current state of the RAID:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo mdadm --detail \/dev\/md0<\/pre>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">State : clean, degraded<br \/>\nActive Devices : 1<br \/>\nFailed Devices : 1<\/span><\/p>\n<pre><span style=\"color: #ffffff;\"><img decoding=\"async\" class=\"alignnone size-full wp-image-536\" src=\"https:\/\/admin.danychrys.ro:4433\/wp-content\/uploads\/2025\/10\/faulty-disk-7950x-YNqBNX2Lqkcaw46N.avif\" alt=\"\" \/><\/span><\/pre>\n<h2 dir=\"auto\"><span style=\"color: #ffffff;\">2. Mark and Remove the Faulty Disk<\/span><\/h2>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">If the faulty disk is still present but failing, run:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo mdadm --fail \/dev\/md0 \/dev\/nvme1n1p1<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo mdadm --remove \/dev\/md0 \/dev\/nvme1n1p1<\/pre>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">If the disk has already been physically removed, you can skip this step.<\/span><\/p>\n<h2 dir=\"auto\"><span style=\"color: #ffffff;\">3. Replace the Faulty Disk<\/span><\/h2>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">Power down the server (if required), physically remove the faulty disk, and install a new one. Boot back into the system.<\/span><\/p>\n<h2 dir=\"auto\"><span style=\"color: #ffffff;\">4. Partition the New Disk<\/span><\/h2>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">RAID 1 mirrors data inside partitions, not the partition layout itself. The new disk must match the layout of the healthy one.<br \/>\nClone the partition table from the working disk:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo sgdisk -R=\/dev\/nvme1n1 \/dev\/nvme0n1<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo sgdisk -G \/dev\/nvme1n1<\/pre>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">-R=\/dev\/nvme1n1 \/dev\/nvme0n1: Copies the partition table.<br \/>\n-G: Regenerates the disk GUID to avoid conflicts.<br \/>\nCheck the layout:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">lsblk<\/pre>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">Make sure \/dev\/nvme1n1p1 exists and matches the partition size of \/dev\/nvme0n1p2.<\/span><\/p>\n<div class=\"layout-element layout-element--layout layout-element transition transition--scale\" data-v-4edbe80f=\"\" data-qa=\"layout-element-wrapper:zgxj7y\" data-animation-state=\"active\">\n<div id=\"zgXj7y\" class=\"text-box layout-element__component layout-element__component--GridTextBox\" data-v-4edbe80f=\"\" data-qa=\"gridtextbox:zgxj7y\">\n<h2 dir=\"auto\"><span style=\"color: #ffffff;\">5. Add the New Disk to the RAID Array<\/span><\/h2>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">Once partitioned, re-add the new disk:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo mdadm --add \/dev\/md0 \/dev\/nvme1n1p1<\/pre>\n<h2 dir=\"auto\"><span style=\"color: #ffffff;\">6. Monitor the Rebuild Process<\/span><\/h2>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">Use this command to check the rebuild progress:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">cat \/proc\/mdstat<\/pre>\n<p><span style=\"color: #ffffff;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-537 size-full\" src=\"https:\/\/admin.danychrys.ro:4433\/wp-content\/uploads\/2025\/10\/mdstat-recovery-output-A3Q2rqMK9OFVy91W.png\" alt=\"\" width=\"989\" height=\"290\" srcset=\"https:\/\/danychrys.go.ro\/web\/wp-content\/uploads\/2025\/10\/mdstat-recovery-output-A3Q2rqMK9OFVy91W.png 989w, https:\/\/danychrys.go.ro\/web\/wp-content\/uploads\/2025\/10\/mdstat-recovery-output-A3Q2rqMK9OFVy91W-300x88.png 300w, https:\/\/danychrys.go.ro\/web\/wp-content\/uploads\/2025\/10\/mdstat-recovery-output-A3Q2rqMK9OFVy91W-768x225.png 768w\" sizes=\"auto, (max-width: 989px) 100vw, 989px\" \/><\/span><\/p>\n<h2 dir=\"auto\"><span style=\"color: #ffffff;\">7. Confirm Rebuild Completion<\/span><\/h2>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">When the rebuild is done, confirm the RAID status:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo mdadm --detail \/dev\/md0<\/pre>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">Expected output:<br \/>\nState : clean<br \/>\nActive Devices : 2<br \/>\nFailed Devices : 0<\/span><\/p>\n<pre><span style=\"color: #ffffff;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-538 size-full\" src=\"https:\/\/admin.danychrys.ro:4433\/wp-content\/uploads\/2025\/10\/mdadm-details-output-Aq2WNp3ZkOINGrGZ.png\" alt=\"\" width=\"556\" height=\"155\" srcset=\"https:\/\/danychrys.go.ro\/web\/wp-content\/uploads\/2025\/10\/mdadm-details-output-Aq2WNp3ZkOINGrGZ.png 556w, https:\/\/danychrys.go.ro\/web\/wp-content\/uploads\/2025\/10\/mdadm-details-output-Aq2WNp3ZkOINGrGZ-300x84.png 300w\" sizes=\"auto, (max-width: 556px) 100vw, 556px\" \/><\/span><\/pre>\n<h2 dir=\"auto\"><span style=\"color: #ffffff;\">Optional: Update mdadm Config for Boot Persistence<\/span><\/h2>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">Run the following to ensure mdadm config is saved for future boots:<\/span><\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo mdadm --detail --scan | sudo tee \/etc\/mdadm\/mdadm.conf<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">sudo update-initramfs -u<\/pre>\n<p class=\"body\" dir=\"auto\"><span style=\"color: #ffffff;\">With these steps, you&#8217;ve successfully replaced a failed RAID 1 disk and restored redundancy.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Check RAID Status Use the following command to inspect the current state of the RAID: sudo mdadm &#8211;detail \/dev\/md0 State : clean, degraded Active Devices : 1 Failed Devices : 1 2. Mark and Remove the Faulty Disk If the faulty disk is still present but failing, run: sudo mdadm &#8211;fail \/dev\/md0 \/dev\/nvme1n1p1 sudo&hellip;<\/p>\n","protected":false},"author":1,"featured_media":530,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-528","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","category-5","description-off"],"_links":{"self":[{"href":"https:\/\/danychrys.go.ro\/web\/wp-json\/wp\/v2\/posts\/528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/danychrys.go.ro\/web\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/danychrys.go.ro\/web\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/danychrys.go.ro\/web\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/danychrys.go.ro\/web\/wp-json\/wp\/v2\/comments?post=528"}],"version-history":[{"count":20,"href":"https:\/\/danychrys.go.ro\/web\/wp-json\/wp\/v2\/posts\/528\/revisions"}],"predecessor-version":[{"id":553,"href":"https:\/\/danychrys.go.ro\/web\/wp-json\/wp\/v2\/posts\/528\/revisions\/553"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/danychrys.go.ro\/web\/wp-json\/wp\/v2\/media\/530"}],"wp:attachment":[{"href":"https:\/\/danychrys.go.ro\/web\/wp-json\/wp\/v2\/media?parent=528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/danychrys.go.ro\/web\/wp-json\/wp\/v2\/categories?post=528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/danychrys.go.ro\/web\/wp-json\/wp\/v2\/tags?post=528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}