{"id":183,"date":"2014-07-15T00:19:43","date_gmt":"2014-07-15T04:19:43","guid":{"rendered":"https:\/\/www.grumpyland.com\/blog\/?p=183"},"modified":"2014-10-19T19:32:13","modified_gmt":"2014-10-19T23:32:13","slug":"installing-software-raid-on-centos-567-via-ssh","status":"publish","type":"post","link":"https:\/\/www.grumpyland.com\/blog\/183\/installing-software-raid-on-centos-567-via-ssh\/","title":{"rendered":"Installing Software RAID on Centos 5\/6\/7 via SSH"},"content":{"rendered":"<p>Considering number of dedicated server rentals that just gives JBOD, setting up your own software raid is quite handy.\u00a0This tutorial goes over the very basic of how it&#8217;s done.<\/p>\n<p>All of this should be done under root.<br \/>\nLet&#8217;s say you have 3 disks: sda, sdb &amp; sdc. The OS is mounted on the sda, so we&#8217;ll leave that alone and make a raid 1 with sdb and\u00a0sdc.<\/p>\n<h3>Use mdadm to create your software raid<\/h3>\n<p>First, make sure mdadm is installed.<\/p>\n<pre lang=\"php\" escaped=\"true\">yum install mdadm<\/pre>\n<p>Assuming that the disks sdb &amp; sdc are unmounted &amp; unused, we can create a raid with the two of them by telling mdadm to create the partition.<\/p>\n<pre lang=\"php\" escaped=\"true\">mdadm --create \/dev\/md0 --level=1 --raid-devices=2 \/dev\/sdb \/dev\/sdc<\/pre>\n<p>If you have more disks, adjust the raid devices parameter and more devices listed at the end. Other levels of RAID can be setup as well like 0, 10, etc just by changing the &#8211;level parameter. So, if you were making a raid0 of 3 disks, you could call<\/p>\n<pre lang=\"php\" escaped=\"true\">mdadm --create \/dev\/md0 --level=0 --raid-devices=3 \/dev\/sdb \/dev\/sdc \/dev\/sdd<\/pre>\n<p>for example.<\/p>\n<p>You can confirm the setup by looking at mdstat.<\/p>\n<pre lang=\"php\" escaped=\"true\">cat \/proc\/mdstat<\/pre>\n<p>Now we add the device information to a configuration file for mdadm so that they&#8217;re always available.<\/p>\n<pre lang=\"php\" escaped=\"true\">echo \"DEVICE \/dev\/sdb \/dev\/sdc\" &gt; \/etc\/mdadm.conf\r\nmdadm --detail --scan &gt;&gt; \/etc\/mdadm.conf\r\necho \"MAILADDR youremailaddress@example.com\" &gt;&gt; \/etc\/mdadm.conf\r\nmdadm -As \/dev\/md0<\/pre>\n<p>Including MAILADDR is critical for getting notifications, but it&#8217;s also critical for getting the monitor running. On newer versions (7&#8217;s repo), the monitor will not run without MAILADDR parameter.<\/p>\n<h3>mdmonitor for your RAID<\/h3>\n<p>Now that we have a RAID array, they need to be monitored. This can be done through the mdmonitor service.<\/p>\n<pre lang=\"php\" escaped=\"true\">service mdmonitor start\r\nchkconfig mdmonitor on<\/pre>\n<p>If you&#8217;re on Centos 7, you&#8217;ll need to use the new systemctl instead.<\/p>\n<pre lang=\"php\" escaped=\"true\">systemctl start mdmonitor\r\nsystemctl enable mdmonitor<\/pre>\n<h3>Making the file system &amp; mounting it<\/h3>\n<p>Next, we&#8217;ll create the file system that uses this raid array and call it \/dev\/md0 with the file system ext4<\/p>\n<pre lang=\"php\" escaped=\"true\">mkfs -t ext4 \/dev\/md0<\/pre>\n<p>You can now mount md0 to any folder you want. Like&#8230;<\/p>\n<pre lang=\"php\" escaped=\"true\">mount \/dev\/md0 \/home\/grumpyland<\/pre>\n<p>The new mount point should now appear when you call df<\/p>\n<pre lang=\"php\" escaped=\"true\">df<\/pre>\n<p>We want the mount to be always there when we start up the server, so, we need to add it to fstab too using your favorite editor. I always found nano to be the most newbie friendly with the instruction on the bottom.<\/p>\n<pre lang=\"php\" escaped=\"true\">nano \/etc\/fstab<\/pre>\n<p>There, you&#8217;ll want to add a line about the md0 we just made. Note that the directory to be mounted must already exist!<\/p>\n<pre lang=\"php\" escaped=\"true\">\/dev\/md0                \/home\/grumpyland           ext4    defaults        0 0<\/pre>\n<p>That&#8217;s it! I hope this simplified tutorial was helpful. For further information on mdadm, check out its <a href=\"http:\/\/linux.die.net\/man\/8\/mdadm\" target=\"_blank\">man pages<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Considering number of dedicated server rentals that just gives JBOD, setting up your own software raid is quite handy.\u00a0This tutorial goes over the very basic of how it&#8217;s done. All of this should be done under root. Let&#8217;s say you have 3 disks: sda, sdb &amp; sdc. The OS is mounted on the sda, so [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"_vp_format_video_url":"","_vp_image_focal_point":[],"footnotes":""},"categories":[15],"tags":[20,36,6,37,38,39],"class_list":["post-183","post","type-post","status-publish","format-standard","hentry","category-tutorial","tag-centos","tag-centos-5","tag-centos-6","tag-centos-7","tag-mdadm","tag-software-raid"],"_links":{"self":[{"href":"https:\/\/www.grumpyland.com\/blog\/wp-json\/wp\/v2\/posts\/183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.grumpyland.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.grumpyland.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.grumpyland.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.grumpyland.com\/blog\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":15,"href":"https:\/\/www.grumpyland.com\/blog\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":209,"href":"https:\/\/www.grumpyland.com\/blog\/wp-json\/wp\/v2\/posts\/183\/revisions\/209"}],"wp:attachment":[{"href":"https:\/\/www.grumpyland.com\/blog\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.grumpyland.com\/blog\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.grumpyland.com\/blog\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}