{"id":1233,"date":"2020-04-28T16:47:21","date_gmt":"2020-04-28T23:47:21","guid":{"rendered":"http:\/\/emresaglam.com\/blog\/?p=1233"},"modified":"2020-04-28T16:47:21","modified_gmt":"2020-04-28T23:47:21","slug":"so-you-lost-a-disk-on-a-md-raid5-array-now-what","status":"publish","type":"post","link":"https:\/\/emresaglam.com\/blog\/blog\/2020\/04\/28\/so-you-lost-a-disk-on-a-md-raid5-array-now-what\/","title":{"rendered":"So you lost a disk on a MD RAID5 array, now\u00a0what?"},"content":{"rendered":"\n<p>It happens, you just lost a disk on your RAID5 MD array, or things are not how it should look like\u2026 How do we troubleshoot this?<\/p>\n\n\n\n<p>First things first, what&#8217;s the name of your MD device. You can easily learn that by issuing:<\/p>\n\n\n\n<p><code>cat \/proc\/mdstat<\/code><\/p>\n\n\n\n<p>This should output something similar to:<\/p>\n\n\n\n<p><code>Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]<br>md0 : active raid5 sdd[1] sda[3] sdb[2]<br>2929890816 blocks super 1.2 level 5, 512k chunk, algorithm 2 [3\/4] [.AAA]<br>bitmap: 0\/8 pages [0KB], 65536KB chunk<\/code><\/p>\n\n\n\n<p>Here we have a MD device <code>\/dev\/md0<\/code>. (If you don&#8217;t see a response to this, you might have lost your MD device, which could be a bigger issue!)<\/p>\n\n\n\n<p>Another thing that we see (Or we don&#8217;t see) here is that sda\/sdb\/sdd are here in the raid but <code>sdc<\/code> is nowhere to be found! This is our problem. <\/p>\n\n\n\n<p>For some reason <code>\/dev\/sdc<\/code> is not in the RAID group anymore. Let&#8217;s see what&#8217;s going on with <code>\/dev\/sdc<\/code>?<\/p>\n\n\n\n<p><code>mdadm --examine \/dev\/sdc<\/code><\/p>\n\n\n\n<p>In my example this was hanging for a long time. When I issue <code>dmesg<\/code> on another console, I was getting a lot of I\/O errors about this disk. This is telling me that the disk is malfunctioning. <\/p>\n\n\n\n<p>I shutdown the server and wiggled the disk. Rebooted and it was back online. My array has now four disks however only 3 of them are &#8220;functioning&#8221; since after the reboot MD kicked <code>\/dev\/sdc<\/code> out of the array. <\/p>\n\n\n\n<p>We need to reassemble the array and let RAID5 do its magic. First stop the MD device <code>\/dev\/md0<\/code>.<\/p>\n\n\n\n<p><code>mdadm --stop \/dev\/md0<\/code><\/p>\n\n\n\n<p>Then we need to add <code>\/dev\/sdc<\/code> back into the array:<\/p>\n\n\n\n<p><code>mdadm \/dev\/md0 -a \/dev\/sdc<\/code><\/p>\n\n\n\n<p>Then depending on the situation we might need to reassemble the array:<\/p>\n\n\n\n<p><code>mdadm --assemble \/dev\/md0 \/dev\/sd[abcd] --verbose --force<\/code><\/p>\n\n\n\n<p>Hopefully <code>\/dev\/sdc<\/code> is now back in your array now. This should start a long(er) process to sync up the array state to all disks and hopefully you now have your array back!<\/p>\n\n\n\n<p>After the sync completes, I would still do a fsck on the <code>\/dev\/md0<\/code> filesystem. <\/p>\n\n\n\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container\">\n<h1><code>fsck.ext4 \/dev\/md0<\/code><\/h1>\n\n\n\n<p><code>e2fsck 1.45.5 (07-Jan-2020)<br>data: recovering journal<br>JBD2: Invalid checksum recovering block 185073680 in log<br>JBD2: Invalid checksum recovering block 89 in log<br>Journal checksum error found in data<br>data was not cleanly unmounted, check forced.<br>Pass 1: Checking inodes, blocks, and sizes<br>Pass 2: Checking directory structure<br>Pass 3: Checking directory connectivity<br>Pass 4: Checking reference counts<br>Pass 5: Checking group summary information<br>Free blocks count wrong (704006059, counted=696320594).<br>Fix? yes<br>Free inodes count wrong (182701042, counted=182694547).<br>Fix? yes<\/code><br><code>data: <em>FILE SYSTEM WAS MODIFIED<\/em><br>data: 429421\/183123968 files (0.2% non-contiguous), 36152110\/732472704 blocks<\/code><\/p>\n<\/div><\/div>\n\n\n\n<p>You can use this same steps (or similar) to remove \/dev\/sdc and replace with a brand new hard drive. In my case wiggling solved the problem for now. (I probably will need a drive in the near future) <\/p>\n\n\n\n<p>I hope this helped someone. It surely will help me when I will have to do this again \ud83d\ude1b <\/p>\n","protected":false},"excerpt":{"rendered":"<p>It happens, you just lost a disk on your RAID5 MD array, or things are not how it should look like\u2026 How do we troubleshoot this? First things first, what&#8217;s the name of your MD device. You can easily learn that by issuing: cat \/proc\/mdstat This should output something similar to: Personalities : [linear] [multipath] &hellip; <a href=\"https:\/\/emresaglam.com\/blog\/blog\/2020\/04\/28\/so-you-lost-a-disk-on-a-md-raid5-array-now-what\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">So you lost a disk on a MD RAID5 array, now\u00a0what?<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[11,9],"_links":{"self":[{"href":"https:\/\/emresaglam.com\/blog\/wp-json\/wp\/v2\/posts\/1233"}],"collection":[{"href":"https:\/\/emresaglam.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/emresaglam.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/emresaglam.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/emresaglam.com\/blog\/wp-json\/wp\/v2\/comments?post=1233"}],"version-history":[{"count":4,"href":"https:\/\/emresaglam.com\/blog\/wp-json\/wp\/v2\/posts\/1233\/revisions"}],"predecessor-version":[{"id":1299,"href":"https:\/\/emresaglam.com\/blog\/wp-json\/wp\/v2\/posts\/1233\/revisions\/1299"}],"wp:attachment":[{"href":"https:\/\/emresaglam.com\/blog\/wp-json\/wp\/v2\/media?parent=1233"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/emresaglam.com\/blog\/wp-json\/wp\/v2\/categories?post=1233"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/emresaglam.com\/blog\/wp-json\/wp\/v2\/tags?post=1233"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}