{"id":212,"date":"2017-08-28T15:38:16","date_gmt":"2017-08-28T15:38:16","guid":{"rendered":"https:\/\/d1m0.com\/?p=212"},"modified":"2017-08-29T15:30:02","modified_gmt":"2017-08-29T15:30:02","slug":"software-raidbasics-and-how-to","status":"publish","type":"post","link":"https:\/\/d1m0.com\/?p=212","title":{"rendered":"Software Raid,basics and how to."},"content":{"rendered":"<p>1. Create<br \/>\n1.1 Levels<br \/>\n2. Monitor<br \/>\n2.1 Follow<br \/>\n3. Build Manage<br \/>\n4. Grow<br \/>\n5. hints<\/p>\n<p><!--more--><\/p>\n<p>1. Create<\/p>\n<blockquote><p>sudo mdadm &#8211;zero-superblock \/dev\/sdc<br \/>\nsudo mdadm &#8211;zero-superblock \/dev\/sdd<br \/>\nsudo mdadm &#8211;create &#8211;verbose \/dev\/md0 &#8211;level=0 &#8211;raid-devices=2 \/dev\/sda \/dev\/sdb<br \/>\ncat \/proc\/mdstat<\/p><\/blockquote>\n<p>Create and Mount the Filesystem<\/p>\n<blockquote><p>sudo mkfs.ext4 -F \/dev\/md0<br \/>\nsudo mkdir -p \/mnt\/md0<br \/>\nsudo mount \/dev\/md0 \/mnt\/md0<\/p><\/blockquote>\n<p>Save the Array Layout<\/p>\n<blockquote><p>sudo mdadm &#8211;detail &#8211;scan | sudo tee -a \/etc\/mdadm\/mdadm.conf<br \/>\nsudo update-initramfs -u<br \/>\necho &#8216;\/dev\/md0 \/mnt\/md0 ext4 defaults,nofail,discard 0 0&#8217; | sudo tee -a \/etc\/fstab<\/p><\/blockquote>\n<p>1.1 Levels<\/p>\n<p>Level 4<\/p>\n<blockquote><p>mdadm &#8211;create &#8211;verbose \/dev\/md0 &#8211;level=4 &#8211;raid-devices=4 \/dev\/sdb \/dev\/sdc \/dev\/sdd \/dev\/sde spare-devices=\/dev\/sdf<\/p><\/blockquote>\n<p>Level 5<\/p>\n<blockquote><p>mdadm &#8211;create \/dev\/md0 &#8211;level=5 &#8211;raid-devices=4 \/dev\/sda1 \/dev\/sdb1 \/dev\/sdc1 \/dev\/sdd1<br \/>\nmdadm &#8211;assemble \/dev\/md0 \/dev\/sda1 \/dev\/sdb1 \/dev\/sdc1 \/dev\/sdd1<\/p><\/blockquote>\n<p>Level 1<\/p>\n<blockquote><p>mdadm &#8211;create &#8211;verbose \/dev\/md0 &#8211;level=mirror &#8211;raid-devices=2 \/dev\/sdb1 \/dev\/sdc1<br \/>\nmdadm &#8211;assemble \/dev\/md0 \/dev\/sdb1 \/dev\/sdc1<\/p><\/blockquote>\n<p>Level 0<\/p>\n<blockquote><p>mdadm &#8211;create &#8211;verbose \/dev\/md0 &#8211;level=stripe &#8211;raid-devices=2 \/dev\/sdb6 \/dev\/sdc5<\/p><\/blockquote>\n<p>If you have spare disks, you can add them to the end of the device specification like<\/p>\n<blockquote><p>mdadm &#8211;create &#8211;verbose \/dev\/md0 &#8211;level=mirror &#8211;raid-devices=2 \/dev\/sdb1 \/dev\/sdc1 &#8211;spare-devices=1 \/dev\/sdd1<\/p><\/blockquote>\n<p>2.Monitoring mdadm, Follow<\/p>\n<blockquote><p>cat \/proc\/mdstat<br \/>\nmdadm -D \/dev\/md0<br \/>\nmdadm &#8211;query \/dev\/md0<br \/>\nmdadm -E \/dev\/sdc1<br \/>\nmdadm &#8211;verbose &#8211;detail -scan<\/p><\/blockquote>\n<p>2.1Follow<\/p>\n<blockquote><p>mdadm &#8211;monitor &#8211;mail=root &#8211;delay=300 \/dev\/md0<\/p><\/blockquote>\n<p>You can also specify -y option to let mdadm write log into syslog.<\/p>\n<blockquote><p>chkconfig mdmonitor on<br \/>\nchkconfig &#8211;list mdmonitor<br \/>\nmdmonitor 0:off 1:off 2:on 3:on 4:on 5:on 6:off<br \/>\nBy default, it uses the following options<br \/>\nOPTIONS=&#8221;&#8211;monitor &#8211;scan -f &#8211;pid-file=$PIDFILE&#8221;<\/p><\/blockquote>\n<p>test it<\/p>\n<blockquote><p>mdadm &#8211;monitor -t \/dev\/md1<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>3.Build, Manage, adding, removing<\/p>\n<blockquote><p>mdadm &#8211;stop \/dev\/md0<br \/>\nmdadm &#8211;remove \/dev\/md0<\/p><\/blockquote>\n<p>To start (assemble) a stopped array :<\/p>\n<blockquote><p>mdadm &#8211;asemble \/dev\/md0<br \/>\nmdadm &#8211;add \/dev\/md0 \/dev\/sdd<\/p><\/blockquote>\n<p>removing a device<\/p>\n<p>We can fail a device (-f) from an array and then remove (-r) it:<\/p>\n<blockquote><p>mdadm &#8211;manage \/dev\/md0 -f \/dev\/sdd<br \/>\nmdadm &#8211;manage \/dev\/md0 -r \/dev\/sdd<\/p><\/blockquote>\n<p>5.Hitns<br \/>\nlsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Create 1.1 Levels 2. Monitor 2.1 Follow 3. Build Manage 4. Grow 5. hints<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-212","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/d1m0.com\/index.php?rest_route=\/wp\/v2\/posts\/212","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/d1m0.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/d1m0.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/d1m0.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/d1m0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=212"}],"version-history":[{"count":6,"href":"https:\/\/d1m0.com\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions"}],"predecessor-version":[{"id":218,"href":"https:\/\/d1m0.com\/index.php?rest_route=\/wp\/v2\/posts\/212\/revisions\/218"}],"wp:attachment":[{"href":"https:\/\/d1m0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=212"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/d1m0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=212"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/d1m0.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}