{"id":1070,"date":"2012-01-17T13:09:44","date_gmt":"2012-01-17T18:09:44","guid":{"rendered":"http:\/\/www.shainmiley.com\/wordpress\/?p=1070"},"modified":"2012-03-07T20:30:50","modified_gmt":"2012-03-08T01:30:50","slug":"mdadm-cheat-sheet","status":"publish","type":"post","link":"https:\/\/www.shainmiley.com\/wordpress\/2012\/01\/17\/mdadm-cheat-sheet\/","title":{"rendered":"Mdadm cheat sheet"},"content":{"rendered":"<p>I have spent some time over the last few weeks getting familiar with mdadm and software RAID on Linux, so I thought I would write down some of the commands and example syntax that I have used while getting started.<\/p>\n<p><strong>1)If we would like to create a new RAID array from scratch we can use the following example commands:<\/strong><\/p>\n<p>RAID1-with 2 Drives:<\/p>\n<div class=\"ex\"># mdadm &#8211;create &#8211;verbose \/dev\/md0 &#8211;level=1 \/dev\/sda1 \/dev\/sdb1<\/div>\n<p>RAID5-with 5 Drives:<\/p>\n<div class=\"ex\"># mdadm &#8211;create &#8211;verbose \/dev\/md0 &#8211;level=5 \/dev\/sda1 \/dev\/sdb1 \/dev\/sdc1 \/dev\/sdd1 \/dev\/sde1<\/div>\n<p>RAID6-with 4 Drives with 1 spare:<\/p>\n<div class=\"ex\"># mdadm &#8211;create &#8211;verbose \/dev\/md0 &#8211;level=6 &#8211;raid-devices=4 \/dev\/sda1 \/dev\/sdb1 \/dev\/sdc1 \/dev\/sdd1 \/dev\/sde1<\/div>\n<p><strong>2)If we would like to add a disk to an existing array:<\/strong><\/p>\n<div class=\"ex\"># mdadm &#8211;add \/dev\/md0 \/dev\/sdf1 (only added as a spare)<br \/>\n# mdadm &#8211;grow \/dev\/md0 -n [new number of active disks &#8211; spares] (grow the size of the array)<\/div>\n<p><strong>3)If we would like to remove a disk from an existing array:<\/strong><\/p>\n<p>First we need to &#8216;fail&#8217; the drive:<\/p>\n<div class=\"ex\"># mdadm &#8211;fail \/dev\/md0 \/dev\/sdc1<\/div>\n<p>Next it can be safely removed from the array:<\/p>\n<div class=\"ex\"># mdadm &#8211;remove \/dev\/md0 \/dev\/sdc1<\/div>\n<p><strong>4)In order to make the array survive a reboot, you need to add the details to &#8216;\/etc\/mdadm\/mdadm.conf&#8217;<\/strong><\/p>\n<div class=\"ex\"># mdadm &#8211;detail &#8211;scan &gt;&gt; \/etc\/mdadm\/mdadm.conf (Debian)<br \/>\n# mdadm &#8211;detail &#8211;scan &gt;&gt; \/etc\/mdadm.conf (Everyone else)<\/div>\n<p><strong>5)In order to delete and remove the entire array:<\/strong><\/p>\n<p>First we need to &#8216;stop&#8217; the array:<\/p>\n<div class=\"ex\"># mdadm &#8211;stop \/dev\/md0<\/div>\n<p>Next it can be removed:<\/p>\n<div class=\"ex\"># mdadm &#8211;remove \/dev\/md0<\/div>\n<p><strong>6)Examining the status of your RAID array:<\/strong><\/p>\n<p>There are two options here:<\/p>\n<div class=\"ex\">\n# cat \/proc\/mdstat<br \/>\nor<br \/>\n# mdadm &#8211;detail \/dev\/md0\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I have spent some time over the last few weeks getting familiar with mdadm and software RAID on Linux, so I thought I would write down some of the commands and example syntax that I have used while getting started. 1)If we would like to create a new RAID array from scratch we can use [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[4,3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.shainmiley.com\/wordpress\/wp-json\/wp\/v2\/posts\/1070"}],"collection":[{"href":"https:\/\/www.shainmiley.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shainmiley.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shainmiley.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shainmiley.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1070"}],"version-history":[{"count":22,"href":"https:\/\/www.shainmiley.com\/wordpress\/wp-json\/wp\/v2\/posts\/1070\/revisions"}],"predecessor-version":[{"id":1087,"href":"https:\/\/www.shainmiley.com\/wordpress\/wp-json\/wp\/v2\/posts\/1070\/revisions\/1087"}],"wp:attachment":[{"href":"https:\/\/www.shainmiley.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1070"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shainmiley.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1070"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shainmiley.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1070"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}