<?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; fs</title>
	<atom:link href="http://andriigrytsenko.net/tag/fs/feed/" rel="self" type="application/rss+xml" />
	<link>http://andriigrytsenko.net</link>
	<description>With Andrii Grytsenko</description>
	<lastBuildDate>Sun, 01 Apr 2012 11:10:57 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Software RAID level 1 behavior</title>
		<link>http://andriigrytsenko.net/2010/07/software-raid-level-1-behavior/</link>
		<comments>http://andriigrytsenko.net/2010/07/software-raid-level-1-behavior/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 17:47:57 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[fs]]></category>
		<category><![CDATA[mdadm]]></category>
		<category><![CDATA[raid]]></category>

		<guid isPermaLink="false">http://andriigrytsenko.net/?p=827</guid>
		<description><![CDATA[Here I will try to describe behavior of SW RAID level 1 in case of crash. There will be two scenario: Delete partition by fdisk and restart the computer. Delete and create empty partition by fdisk and restart the computer. Delete whole storage device from the system and restart computer. Delete and create whole storage [...]]]></description>
			<content:encoded><![CDATA[<p>Here I will try to describe behavior of SW RAID level 1 in case of crash.<br />
<span id="more-827"></span></p>
<p>There will be two scenario:</p>
<ol>
<li> Delete partition by <strong>fdisk</strong> and restart the computer.</li>
<li> Delete and create empty partition by <strong>fdisk</strong> and restart the computer.</li>
<li> Delete whole storage device from the system and restart computer.</li>
<li> Delete and create whole storage device from the system and restart computer.</li>
</ol>
<h3 style="text-align: center;"><strong>1.  Delete partition by fdisk and restart the computer.</strong></h3>
<p>First, I gotta create the <em>raid</em> device:</p>
<pre>[root@node1 ~]# mdadm -C /dev/md0 -n 2 -l 1 /dev/hdd1 /dev/hdb8
mdadm: largest drive (/dev/hdb8) exceed size (476160K) by more than 1%
Continue creating array? y
mdadm: array /dev/md0 started.</pre>
<p>and build <strong>ext3</strong> file system on the device:</p>
<pre>[root@node1 ~]# mke2fs -j /dev/md0</pre>
<p>Edit <em>/etc/fstab</em> according to the changes:</p>
<pre>/dev/md0                /test                   ext3    defaults        0 0</pre>
<p>and mount everything is contained at <strong>/etc/fstab</strong>:</p>
<pre>[root@node1 ~]#mount -a</pre>
<p>Copy some files to <strong>/test</strong>(to be able to check files integrity in the future):</p>
<pre>[root@node1 ~]# cp -rfv /var/* /test/</pre>
<p>Now, delete <strong>/dev/hdd1</strong> through <strong>fdisk</strong>:</p>
<pre>[root@node1 ~]# fdisk  /dev/hdd

The number of cylinders for this disk is set to 8322.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): d
Selected partition 1

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.</pre>
<p>and restart computer:</p>
<pre>[root@node1 ~]# reboot</pre>
<p>During the system booting I got next error(the same I got when try to manually mount <strong>md0</strong>):</p>
<pre>mount: wrong fs type, bad option, bad superblock on /dev/md0,
       missing codepage or other error
       (could this be the IDE device where you in fact use
       ide-scsi so that sr0 or sda or so is needed?)
       In some cases useful info is found in syslog - try
       dmesg | tail  or so</pre>
<p><strong>/proc/mdstat</strong> doesn&#8217;t see any  local raid devices:</p>
<pre>[root@node1 ~]# cat /proc/mdstat
Personalities :
unused devices:</pre>
<p>Let&#8217;s create new <strong>mdadm.conf</strong> :</p>
<pre>[root@node1 ~]#  mdadm --examine --scan  /dev/hdb8 &gt; /etc/mdadm.conf

[root@node1 ~]# cat /etc/mdadm.conf
ARRAY /dev/md0 level=raid1 num-devices=2 UUID=c1ce0c10:035aa2a3:829450b6:84b7a236</pre>
<p>And active everything from mdadm.conf:</p>
<pre>[root@node1 ~]#  mdadm -A -s
mdadm: /dev/md0 has been started with 1 drive (out of 2).</pre>
<p>The <strong>md0</strong> was activated, but only with one disk:</p>
<pre>[root@node1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 hdb8[1]
      476160 blocks [2/1] [_U]</pre>
<p><strong>Conclusion:</strong> If it was a root partition your system wouldn&#8217;t boot at all. And you would have to dance with boot disk to make you system alive.</p>
<h3 style="text-align: center;"><strong>2. Delete and create empty partition by fdisk and restart the computer.</strong></h3>
<p>The same actions as above and additional create partition <strong>/dev/hdd1</strong> in <strong>fdisk</strong>.<br />
After system booted. None of raid&#8217;s are active :</p>
<p></strong></p>
<pre>[root@node1 ~]# cat /proc/mdstat
Personalities :
unused devices:</pre>
<p>But after restore procedure system is going to work in full-fledged mode(with 2 disks):</p>
<pre>[root@node1 ~]#  mdadm --examine --scan  /dev/hdb8 &gt; /etc/mdadm.conf
[root@node1 ~]# mdadm -A -s
mdadm: /dev/md0 has been started with 2 drives.
[root@node1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 hdd1[0] hdb8[1]
475136 blocks [2/2] [UU]</pre>
<p>The new device has no influence on system behavior at all. Result is similar to previous one.</p>
<h3 style="text-align: center;"><strong>3. Delete whole storage device from the system and restart computer.</strong></h3>
<p>During this test the <strong>md0</strong> was restored and mounted during system boot without any problem or delays. Also next notice message were generated and put into the syslog facility <strong>kernel</strong>:</p>
<pre>kernel: raid1: raid set md0 active with 1 out of 2 mirrors</pre>
<h3 style="text-align: center;"><strong>4. Delete and create whole storage device from the system and restart computer.</h3>
<p></strong><br />
During boot raid wasn&#8217;t rebuilt by itself: </p>
<pre>
[root@node1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 hdb8[1]
      475136 blocks [2/1] [_U]
</pre>
<p>And has to be re-built manually :</p>
<pre>
[root@node1 ~]# mdadm -a /dev/md0 /dev/hdd1
mdadm: re-added /dev/hdd1
</pre>
<p>Still recovering :) : </p>
<pre>
[root@node1 ~]# cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 hdd1[0] hdb8[1]
      475136 blocks [2/1] [_U]
      [====>................]  recovery = 21.5% (103296/475136) finish=0.4min speed=12912K/sec
</pre>
<p><strong>NOTE: partition type for new partition should be set to &#8216;Linux raid autodetect&#8217; (FD in a hex code). Frankly speaking I didn&#8217;t test whether it works without that, that&#8217;s why it may be or may _not_ useless procedure. My advice is: just do it! </strong></p>
<pre>
[root@node1 ~]# fdisk -l /dev/hdd

Disk /dev/hdd: 4294 MB, 4294967296 bytes
16 heads, 63 sectors/track, 8322 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hdd1               1         943      475240+  fd  Linux raid autodetect
</pre>
<h3><strong>P.S. System information:</strong></h3>
<p>Tests were performed at virtual machine:<br />
<strong>virtualbox-2.1.4<br />
virtualbox-ose-guest-modules-2.6.26-1-686</strong><br />
Software installed inside VM:<br />
<strong>CentOS(kernel-2.6.18-128.el5)<br />
mdadm-2.6.9-2.el5</strong></p>
<p></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://andriigrytsenko.net/2010/07/software-raid-level-1-behavior/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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 [...]]]></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></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 to 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</p>
<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 200M /dev/VolGroup00/home
WARNING: Reducing active logical volume to 200.00MiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce home? [y/n]: y
Reducing logical volume home to 200 MiB
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  197M   35M  162M   21% /home</pre>
<p>As you can see now our partition is about 200M</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
[root@lvm ~]# umount /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>0</slash:comments>
		</item>
	</channel>
</rss>

