<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.cs.earlham.edu/index.php?action=history&amp;feed=atom&amp;title=Mdadm</id>
	<title>Mdadm - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.cs.earlham.edu/index.php?action=history&amp;feed=atom&amp;title=Mdadm"/>
	<link rel="alternate" type="text/html" href="https://wiki.cs.earlham.edu/index.php?title=Mdadm&amp;action=history"/>
	<updated>2026-08-11T10:08:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wiki.cs.earlham.edu/index.php?title=Mdadm&amp;diff=17115&amp;oldid=prev</id>
		<title>Craigje: Created page with &quot;= Rebuilding and Creating RAID 1 Arrays with mdadm =  == Crating Arrays ==  To create a mirrored array with two drives, &lt;code&gt;sda&lt;/code&gt; and &lt;code&gt;sdb&lt;/code&gt;, on partitions, &lt;...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.cs.earlham.edu/index.php?title=Mdadm&amp;diff=17115&amp;oldid=prev"/>
		<updated>2019-06-03T14:11:48Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;= Rebuilding and Creating RAID 1 Arrays with mdadm =  == Crating Arrays ==  To create a mirrored array with two drives, &amp;lt;code&amp;gt;sda&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sdb&amp;lt;/code&amp;gt;, on partitions, &amp;lt;...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Rebuilding and Creating RAID 1 Arrays with mdadm =&lt;br /&gt;
&lt;br /&gt;
== Crating Arrays ==&lt;br /&gt;
&lt;br /&gt;
To create a mirrored array with two drives, &amp;lt;code&amp;gt;sda&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sdb&amp;lt;/code&amp;gt;, on partitions, &amp;lt;code&amp;gt;sda1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sdb1&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;mdadm --create --verbose /dev/md0 --level=raid1 --raid-devices=2 /dev/sda1 /dev/sdb1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now you can monitor the status of the building of the array with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;cat /proc/mdstat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Once finished, save your &amp;lt;code&amp;gt;mdadm&amp;lt;/code&amp;gt; configuration with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;mdadm --verbose --detail --scan &amp;amp;gt; /etc/mdadm.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You may need to edit this file to remove unwanted lines or to add an email address to &amp;lt;code&amp;gt;MAILADDR&amp;lt;/code&amp;gt; to be notified if a drive failure occurs:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;MAILADDR user1@dom1.com, user2@dom2.com&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
On some systems, &amp;lt;code&amp;gt;mdadm&amp;lt;/code&amp;gt;&amp;#039;s configuration file is &amp;lt;code&amp;gt;/etc/mdadm/mdadm.conf&amp;lt;/code&amp;gt;, it is very important to put the configuration in the correct location.&lt;br /&gt;
&lt;br /&gt;
== Rebuilding Arrays ==&lt;br /&gt;
&lt;br /&gt;
If a drive ever fails, or is the system is booted with a drive removed, you will need to add it back into the array.&lt;br /&gt;
&lt;br /&gt;
=== Failed Drive ===&lt;br /&gt;
&lt;br /&gt;
In this example, &amp;lt;code&amp;gt;/dev/sda1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/sdb1&amp;lt;/code&amp;gt; make up the RAID 1 array &amp;lt;code&amp;gt;/dev/md0&amp;lt;/code&amp;gt;. Let us say that &amp;lt;code&amp;gt;/dev/sdb&amp;lt;/code&amp;gt; fails.&lt;br /&gt;
&lt;br /&gt;
==== Determining failed drive ====&lt;br /&gt;
&lt;br /&gt;
Run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;cat /proc/mdstat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;[root@lo4 ~]# cat /proc/mdstat&lt;br /&gt;
Personalities : [raid1] &lt;br /&gt;
md0 : active raid1 sdb1[1](F) sda1[0]&lt;br /&gt;
      204736 blocks super 1.0 [2/1] [U_]&lt;br /&gt;
