<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Steve Glendinning &#187; RAID</title>
	<atom:link href="http://www.steveglendinning.com/tag/raid/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.steveglendinning.com</link>
	<description></description>
	<lastBuildDate>Fri, 06 Nov 2009 10:26:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Upgrading Linux software RAID-1 array</title>
		<link>http://www.steveglendinning.com/2007/10/24/upgrading-linux-software-raid-1-array/</link>
		<comments>http://www.steveglendinning.com/2007/10/24/upgrading-linux-software-raid-1-array/#comments</comments>
		<pubDate>Wed, 24 Oct 2007 20:40:06 +0000</pubDate>
		<dc:creator>Steve</dc:creator>
				<category><![CDATA[Debian]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[RAID]]></category>

		<guid isPermaLink="false">http://www.steveglendinning.com/2007/10/24/upgrading-linux-software-raid-1-array/</guid>
		<description><![CDATA[I just finished upgrading my Debian Etch fileserver from 2&#215;200GB IDE disks to 2&#215;500GB SATA disks.  I managed to keep the server running for nearly the entire time, by failing and hot-adding disks to the RAID-1 arrays. If I had room in the case for more than two disks it would have been even [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished upgrading my Debian Etch fileserver from 2&#215;200GB IDE disks to 2&#215;500GB SATA disks.  I managed to keep the server running for nearly the entire time, by failing and hot-adding disks to the RAID-1 arrays. If I had room in the case for more than two disks it would have been even easier.</p>
<p>Here is the configuration BEFORE:</p>
<ul>
<li>/dev/hda partitioned into hda1 (10GB), hda2 (1GB), hda3 (175GB)</li>
<li>/dev/hdc partitioned into hdc1 (10GB), hdc2 (1GB), hdc3 (175GB)</li>
<li>RAID-1 array md0 composed of hda1 and hdc1, mounted as /</li>
<li>RAID-1 array md1 composed of hda2 and hdc2, mounted as swap</li>
<li>RAID-1 array md2 composed of hda3 and hdc3, mounted as /home</li>
</ul>
<p>I started the ball rolling by failing one partition from each RAID array:</p>
<blockquote><p>mdadm &#8211;fail /dev/md0 /dev/hdc1<br />
mdadm &#8211;fail /dev/md1 /dev/hdc2<br />
mdadm &#8211;fail /dev/md2 /dev/hdc3</p></blockquote>
<p>Then I powered down the server, disconnected and removed hdc and added a new 500GB SATA disk to the SATA PCI card.  It booted up fine with all three RAID arrays degraded.  I used fdisk to partition the new SATA disk (/dev/sda) with identical sized partitions 1 and 2, and with the third partition taking up the remainder of the disk.  I set all partition types to fd (linux raid auto-detect):</p>
<ul>
<li>sda1 (10GB), sda2 (1GB), sda3 (454GB)</li>
</ul>
<p>Then one at a time I hot-added these partitions to the running RAID arrays.  This causes a background reconstruction, so it&#8217;s worth waiting for each to finish before starting the next:</p>
<blockquote><p>mdadm &#8211;add /dev/md0 /dev/sda1<br />
mdadm &#8211;add /dev/md1 /dev/sda2<br />
mdadm &#8211;add /dev/md2 /dev/sda3</p></blockquote>
<p>When all three were completely synced (cat /proc/mdstat to see the progress), I edited /etc/mdadm/mdadm.conf to change all references from /dev/hdcx to /dev/sdax.  I then re-built the initramfs so it knew how to start the arrays at boot time:</p>
<blockquote><p>update-initramfs -k all -c -t</p></blockquote>
<p>I then powered down the server again, removed the last IDE disk (hda) and added the second SATA disk (sdb).  At this point the system is unbootable, so I started from a rescue CD (actually the Debian Etch netinst cd, starting with the &#8220;rescue&#8221; boot option).  Once I got a command prompt (Alt-F2 and Alt-F3 virtual consoles), I installed grub:</p>
<blockquote><p>mount /dev/sda1 /mnt<br />
chroot /mnt /bin/bash<br />
nano /boot/grub/device.map</p></blockquote>
<p>I edited the device.map so it looked like this:</p>
<blockquote><p>(hd0)   /dev/sda<br />
(hd1)   /dev/sdb</p></blockquote>
<p>Then installed grub on the first SATA disk:</p>
<blockquote><p>grub-install /dev/sda</p></blockquote>
<p>I rebooted and grub succesfully booted the server.  As expected, all RAID arrays were in degraded mode.  I used fdisk to re-partition the second SATA disk to match the first, then hot-added the mirrors to the RAID arrays (waiting for each re-sync to complete before starting the next):</p>
<blockquote><p>mdadm &#8211;add /dev/md0 /dev/sdb1<br />
mdadm &#8211;add /dev/md1 /dev/sdb2<br />
mdadm &#8211;add /dev/md2 /dev/sdb3</p></blockquote>
<p>Then I edited /etc/mdadm/mdadm.conf to update the partitions to (for example) sda1,sdb1.  I re-build the initramfs again as above, and rebooted to test everything booted up cleanly.  Also I checked /proc/mdstat after the reboot to check all arrays were fully functional.</p>
<p>So now the new disks are installed, but there&#8217;s no extra storage available because the ext3 partition is still set to the old size!  I rebooted into single user mode, unmounted /home, then used resize2fs to expand the filesystem to use the whole partition:</p>
<blockquote><p>e2fsck -f /dev/md2<br />
resize2fs /dev/md2</p></blockquote>
<p>One reboot later and voila, 455GB usable in /home.</p>
<p>Then I followed <a href="http://grub.enbug.org/MirroringRAID" title="Grub Mirroring RAID">this guide to install grub on the second RAID disk</a> in a bootable way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.steveglendinning.com/2007/10/24/upgrading-linux-software-raid-1-array/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
