<?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>unixpowered.com &#187; lvm2</title>
	<atom:link href="http://www.unixpowered.com/blog/category/lvm2/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.unixpowered.com/blog</link>
	<description></description>
	<lastBuildDate>Wed, 21 Jul 2010 13:42:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=abc</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Growing mirrored LUN in RedHat</title>
		<link>http://www.unixpowered.com/blog/2009/02/06/growing-mirrored-lun-in-redhat/</link>
		<comments>http://www.unixpowered.com/blog/2009/02/06/growing-mirrored-lun-in-redhat/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 22:52:36 +0000</pubDate>
		<dc:creator>somedude</dc:creator>
				<category><![CDATA[centos]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[linux tips]]></category>
		<category><![CDATA[linux utilities]]></category>
		<category><![CDATA[lvm2]]></category>
		<category><![CDATA[redhat]]></category>
		<category><![CDATA[san]]></category>
		<category><![CDATA[storage]]></category>

		<guid isPermaLink="false">http://wayciak.wordpress.com/?p=118</guid>
		<description><![CDATA[I was putting a RedHat server onto a SAN and I could not find any clear instructions on how to grow a single mirrored LUN on the fly. Anyway, here are some notes on the process. First the setup: Two LUN&#8217;s mirrored across two SAN&#8217;s with LVM volume on the top of it. I could [...]]]></description>
			<content:encoded><![CDATA[<p>I was putting a <a title="Red Hat" href="http://www.redhat.com" target="_self">RedHat</a> server onto a SAN and I could not find any clear instructions on how to grow a single mirrored LUN on the fly. Anyway, here are some notes on the process. First the setup: Two LUN&#8217;s mirrored across two SAN&#8217;s with <acronym title="Logical Volume Manager">LVM</acronym> volume on the top of it. I could have easily just presented another set of mirrored LUN&#8217;s, add them to <acronym title="Volume Group">VG</acronym> and go from there. I wanted to avoid that, as that kind of setup can quickly get out of hand as the number of presented LUN&#8217;s grows. If there is a more &#8220;sensible&#8221; and flexible setup, I would most definitely want to know about it.</p>
<p>For sake of completeness, here are steps to recreate the initial setup I had:</p>
<ol>
<li>Create a mirror from two LUN&#8217;s</li>
<li>Use the mirror as <acronym title="Physical Volume">PV</acronym></li>
<li>Create a VG using the PV</li>
<li>Create <acronym title="Logical Volume">LV</acronym> on the top of the VG</li>
<li>Make ext3 filesystem on the top of LV and mount it</li>
</ol>
<p>Here are the actual steps with some output:</p>
<p><code>[root@ultra /]# <strong>mdadm --create /dev/md10 --level=1 --raid-devices=2 /dev/mapper/mpath4 /dev/mapper/mpath5</strong><br />
mdadm: array /dev/md10 started.<br />
[root@</code><code>ultra</code><code> /]# <strong>pvcreate /dev/md10</strong><br />
Physical volume "/dev/md10" successfully created<br />
[root@</code><code>ultra</code><code> /]# <strong>vgcreate testvg /dev/md10</strong><br />
Volume group "testvg" successfully created<br />
[root@</code><code>ultra</code><code> /]# <strong>lvcreate -l+100%FREE -n testlv testvg</strong><br />
Logical volume "testlv" created<br />
[root@</code><code>ultra</code><code> /]# <strong>mkfs -t ext3 /dev/testvg/testlv</strong><br />
[root@</code><code>ultra</code><code> /]# <strong>mount /dev/testvg/testlv /tmp/test</strong></code></p>
<p>Now the resizing part. There might be a few steps but the upshot is that the filesystem can stay mounted and in use. High level overview of steps to take:</p>
<ol>
<li>Grow the two LUN&#8217;s using SAN management software</li>
<li>Fail and remove one of the submirrors</li>
<li>Force the kernel to see the size increase of the submirror</li>
<li>Flush and recreate the multipath device map so multipathing sees the new size</li>
<li>Re-add the submirror to the mirror and let it sync</li>
<li>Repeat 2-4 for the second submirror</li>
<li>Resize the PV</li>
<li>Resize the LV</li>
<li>Resize the filesystem</li>
</ol>
<p>First, you fail and remove the submirror:</p>
<p><code>[root@</code><code>ultra</code><code> /]# <strong>mdadm /dev/md10 -f /dev/mapper/mpath4 -r /dev/mapper/mpath4</strong><br />
mdadm: set /dev/mapper/mpath4 faulty in /dev/md10<br />
mdadm: hot removed /dev/mapper/mpath4<br />
</code><br />
Now, note all paths to the LUN. Kernel sees a separate device at the end of each path to a LUN. In this case they are <em>sdj</em>, <em>sdt</em>, <em>sdg</em> and <em>sdq</em>.</p>
<p><code>[root@</code><code>ultra</code><code> /]# <strong>multipath -ll mpath4</strong><br />
mpath4 (3600508b400011c300000f000008d0000)<br />
[size=12 GB][features="1 queue_if_no_path"][hwhandler="0"]<br />
_ round-robin 0 [prio=100][active]<br />
._ 1:0:3:1     sdj 8:144  [active][ready]<br />
._ 2:0:3:1     sdt 65:48  [active][ready]<br />
_ round-robin 0 [prio=20][enabled]<br />
._ 1:0:2:1     sdg 8:96   [active][ready]<br />
._ 2:0:2:1     sdq 65:0   [active][ready]</code></p>
<p>At this point the problem is to get the kernel to recognize the new size without reboot. After a lot of trying and sifting through man pages I found that <em>blockdev</em> command does the magic. Then I googled &#8220;blockdev resize&#8221; and I found <a title="Detect online disk resize" href="http://lwn.net/Articles/296401/" target="_self">this</a> confirming my finding. So, the next step is to probe all logical paths to the LUN:</p>
<p><code>[root@</code><code>ultra</code><code> /]# <strong>blockdev --rereadpt /dev/sdj<br />
</strong> [root@</code><code>ultra</code><code> /]# <strong>blockdev --rereadpt /dev/sdt</strong><br />
[root@</code><code>ultra</code><code> /]# <strong>blockdev --rereadpt /dev/sdg</strong><br />
[root@</code><code>ultra</code><code> /]# <strong>blockdev --rereadpt /dev/sdq</strong></code></p>
<p>You should see messages in <em>/var/log/messages</em> about kernel seeing new size on all paths. If you were to issue <em>multipath -ll</em> right now you would see that multipathing is still reporting old size. To fix that, flush the device map of the LUN and then recreate it:</p>
<p><code>[root@</code><code>ultra</code><code> /]# <strong>multipath -f mpath4</strong><br />
[root@</code><code>ultra</code><code> /]# <strong>multipath -v2</strong><br />
create: mpath4 (3600508b400011c300000f000008d0000)<br />
[size=13 GB][features="0"][hwhandler="0"]<br />
_ round-robin 0 [prio=100]<br />
._ 1:0:3:1     sdj 8:144  [ready]<br />
._ 2:0:3:1     sdt 65:48  [ready]<br />
_ round-robin 0 [prio=20]<br />
._ 1:0:2:1     sdg 8:96   [ready]<br />
._ 2:0:2:1     sdq 65:0   [ready]</code></p>
<p>Multipathing should be reporting the new size. Now you are ready to put back the grown submirror and let the whole mirror sync:</p>
<p><code>[root@</code><code>ultra</code><code> /]# <strong>mdadm /dev/md10 -a /dev/mapper/mpath4</strong><br />
mdadm: hot added /dev/mapper/mpath4</code></p>
<p>When the mirror has synced up, repeat the above process for the second submirror and wait for the sync to finish. Time to grow the mirror device itself:</p>
<p><code>[root@</code><code>ultra</code><code> /]# <strong>mdadm --grow /dev/md10 --size=max</strong></code></p>
<p>After the completion <em>/proc/mdstat</em> should report increase in size of <em>/dev/md10</em>. Moving on you need to grow the PV that resides on<em> /dev/md10</em>:</p>
<p><code>[root@</code><code>ultra</code><code> /]# <strong>pvresize /dev/md10</strong><br />
Physical volume "/dev/md10" changed<br />
1 physical volume(s) resized / 0 physical volume(s) not resized</code></p>
<p>And finally, you need to resize the LV:</p>
<p><code>[root@</code><code>ultra</code><code> /]# <strong>lvresize -l+100%FREE testvg/testlv</strong><br />
Extending logical volume testlv to 13.00 GB<br />
Logical volume testlv successfully resized</code></p>
<p>Of course, don&#8217;t forget to grow the filesystem itself:</p>
<p><code>[root@</code><code>ultra</code><code> /]# <strong>ext2online /dev/testvg/testlv</strong><br />
ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b<br />
[root@</code><code>ultra</code><code> /]# <strong>df</strong><br />
Filesystem           1K-blocks      Used Available Use% Mounted on<br />
/dev/mapper/VolGroup00-rootlv<br />
.                    132304280     5104976 120478588     5% /<br />
/dev/md0                               132134         32791     92521   27% /boot<br />
none                                     8202920                 0   8202920     0% /dev/shm<br />
/dev/mapper/testvg-testlv<br />
.                     13413488         63516   12668820     1% /tmp/test</code></p>
<p>That should be it. The sync time for huge volumes is going to be something to keep in mind. The whole setup is clean and neat without clutter. I could have opted to mirror using LVM, but there seems to be a strange requirement for third, log volume. It is possible to keep the log in memory, but that supposedly causes resync on boot.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.unixpowered.com/blog/2009/02/06/growing-mirrored-lun-in-redhat/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript" src="http://analytics.hosting24.com/count.php"></script>
<noscript><a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/count.php" alt="web hosting" /></a></noscript>
<!-- End Of Analytics Code -->
