{"id":323,"date":"2019-04-09T18:48:38","date_gmt":"2019-04-09T16:48:38","guid":{"rendered":"http:\/\/evcz.tk\/blog\/?p=323"},"modified":"2019-04-18T11:59:29","modified_gmt":"2019-04-18T09:59:29","slug":"centos-7-raid5-rebuild-grub-from-live-ubuntu-18-04-rescue-env","status":"publish","type":"post","link":"https:\/\/evcz.tk\/blog\/2019\/04\/09\/centos-7-raid5-rebuild-grub-from-live-ubuntu-18-04-rescue-env\/","title":{"rendered":"centos 7 raid5 rebuild + grub from live ubuntu 18.04 rescue env"},"content":{"rendered":"\n<pre lang=\"bash\">sudo su -\n\nmodprobe raid5\nmdadm --stop \/dev\/md0\nmdadm --stop \/dev\/md1<\/pre>\nstop any other active md device (you can see them in \/prod\/mdstat)\n<pre lang=\"bash\">mdadm --stop \/dev\/md127\nmdadm --stop \/dev\/md126<\/pre>\n\ncheck if they are all stopped\n<pre lang=\"bash\">cat \/proc\/mdstat<\/pre>\n\nrun a new scan\n<pre lang=\"bash\">mdadm --assemble --scan<\/pre>\n\ncheck if the raid5 is properly detected\n<pre lang=\"bash\">cat \/proc\/mdstat<\/pre>\n\ncopy over the partition tables from working disk (sdc here) to the new disk (sdb here)\n<pre lang=\"bash\">sfdisk -d \/dev\/sdc | sfdisk \/dev\/sdb<\/pre>\n\nadd the devices to their corresponding arrays (start with the \/boot one if you have a  dedicated boot one)\n<pre lang=\"bash\">mdadm \/dev\/md126 -a \/dev\/sdb2\nmdadm \/dev\/md127 -a \/dev\/sdb3<\/pre>\n\nnow let&#8217;s get ready to fix grub on the new disk, in our example  md126 is boot, md127 is \/\n\n<pre lang=\"bash\">mkdir \/mnt-boot\nmount \/dev\/md126 \/mnt\nmount \/dev\/md127 \/mnt-boot\nmount --bind \/dev \/mnt\/dev\nmount --bind \/proc \/mnt\/proc\nmount --bind \/sys \/mnt\/sys\nmount --bind \/mnt-boot \/mnt\/boot\nchroot \/mnt<\/pre>\n\nyou may get an error when doing the chroot if the shell is on a different path.\n\nthis works for default centos install\n<pre lang=\"bash\">chroot \/mnt \/usr\/bin\/bash<\/pre>\n\ninstall grub on all the disks\n<pre lang=\"bash\">grub2-install \/dev\/sda\ngrub2-install \/dev\/sdb\ngrub2-install \/dev\/sdc<\/pre>\n\nregenerate grub.cfg\n<pre lang=\"bash\">grub2-mkconfig > \/boot\/grub2\/grub.cfg\n<\/pre>\n\nnow monitor the progress of the array rebuild process and reboot once completed\n<pre lang=\"bash\">watch cat \/proc\/mdstat<\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>sudo su &#8211; modprobe raid5 mdadm &#8211;stop \/dev\/md0 mdadm &#8211;stop \/dev\/md1 stop any other active md device (you can see them in \/prod\/mdstat) mdadm &#8211;stop \/dev\/md127 mdadm &#8211;stop \/dev\/md126 check if they are all stopped cat \/proc\/mdstat run a new scan mdadm &#8211;assemble &#8211;scan check if the raid5 is properly detected cat \/proc\/mdstat copy over &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/evcz.tk\/blog\/2019\/04\/09\/centos-7-raid5-rebuild-grub-from-live-ubuntu-18-04-rescue-env\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;centos 7 raid5 rebuild + grub from live ubuntu 18.04 rescue env&#8221;<\/span><\/a><\/p>\n","protected":false},"author":45,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,20],"tags":[5],"class_list":["post-323","post","type-post","status-publish","format-standard","hentry","category-howto","category-snippets","tag-centos"],"_links":{"self":[{"href":"https:\/\/evcz.tk\/blog\/wp-json\/wp\/v2\/posts\/323","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/evcz.tk\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/evcz.tk\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/evcz.tk\/blog\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/evcz.tk\/blog\/wp-json\/wp\/v2\/comments?post=323"}],"version-history":[{"count":7,"href":"https:\/\/evcz.tk\/blog\/wp-json\/wp\/v2\/posts\/323\/revisions"}],"predecessor-version":[{"id":332,"href":"https:\/\/evcz.tk\/blog\/wp-json\/wp\/v2\/posts\/323\/revisions\/332"}],"wp:attachment":[{"href":"https:\/\/evcz.tk\/blog\/wp-json\/wp\/v2\/media?parent=323"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/evcz.tk\/blog\/wp-json\/wp\/v2\/categories?post=323"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/evcz.tk\/blog\/wp-json\/wp\/v2\/tags?post=323"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}