{"id":537,"date":"2019-07-05T17:16:05","date_gmt":"2019-07-05T17:16:05","guid":{"rendered":"https:\/\/server-help.org\/?p=537"},"modified":"2019-07-05T17:19:29","modified_gmt":"2019-07-05T17:19:29","slug":"recovering-a-linux-software-raid-when-a-rebuild-fails","status":"publish","type":"post","link":"https:\/\/server-help.org\/index.php\/2019\/07\/05\/recovering-a-linux-software-raid-when-a-rebuild-fails\/","title":{"rendered":"Recovering a Linux Software raid when a rebuild fails"},"content":{"rendered":"\n<p>In this scenario we will recover from a situation where both drives in a software raid 1 in Linux have failed.<\/p>\n\n\n\n<p>First go through this guide: https:\/\/server-help.org\/index.php\/2019\/04\/17\/rebuild-software-raid-linux\/<\/p>\n\n\n\n<p>If this process fails and the raid is not rebuilt proceed as follows.<\/p>\n\n\n\n<p>In this we assume sda is the drive with our data but is failing, and sdb is new.<\/p>\n\n\n\n<p>We also assume this server is running Cent OS 6, if using CentOS 7 or Ubuntu your steps may be different: <\/p>\n\n\n\n<p>https:\/\/wiki.centos.org\/TipsAndTricks\/CreateNewInitrd<\/p>\n\n\n\n<p>https:\/\/ubuntugenius.wordpress.com\/tag\/update-initramfs<\/p>\n\n\n\n<p>Reboot into a rescue image.<\/p>\n\n\n\n<p>If the ddrescue command is not installed on your rescue image:<\/p>\n\n\n\n<p>1). wget http:\/\/ftp.us.debian.org\/debian\/pool\/main\/g\/gddrescue\/gddrescue_1.21-1_amd64.deb<br> 2). dpkg -i gddrescue_1.21-1_amd64.deb<\/p>\n\n\n\n<p>1). Run the following command:<\/p>\n\n\n\n<p>ddrescue -f \/dev\/sda \/dev\/sdb \/log.log<\/p>\n\n\n\n<p>This process will take a very long time, especially if the drive is large or there are alot of errors (6-24 hours+)<\/p>\n\n\n\n<p>Once successful proceed with removing the bad sda from the array and replacing with the cloned data on the good drive sdb.<\/p>\n\n\n\n<p>1). mdadm &#8211;stop \/dev\/md1<br>2). mdadm &#8211;assemble \/dev\/md1 \/dev\/sdb1<br>3). dmsetup remove vg00-home<br>4). dmsetup remove vg00-usr<br>5). dmsetup remove vg00-var<br>6). mdadm &#8211;stop \/dev\/md3<br>7). mdadm &#8211;assemble \/dev\/md3 \/dev\/sdb3<br>8). vgchange -ay<br>9). fsck -y \/dev\/md1<\/p>\n\n\n\n<p>10). fsck -y \/dev\/mapper\/vg00-usr<br>11). fsck -y \/dev\/mapper\/vg00-var<br>12). fsck -y \/dev\/mapper\/vg00-home<br>13). mount \/dev\/md1 \/mnt<br>14). mdadm &#8211;examine &#8211;scan &#8211;config=mdadm.conf &gt;&gt; \/mnt\/etc\/mdadm.conf<br>15). mount \/dev\/vg00\/usr \/mnt\/usr<br>16). mount \/dev\/vg00\/var \/mnt\/var<br>17). mount \/dev\/vg00\/home \/mnt\/home<br>18). mount &#8211;bind \/proc \/mnt\/proc<br>19). mount &#8211;bind \/dev \/mnt\/dev<\/p>\n\n\n\n<p>20). mount &#8211;bind \/sys \/mnt\/sys<br>21). chroot \/mnt<br>22). ls \/boot\/ (to find your latest initramfs)<br>23). dracut -f \/boot\/initramfs-2.6.32-431.11.2.el6.x86_64.img initramfs-2.6.32-431.11.2.el6.x86_64<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this scenario we will recover from a situation where both drives in a software raid 1 in Linux have failed. First go through this guide: https:\/\/server-help.org\/index.php\/2019\/04\/17\/rebuild-software-raid-linux\/ If this process fails and the raid is not rebuilt proceed as follows. In this we assume sda is the drive with our data but is failing, and&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/537"}],"collection":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/comments?post=537"}],"version-history":[{"count":4,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/537\/revisions"}],"predecessor-version":[{"id":543,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/posts\/537\/revisions\/543"}],"wp:attachment":[{"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/media?parent=537"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/categories?post=537"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server-help.org\/index.php\/wp-json\/wp\/v2\/tags?post=537"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}