<?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>Hamstar &#187; mkinitrd</title>
	<atom:link href="http://www.hamstar.co.nz/tag/mkinitrd/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hamstar.co.nz</link>
	<description>Another Metal Car Computer Geek blog</description>
	<lastBuildDate>Sat, 06 Aug 2011 17:46:55 +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>Migrating to a RAID1 array in RHEL5.4</title>
		<link>http://www.hamstar.co.nz/2009/11/29/migrating-to-a-raid1-array-in-rhel5-4/</link>
		<comments>http://www.hamstar.co.nz/2009/11/29/migrating-to-a-raid1-array-in-rhel5-4/#comments</comments>
		<pubDate>Sun, 29 Nov 2009 10:35:29 +0000</pubDate>
		<dc:creator>hamstar</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[grub]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[mdadm]]></category>
		<category><![CDATA[mirror]]></category>
		<category><![CDATA[mkinitrd]]></category>
		<category><![CDATA[raid]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[rhel5]]></category>
		<category><![CDATA[scsi]]></category>

		<guid isPermaLink="false">http://www.hamstar.co.nz/?p=355</guid>
		<description><![CDATA[OK, so I just had a bitch of a time migrating from a live single disk redhat enterprise linux 5.4 box to a booting dual disk RAID 1 setup&#8230; There is pretty much nothing on the net about this for redhat especially to do with making kernels which almost none of the debian guides seem [...]]]></description>
			<content:encoded><![CDATA[<p>OK, so I just had a bitch of a time migrating from a live single disk redhat enterprise linux 5.4 box to a booting dual disk RAID 1 setup&#8230; There is pretty much nothing on the net about this for redhat especially to do with making kernels which almost none of the debian guides seem to care about.</p>
<p>So I played it by ear and I&#8217;m going to post how I did it so you won&#8217;t have to.  You&#8217;ll need to be using mdadm.  I&#8217;m going to assume the partitions you want raided are /dev/sda1 and /dev/sdb1 and that you are currently booted to /dev/sda1.  A rescue disk will also be helpful.</p>
<p>We are going to get a mirror going with just /dev/sdb1 (empty I hope) in it.  Then we&#8217;ll copy everything over to it so everything is the same after reboot when it does a resync.  Makes your data a bit safer.</p>
<h3>Here we go&#8230;</h3>
<p>Have you tried to setup raid before on these drives?  This checks them for superblocks.</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mdadm --examine /dev/sda1<br />
mdadm --examine /dev/sda1</div></div>
<p>If it spat up lines like &#8220;ARRAY blah blah UUID=34cd3:etc&#8221;, zero them.  Don&#8217;t worry not dangerous to data.</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mdadm --zero-superblock /dev/sda1<br />
mdadm --zero-superblock /dev/sdb1</div></div>
<p>OK now we want to copy the partition tables over:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">sfdisk -d /dev/sda1 | sfdisk /dev/sdb</div></div>
<p>Now we create the raid array in a degraded mode with the master drive missing and format it to your filesystem.</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mdadm --create /dev/md0 --level 1 --raid-devices=2 missing /dev/sdb1<br />
mkfs.ext3 /dev/md0</div></div>
<p>Have a look at your new RAID:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mdadm --detail /dev/md0<br />
cat /proc/mdstat</div></div>
<p>Now we need to make sure that the kernel modules for scsi and raid are built in to the kernel.  I am not actually sure if this step is needed but it worked on mine.</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">cd /usr/src/kernels/2.6.18-lots-of-numbers/<br />
make menuconfig</div></div>
<p>Now you&#8217;ll be presented with the kernel modules config screen.  Find <strong>Device Drivers</strong> then in <strong>SCSI Device Support</strong>.  In this section we need to make sure a few things have the asterisk in the brackets (should mean built in on the legend).  These things for me were <strong>RAID Transport Class</strong>, <strong>SCSI device support</strong>, <strong>SCSI disk support</strong> and <strong>SCSI generic support</strong>.  Press spacebar on each of them to change the M or blank in the brackets to an asterisk.  Then exit out of it saving your config as you leave.</p>
<p>Now the important part &#8211; creating the kernel image.  This worked for me&#8230; at about the sixth time and exhaustive google searches:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mkinitrd --preload=raid1 --with=raid1 --builtin=raid1 --force-scsi-probe --force-raid-probe /boot/initrd-`uname -r`-raid.img `uname -r`</div></div>
<p>Now you want to modify /boot/grub/grub.conf and /boot/grub/device.map.</p>
<p>Need to make sure we have both devices in there<br />
/boot/grub/device.map:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">(hd0) &nbsp; &nbsp;/dev/sda<br />
(hd1) &nbsp; &nbsp;/dev/sdb</div></div>
<p>Need to make a backup bootloader entry and a raided one too<br />
/boot/grub/grub.conf:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">default=0<br />
fallback=1<br />
timeout=5<br />
splashimage=(hd1,0)/boot/grub/splash.xpm.gz<br />
hiddenmenu<br />
title RHEL RAID<br />
&nbsp; &nbsp; &nbsp; &nbsp; root (hd1,0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; kernel /boot/vmlinuz-2.6.23.1-42 root=/dev/md0 ro rhgb quiet<br />
&nbsp; &nbsp; &nbsp; &nbsp; initrd /boot/initrd-2.6.23.1-42-raid.img<br />
<br />
title RHEL Non-RAID<br />
&nbsp; &nbsp; &nbsp; &nbsp; root (hd0,0)<br />
&nbsp; &nbsp; &nbsp; &nbsp; kernel /boot/vmlinuz-2.6.23.1-42 root=/dev/sda1 ro rhgb quiet<br />
&nbsp; &nbsp; &nbsp; &nbsp; initrd /boot/initrd-2.6.23.1-42.img</div></div>
<p>That boot list boots off /dev/sdb before and loads into the system with the raid array active.  This allows you to add /dev/sda1 into the array.  If it booted off /dev/sda1 (e.g. hd0) then /dev/sda1 would be locked and you would not be able to do the mdadm command.</p>
<p>It also allows you to boot without the raid array if your raid setup failed to boot (i.e. kernel panic).  The setting for root in fstab doesn&#8217;t matter if its set  to /dev/md0, /dev/sda1 still becomes the root drive.</p>
<p>Now install grub on /dev/sdb:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">grub<br />
root (hd1)<br />
setup (hd1)</div></div>
<p>Now change the root device in your fstab to be /dev/md0<br />
/etc/fstab:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">/dev/md0 &nbsp; &nbsp;/ &nbsp; &nbsp;ext3 &nbsp; &nbsp;defaults &nbsp; &nbsp;1 &nbsp;1</div></div>
<p>Now we need to copy everything over to the raid array, however it will probably crash out copying with the running system like mine did, but not to worry we are pretty much ready to go here.</p>
<p>Shut down and boot into a linux rescue disk (the first cd of RHEL5.4 has it), and get to the command line, don&#8217;t bother mounting filesystems or anything.<br />
Try this:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mdadm --assemble --scan<br />
mdadm --assemble /dev/md0</div></div>
<p>If that doesn&#8217;t work then try this:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mdadm --create /dev/md0 --level 1 --raid-devices=2 missing /dev/sdb1 --assume-clean</div></div>
<p>and push y if it asks you to create over another array.</p>
<p>Create mountpoints and mount your drives:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">cd /mnt<br />
mkdir sda1 md0<br />
mount /dev/sda1 sda1<br />
mount /dev/md0 md0</div></div>
<p>Now copy everything over:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">cp -dpRx /mnt/sda1/* /mnt/md0/</div></div>
<p>Wait a while till that is done then reboot.  Hopefully you don&#8217;t get a kernel panic, and it boots up on the degraded /dev/md0 array.  If it does then add your /dev/sda1 in like follows:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">mdadm --add /dev/md0 /dev/sda1</div></div>
<p>Now you can watch the resync progress like this:</p>
<div class="codecolorer-container text vibrant" style="overflow:auto;white-space:nowrap;border: 1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">watch -n 2 cat /proc/mdstat</div></div>
<p>mdadm is pretty smart.</p>
<p>Here&#8217;s some other links that may help you out if you&#8217;re stuck:<br />
<a href="http://wiki.clug.org.za/wiki/RAID-1_in_a_hurry_with_grub_and_mdadm">http://wiki.clug.org.za/wiki/RAID-1_in_a_hurry_with_grub_and_mdadm</a><br />
<a href="http://www.mail-archive.com/linux-raid@vger.kernel.org/msg09672.html">http://www.mail-archive.com/linux-raid@vger.kernel.org/msg09672.html</a><br />
<a href="http://www.debian-administration.org/articles/238">http://www.debian-administration.org/articles/238</a><br />
<a href="http://unthought.net/Software-RAID.HOWTO/Software-RAID.HOWTO-7.html">http://unthought.net/Software-RAID.HOWTO/Software-RAID.HOWTO-7.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.hamstar.co.nz/2009/11/29/migrating-to-a-raid1-array-in-rhel5-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

