{"id":3130,"date":"2020-05-16T20:17:00","date_gmt":"2020-05-16T14:47:00","guid":{"rendered":"https:\/\/www.24x7serversupport.com\/blog\/?p=3130"},"modified":"2023-01-28T12:35:17","modified_gmt":"2023-01-28T07:05:17","slug":"how-to-create-remove-the-disk-from-the-array","status":"publish","type":"post","link":"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/","title":{"rendered":"How to create\/remove the disk from the array"},"content":{"rendered":"\n<p><strong>Mdadm<\/strong> is the modern tool most Linux distributions use these days to manage <strong>software RAID<\/strong> arrays; in the past <em>raidtools<\/em> was the tool we have used for this. This cheat sheet will show the most <em>common usages of mdadm<\/em> to manage software raid arrays; it assumes you have a good understanding of software RAID and Linux in general, and it will just explain the commands line usage of mdadm. The examples bellow use RAID1, but they can be adapted for any RAID level the Linux kernel driver supports.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"1-create-a-new-raid-array\">. Create a new RAID array<\/h3>\n\n\n\n<p>Create (<code>mdadm --create<\/code>) is used to create a new array:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm --create --verbose \/dev\/md0 --level=1 \/dev\/sda1 \/dev\/sdb2\n<\/code><\/pre>\n\n\n\n<p>or using the compact notation:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm -Cv \/dev\/md0 -l1 -n2 \/dev\/sd&#91;ab]1\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"2-etcmdadmconf\">2. \/etc\/mdadm.conf<\/h3>\n\n\n\n<p>\/etc\/mdadm.conf or \/etc\/mdadm\/mdadm.conf (on debian) is the main configuration file for mdadm. After we create our RAID arrays we add them to this file using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm --detail --scan &gt;&gt; \/etc\/mdadm.conf\n<\/code><\/pre>\n\n\n\n<p>or on debian<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm --detail --scan &gt;&gt; \/etc\/mdadm\/mdadm.conf\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"3-remove-a-disk-from-an-array\">3. Remove a disk from an array<\/h3>\n\n\n\n<p>We can\u2019t remove a disk directly from the array, unless it is failed, so we first have to fail it (if the drive it is failed this is normally already in failed state and this step is not needed):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm --fail \/dev\/md0 \/dev\/sda1\n<\/code><\/pre>\n\n\n\n<p>and now we can remove it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm --remove \/dev\/md0 \/dev\/sda1\n<\/code><\/pre>\n\n\n\n<p>This can be done in a single step using:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm \/dev\/md0 --fail \/dev\/sda1 --remove \/dev\/sda1\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"4-add-a-disk-to-an-existing-array\">4. Add a disk to an existing array<\/h3>\n\n\n\n<p>We can add a new disk to an array (replacing a failed one probably):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm --add \/dev\/md0 \/dev\/sdb1\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"5-verifying-the-status-of-the-raid-arrays\">5. Verifying the status of the RAID arrays<\/h3>\n\n\n\n<p>We can check the status of the arrays on the system with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/proc\/mdstat\n<\/code><\/pre>\n\n\n\n<p>or<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm --detail \/dev\/md0\n<\/code><\/pre>\n\n\n\n<p>The output of this command will look like:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/proc\/mdstat\nPersonalities : &#91;raid1]\nmd0 : active raid1 sdb1&#91;1] sda1&#91;0]\n104320 blocks &#91;2\/2] &#91;UU]\n\nmd1 : active raid1 sdb3&#91;1] sda3&#91;0]\n19542976 blocks &#91;2\/2] &#91;UU]\n\nmd2 : active raid1 sdb4&#91;1] sda4&#91;0]\n223504192 blocks &#91;2\/2] &#91;UU]\n<\/code><\/pre>\n\n\n\n<p>here we can see both drives are used and working fine &#8211; <strong>U<\/strong>. A failed drive will show as <strong>F<\/strong>, while a degraded array will miss the second disk <strong>&#8211;<\/strong><\/p>\n\n\n\n<p>Note: while monitoring the status of a RAID rebuild operation using watch can be useful:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>watch cat \/proc\/mdstat\n<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"6-stop-and-delete-a-raid-array\">6. Stop and delete a RAID array<\/h3>\n\n\n\n<p>If we want to completely remove a raid array we have to stop if first and then remove it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm --stop \/dev\/md0\nmdadm --remove \/dev\/md0\n<\/code><\/pre>\n\n\n\n<p>and finally we can even delete the superblock from the individual drives:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mdadm --zero-superblock \/dev\/sda\n<\/code><\/pre>\n\n\n\n<p>Finally in using RAID1 arrays, where we create <strong>identical partitions<\/strong> on both drives this can be useful to copy the partitions from sda to sdb:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sfdisk -d \/dev\/sda | sfdisk \/dev\/sdb\n<\/code><\/pre>\n\n\n\n<p>(this will dump the partition table of sda, removing completely the existing partitions on sdb, so be sure you want this before running this command, as it will not warn you at all).<\/p>\n\n\n\n<p>There are many other usages of <strong>mdadm<\/strong> particular for each type of RAID level, and I would recommend to use the manual page (<em>man mdadm<\/em>) or the help (<em>mdadm \u2013help<\/em>) if you need more details on its usage. Hopefully these quick examples will put you on the fast track with how mdadm works.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Mdadm is the modern tool most Linux distributions use these days to manage software RAID arrays; in the past raidtools was the tool we have used for this. This cheat sheet will show the most common usages of mdadm to manage software raid arrays; it assumes you have a good understanding of software RAID and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3602,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[30,38,33],"tags":[317,31,79,74,112,191],"class_list":["post-3130","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","category-cloudlinux","category-cpanel","tag-array","tag-centos","tag-centos6","tag-centos7","tag-linux","tag-software-raid"],"jetpack_publicize_connections":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to create\/remove the disk from the array | 24x7serversupport Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to create\/remove the disk from the array | 24x7serversupport Blog\" \/>\n<meta property=\"og:description\" content=\"Mdadm is the modern tool most Linux distributions use these days to manage software RAID arrays; in the past raidtools was the tool we have used for this. This cheat sheet will show the most common usages of mdadm to manage software raid arrays; it assumes you have a good understanding of software RAID and [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/\" \/>\n<meta property=\"og:site_name\" content=\"24x7serversupport Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-05-16T14:47:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-01-28T07:05:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/05\/How-to-create-remove-the-disk-from-the-array.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"350\" \/>\n\t<meta property=\"og:image:height\" content=\"200\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"24x7support\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:site\" content=\"@24x7serversuppo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"24x7support\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/\",\"name\":\"How to create\/remove the disk from the array | 24x7serversupport Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/05\/How-to-create-remove-the-disk-from-the-array.webp?fit=350%2C200&ssl=1\",\"datePublished\":\"2020-05-16T14:47:00+00:00\",\"dateModified\":\"2023-01-28T07:05:17+00:00\",\"author\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/#primaryimage\",\"url\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/05\/How-to-create-remove-the-disk-from-the-array.webp?fit=350%2C200&ssl=1\",\"contentUrl\":\"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/05\/How-to-create-remove-the-disk-from-the-array.webp?fit=350%2C200&ssl=1\",\"width\":350,\"height\":200,\"caption\":\"How to create\/remove the disk from the array\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.24x7serversupport.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to create\/remove the disk from the array\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#website\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/\",\"name\":\"24x7serversupport Blog\",\"description\":\"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401\",\"name\":\"24x7support\",\"url\":\"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to create\/remove the disk from the array | 24x7serversupport Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/","og_locale":"en_US","og_type":"article","og_title":"How to create\/remove the disk from the array | 24x7serversupport Blog","og_description":"Mdadm is the modern tool most Linux distributions use these days to manage software RAID arrays; in the past raidtools was the tool we have used for this. This cheat sheet will show the most common usages of mdadm to manage software raid arrays; it assumes you have a good understanding of software RAID and [&hellip;]","og_url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/","og_site_name":"24x7serversupport Blog","article_published_time":"2020-05-16T14:47:00+00:00","article_modified_time":"2023-01-28T07:05:17+00:00","og_image":[{"width":350,"height":200,"url":"https:\/\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/05\/How-to-create-remove-the-disk-from-the-array.webp","type":"image\/webp"}],"author":"24x7support","twitter_card":"summary_large_image","twitter_creator":"@24x7serversuppo","twitter_site":"@24x7serversuppo","twitter_misc":{"Written by":"24x7support","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/","url":"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/","name":"How to create\/remove the disk from the array | 24x7serversupport Blog","isPartOf":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/#primaryimage"},"image":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/#primaryimage"},"thumbnailUrl":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/05\/How-to-create-remove-the-disk-from-the-array.webp?fit=350%2C200&ssl=1","datePublished":"2020-05-16T14:47:00+00:00","dateModified":"2023-01-28T07:05:17+00:00","author":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401"},"breadcrumb":{"@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/#primaryimage","url":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/05\/How-to-create-remove-the-disk-from-the-array.webp?fit=350%2C200&ssl=1","contentUrl":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/05\/How-to-create-remove-the-disk-from-the-array.webp?fit=350%2C200&ssl=1","width":350,"height":200,"caption":"How to create\/remove the disk from the array"},{"@type":"BreadcrumbList","@id":"https:\/\/www.24x7serversupport.com\/blog\/how-to-create-remove-the-disk-from-the-array\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.24x7serversupport.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to create\/remove the disk from the array"}]},{"@type":"WebSite","@id":"https:\/\/www.24x7serversupport.com\/blog\/#website","url":"https:\/\/www.24x7serversupport.com\/blog\/","name":"24x7serversupport Blog","description":"Linux | CPanel | WHM | webhosting| Plesk | DirectAdmin | CentOs | Debian | Ubuntu Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.24x7serversupport.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.24x7serversupport.com\/blog\/#\/schema\/person\/decfb5fad6bde6ac6822d4e965c6d401","name":"24x7support","url":"https:\/\/www.24x7serversupport.com\/blog\/author\/24x7support\/"}]}},"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.24x7serversupport.com\/blog\/wp-content\/uploads\/2020\/05\/How-to-create-remove-the-disk-from-the-array.webp?fit=350%2C200&ssl=1","jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3130","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/comments?post=3130"}],"version-history":[{"count":2,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3130\/revisions"}],"predecessor-version":[{"id":3603,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/posts\/3130\/revisions\/3603"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media\/3602"}],"wp:attachment":[{"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/media?parent=3130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/categories?post=3130"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.24x7serversupport.com\/blog\/wp-json\/wp\/v2\/tags?post=3130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}