&lt;br /&gt;
unused devices: &amp;amp;lt;none&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
When a drive fails or is missing, you will see an underscore in the array output (&amp;lt;code&amp;gt;[U_]&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;[UU]&amp;lt;/code&amp;gt;). &amp;lt;code&amp;gt;(F)&amp;lt;/code&amp;gt; will be displayed next to the failed drive (&amp;lt;code&amp;gt;sdb1[1](F)&amp;lt;/code&amp;gt;).&amp;lt;br /&amp;gt; If not, running &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; may help you determine which drive it is that failed&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;hdparm -I /dev/sda | grep &amp;amp;quot;Serial Number&amp;amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Will give you the serial number of &amp;lt;code&amp;gt;/dev/sda&amp;lt;/code&amp;gt;, which may help you identify physical disks as well.&lt;br /&gt;
&lt;br /&gt;
==== Remove Failed Drive ====&lt;br /&gt;
&lt;br /&gt;
If a drive has has failed, it should be removed from the &amp;lt;code&amp;gt;mdadm&amp;lt;/code&amp;gt; array before being replaced.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;mdadm --manage /dev/md0 --fail /dev/sdb1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;[root@lo4 ~]# mdadm --manage /dev/md0 --fail /dev/sdb1&lt;br /&gt;
mdadm: set /dev/sdb1 faulty in /dev/md0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Now, we can remove it from the array.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;mdadm --manage /dev/md0 --remove /dev/sdb1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;[root@lo4 ~]# mdadm --manage /dev/md0 --remove /dev/sdb1&lt;br /&gt;
mdadm: hot removed /dev/sdb1 from /dev/md0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Check &amp;lt;code&amp;gt;/proc/mdstat&amp;lt;/code&amp;gt;. There should no longer be any &amp;lt;code&amp;gt;(F)&amp;lt;/code&amp;gt; or listed drive besides &amp;lt;code&amp;gt;sda1[0]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Power down the system.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;shutdown -h now&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==== Replace Drive ====&lt;br /&gt;
&lt;br /&gt;
Now that everything is powered down, remove the failed HDD then replace it with the new one.&lt;br /&gt;
&lt;br /&gt;
Once the drive is replaced, boot the system back up.&lt;br /&gt;
&lt;br /&gt;
==== Add New Drive to Array ====&lt;br /&gt;
&lt;br /&gt;
Recreate the partitioning scheme of &amp;lt;code&amp;gt;/dev/sda&amp;lt;/code&amp;gt; on the new drive.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;sfdisk -d /dev/sda | fdisk /dev/sdb&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Then verify with &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;mdadm --manage /dev/md0 --add /dev/sdb1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;[root@lo4 ~]# mdadm --manage /dev/md0 --add /dev/sdb1&lt;br /&gt;
mdadm: added /dev/sdb1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Finally, check the status of the rebuilding with&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;cat /proc/mdstat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;[root@lo4 ~]# cat /proc/mdstat &lt;br /&gt;
Personalities : [raid1] &lt;br /&gt;
md0 : active raid1 sdb1[1] sda1[0]&lt;br /&gt;
      204736 blocks super 1.0 [2/1] [U_]&lt;br /&gt;
      [===========&amp;amp;gt;.........]  recovery = 57.7% (118400/204736) finish=0.0min speed=118400K/sec&lt;br /&gt;
&lt;br /&gt;
unused devices: &amp;amp;lt;none&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
=== Missing Drive ===&lt;br /&gt;
&lt;br /&gt;
In this example, &amp;lt;code&amp;gt;/dev/sda1&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/dev/sdb1&amp;lt;/code&amp;gt; make up the RAID 1 array &amp;lt;code&amp;gt;/dev/md0&amp;lt;/code&amp;gt;. Let us say that &amp;lt;code&amp;gt;/dev/sdb1&amp;lt;/code&amp;gt; is missing.&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; to examine HDD partitions with block sizes. Alternatively, you can use &amp;lt;code&amp;gt;fdisk -l&amp;lt;/code&amp;gt; or any other utility you prefer.&lt;br /&gt;
&lt;br /&gt;
Now check the status of &amp;lt;code&amp;gt;mdadm&amp;lt;/code&amp;gt; with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;cat /proc/mdstat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;Personalities : [raid1] &lt;br /&gt;
md0 : active raid1 sdb1[1](F) sda1[0]&lt;br /&gt;
      204736 blocks super 1.0 [2/1] [U_]&lt;br /&gt;
&lt;br /&gt;
unused devices: &amp;amp;lt;none&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
When a drive fails or is missing, you will see an underscore in the array output (&amp;lt;code&amp;gt;[U_]&amp;lt;/code&amp;gt; instead of &amp;lt;code&amp;gt;[UU]&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
Use the output from &amp;lt;code&amp;gt;lsblk&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/proc/mdsat&amp;lt;/code&amp;gt; to match the present drive in an active &amp;lt;code&amp;gt;mdadm&amp;lt;/code&amp;gt; array (&amp;lt;code&amp;gt;/dev/md0&amp;lt;/code&amp;gt;) with the corresponding partition on the missing drive. For example, &amp;amp;quot;match&amp;amp;quot; &amp;lt;code&amp;gt;/dev/sda1&amp;lt;/code&amp;gt; with &amp;lt;code&amp;gt;/dev/sdb1&amp;lt;/code&amp;gt; (after verifying their block sizes are the same).&lt;br /&gt;
&lt;br /&gt;
Now add &amp;lt;code&amp;gt;/dev/sdb1&amp;lt;/code&amp;gt; back into the array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;mdadm --manage /dev/md0 --add /dev/sdb1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;[root@lo4 ~]# mdadm --manage /dev/md0 --add /dev/sdb1&lt;br /&gt;
mdadm: added /dev/sdb1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
You can view the status of the rebuilding array with:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;cat /proc/mdstat&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre class=&amp;quot;text&amp;quot;&amp;gt;[root@lo4 ~]# cat /proc/mdstat &lt;br /&gt;
Personalities : [raid1] &lt;br /&gt;
md0 : active raid1 sdb1[1] sda1[0]&lt;br /&gt;
      204736 blocks super 1.0 [2/1] [U_]&lt;br /&gt;
      [===========&amp;amp;gt;.........]  recovery = 57.7% (118400/204736) finish=0.0min speed=118400K/sec&lt;br /&gt;
&lt;br /&gt;
unused devices: &amp;amp;lt;none&amp;amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
== References and Resources ==&lt;br /&gt;
&lt;br /&gt;
* http://www.howtoforge.com/replacing_hard_disks_in_a_raid1_array&lt;br /&gt;
* http://ubuntuforums.org/showthread.php?t=1760217&lt;br /&gt;
* https://raid.wiki.kernel.org/index.php/RAID_setup#RAID-1&lt;br /&gt;
* http://unix.stackexchange.com/questions/80501/no-etc-mdadm-conf-in-centos-6&lt;/div&gt;</summary>
		<author><name>Craigje</name></author>
	</entry>
</feed>