<?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>Technical Diary &#187; lvm</title>
	<atom:link href="http://andriigrytsenko.net/tag/lvm/feed/" rel="self" type="application/rss+xml" />
	<link>http://andriigrytsenko.net</link>
	<description>With Andrii Grytsenko</description>
	<lastBuildDate>Tue, 17 Aug 2010 08:25:33 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>LVM resizing</title>
		<link>http://andriigrytsenko.net/2009/07/lvm-resizing/</link>
		<comments>http://andriigrytsenko.net/2009/07/lvm-resizing/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 16:15:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[fs]]></category>
		<category><![CDATA[lvm]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=311</guid>
		<description><![CDATA[How to increase or decrease size of existing lvm partitions step-by-step

!!!Please be very careful with your data. My advice is back your data up before you start 
This tutorial describe only ext3 filesystem. 
REDUCING 
To reduce your lvm partition first of all you have to unmount you partition, re-size filesystem and lvm partition.
Here is our [...]]]></description>
			<content:encoded><![CDATA[<p>How to increase or decrease size of existing lvm partitions step-by-step<br />
<span id="more-311"></span></p>
<p><strong><span style="color: #ff0000;">!!!Please be very careful with your data. My advice is back your data up before you start</span></strong><strong><span style="color: #ff0000;"> </span></strong></p>
<p>This tutorial describe only <span style="color: #ff0000;">ext3 <span style="color: #000000;">filesystem. </span></span></p>
<p style="text-align: center;"><strong><span style="color: #ff0000;"><span style="color: #000000;">REDUCING</span> </span></strong></p>
<p>To reduce your lvm partition first of all you have to unmount you partition, re-size filesystem and lvm partition.</p>
<p>Here is our filesystems:</p>
<pre>[root@lvm ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
2.2G  1.1G  976M  53% /
/dev/hda1              99M   12M   82M  13% /boot
tmpfs                  94M     0   94M   0% /dev/shm
/dev/mapper/VolGroup00-home
1.5G   35M  1.4G   3% /home </pre>
<p>Let&#8217;s reduce our /home partition by 200 MB:</p>
<p>Unmount you partition:</p>
<pre>[root@lvm ~]# umount /home </pre>
<p>Double check that it&#8217;s really unmounted. Its should not appear at
<pre>df</pre>
<p> listing :</p>
<pre>[root@lvm ~]# df -h   |grep home
1.5G 35M 1.4G 3% /home
</pre>
<p>Run check fs tool before you start:</p>
<pre>[root@lvm ~]# e2fsck -f /dev/VolGroup00/home
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/VolGroup00/home: 11/192768 files (9.1% non-contiguous), 14826/385024 blocks</pre>
<p>Now is time for reducing fs:</p>
<pre>[root@lvm ~]# resize2fs /dev/VolGroup00/home 200M
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/VolGroup00/home to 327680 (4k) blocks.
The filesystem on /dev/VolGroup00/home is now 327680 blocks long.</pre>
<p>Where, last value in command is size.  Its should be equal the total size of partition after reducing(<em>Total_space &#8211; reduced_space = OUR_SIZE</em>).</p>
<p>Now you are ready to run lvm reduce tool:<br />
<em>!!!Be careful on this step and always make backups before you start.</em></p>
<pre>[root@lvm ~]# lvresize -L -200Mg /dev/VolGroup00/home
/dev/hdc: open failed: No medium found
Rounding up size to full physical extent 192.00 MB
WARNING: Reducing active logical volume to 1.28 GB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce home? [y/n]: y
Reducing logical volume home to 1.28 GB
Logical volume home successfully resized
</pre>
<p>mount your partition :</p>
<pre>[root@lvm ~]# mount /home</pre>
<p>and check it:</p>
<pre>[root@node2 ~]# [root@lvm ~]# df -h /home
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-home  1.3G   35M  1.2G   3% /home
</pre>
<p>As you can see now our partition is 1.3G. Its on 200MB less then old one.</p>
<p style="text-align: center;"><strong> INCREASING</strong></p>
<p>Currently we have 200MB of unallocated space. Next we divide it on two pieces. From first we make new one partition and second one add to existing root(/) partition.</p>
<p>First lets try to make new one:</p>
<pre>[root@lvm ~]# lvcreate -l 50%FREE --name test VolGroup00
/dev/hdc: open failed: No medium found
Logical volume "test" created
</pre>
<p>And make fs:</p>
<pre>[root@lvm ~]# mkfs -t ext3 /dev/VolGroup00/test
mke2fs 1.39 (29-May-2006)
THE OUTPUT IS SKIPPED.</pre>
<p>Mount and check size of new partition:</p>
<pre>[root@lvm ~]# mkdir /mnt/test
[root@lvm ~]# mount /dev/VolGroup00/test /mnt/test/
[root@lvm ~]# df -h | grep test
/dev/mapper/VolGroup00-test  93M  5.6M   83M   7% /mnt/test
</pre>
<p>Ok. This part is done. Back to our tasks. Lets try to add unallocated  space to root partition:</p>
<pre>[root@lvm ~]# lvextend -l +100%FREE /dev/VolGroup00/LogVol00
/dev/hdc: open failed: No medium found
Extending logical volume LogVol00 to 2.28 GB
Logical volume LogVol00 successfully resized</pre>
<p>TO increase file system, do:</p>
<pre>[root@lvm ~]# resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 598016 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 598016 blocks long.</pre>
<p>And last one steps remount and check:</p>
<pre>[root@lvm ~]# mount -o remount /
[root@lvm ~]# df -h /
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00  2.3G  1.1G  1.1G  51% /</pre>
<p>As we can see in the begging of the actions our root partition was 2.2G and now it&#8217;s 2.3G. This means that it was increased by 100Mb.</p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2009/07/lvm-resizing/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
