<?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>Never Use This Font &#187; ext3</title>
	<atom:link href="http://neverusethisfont.com/blog/tags/ext3/feed/" rel="self" type="application/rss+xml" />
	<link>http://neverusethisfont.com/blog</link>
	<description>Aaron Parecki is the co-founder of Geoloqi.com, and specializes in backend systems development.</description>
	<lastBuildDate>Mon, 11 Jul 2011 22:50:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Linux Software RAID and LVM</title>
		<link>http://neverusethisfont.com/blog/2009/08/linux-software-raid-and-lvm/</link>
		<comments>http://neverusethisfont.com/blog/2009/08/linux-software-raid-and-lvm/#comments</comments>
		<pubDate>Mon, 31 Aug 2009 17:48:48 +0000</pubDate>
		<dc:creator>aaron</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Server Software]]></category>
		<category><![CDATA[ext3]]></category>
		<category><![CDATA[LVM]]></category>
		<category><![CDATA[mdadm]]></category>
		<category><![CDATA[RAID 5]]></category>
		<category><![CDATA[Terabyte]]></category>

		<guid isPermaLink="false">http://neverusethisfont.com/blog/?p=97</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<p>I wanted to create a RAID 5 array with four 1tb drives. I only have three, but I have a 750gb and 320gb drive lying around. I figured there was probably a way to combine them into a 1tb drive that I could use with the others.</p>
<p>Using Linux&#8217;s LVM, I can create a logical partition from the two smaller drives as big as the 1tb drive.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ pvdisplay</pre></div></div>

<p>Lists all physical volumes managed by LVM. First we have to create the physical volumes for LVM. I prefer to create the volumes out of partitions, although you can do it from raw drives too.</p>
<p>First let&#8217;s use fdisk to create &#8220;Linux LVM&#8221; partitions on the two drives.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ fdisk <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb
Press <span style="color: #ff0000;">&quot;n&quot;</span> to create a new partition
Press <span style="color: #ff0000;">&quot;t&quot;</span> to <span style="color: #000000; font-weight: bold;">set</span> the partition <span style="color: #7a0874; font-weight: bold;">type</span>, and enter <span style="color: #ff0000;">&quot;8e&quot;</span> <span style="color: #000000; font-weight: bold;">for</span> Linux LVM.</pre></div></div>

<p>When creating the partition, accepting the defaults will make it use the whole drive. I want to use the entire 750 drive and only part of the 320 drive, so that in total it has the same number of blocks as the 1tb drives. So I first created the &#8220;Linux RAID&#8221; partitions on the 1tb drives so I could see how many cylinders it listed, which ended up being <b>121601</b>. So I created a partition the full size of the 750 drive (91201 cylinders), then created a 121601-91201 cylinder partition on the 320 drive.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ fdisk <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb
Disk <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb: <span style="color: #000000;">320.0</span> GB, <span style="color: #000000;">320072933376</span> bytes
<span style="color: #000000;">255</span> heads, <span style="color: #000000;">63</span> sectors<span style="color: #000000; font-weight: bold;">/</span>track, <span style="color: #000000;">38913</span> cylinders
   Device Boot      Start         End      Blocks   Id  System
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb1               <span style="color: #000000;">1</span>       <span style="color: #000000;">30400</span>   <span style="color: #000000;">244187968</span>+  8e  Linux LVM
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb2           <span style="color: #000000;">30401</span>       <span style="color: #000000;">38913</span>    <span style="color: #000000;">68380672</span>+  <span style="color: #000000;">83</span>  Linux
&nbsp;
$ fdisk <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdj
Disk <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdj: <span style="color: #000000;">750.1</span> GB, <span style="color: #000000;">750156374016</span> bytes
<span style="color: #000000;">255</span> heads, <span style="color: #000000;">63</span> sectors<span style="color: #000000; font-weight: bold;">/</span>track, <span style="color: #000000;">91201</span> cylinders
   Device Boot      Start         End      Blocks   Id  System
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdj1               <span style="color: #000000;">1</span>       <span style="color: #000000;">91201</span>   <span style="color: #000000;">732572001</span>   8e  Linux LVM</pre></div></div>

<p>Now that I have the two partitions ready, I moved on to LVM setup.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ pvcreate <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb1
$ pvcreate <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdj1</pre></div></div>

<p>This sets up the two partitions as physical volumes for LVM.</p>
<p>Next is creating a logical volume group:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ vgcreate vg_tb <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdb1 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdj1</pre></div></div>

<p>This creates a volume group called &#8220;vg_tb&#8221; using the two physical volumes sdb1 and sdj1.</p>
<p>Let&#8217;s take a look at what we have so far:</p>
<pre>
$ pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               vg_tb
  PV Size               232.88 GB / not usable 832.50 KB
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              59616
  Free PE               59616
  Allocated PE          0
  PV UUID               70hPKX-n11U-RcB6-0Kyt-1SOP-ni7E-2Y9hcE

  --- Physical volume ---
  PV Name               /dev/sdj1
  VG Name               vg_tb
  PV Size               698.64 GB / not usable 2.34 MB
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              178850
  Free PE               178850
  Allocated PE          0
  PV UUID               PzFb9b-lapG-KdT3-78nh-Gq75-F0Lo-I3xCrl

  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup00
  PV Size               111.60 GB / not usable 2.86 MB
  Allocatable           yes
  PE Size (KByte)       32768
  Total PE              3571
  Free PE               1
  Allocated PE          3570
  PV UUID               1wM65Z-3QGd-vDiq-mq1R-YhEE-Ackp-hh3g13

$ vgdisplay
  --- Volume group ---
  VG Name               vg_tb
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               931.51 GB
  PE Size               4.00 MB
  Total PE              238466
  Alloc PE / Size       0 / 0
  Free  PE / Size       238466 / 931.51 GB
  VG UUID               olg9GP-x1sC-sFAD-TgWY-KIIx-YWNt-kL763n

  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               111.59 GB
  PE Size               32.00 MB
  Total PE              3571
  Alloc PE / Size       3570 / 111.56 GB
  Free  PE / Size       1 / 32.00 MB
  VG UUID               IZ25LV-oMOG-DwKK-QuFN-bqqp-ClUe-d71k5l
</pre>
<p>So far so good. The next step is to create a logical volume in the new volume group:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ lvcreate vg_tb <span style="color: #660033;">-n</span> onetb <span style="color: #660033;">-l</span> <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span>VG
  Logical volume <span style="color: #ff0000;">&quot;onetb&quot;</span> created</pre></div></div>

<p>This creates a new logical volume called &#8220;onetb&#8221; in the &#8220;vg_tb&#8221; group using 100% of the group&#8217;s available space. Now let&#8217;s take a look at the list of logical volumes:</p>
<pre>
$ lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg_tb/onetb
  VG Name                vg_tb
  LV UUID                sQKaq9-D6Mv-p8it-vWGW-O7DX-FGmC-cl5FSh
  LV Write Access        read/write
  LV Status              available
  # open                 0
  LV Size                931.51 GB
  Current LE             238466
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                G5hlbb-tA3S-qhTS-03us-f9dl-1Vxy-9vDSU5
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                109.62 GB
  Current LE             3508
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                7NZrY9-1wSJ-4fRp-VPnM-V07u-9rj8-vmtxTx
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.94 GB
  Current LE             62
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
</pre>
<p>You can ignore all of the VolGroup00 things, those are the auto-created volumes from when I installed Fedora. </p>
<p>At this point, I have a new device at /dev/vg_tb/onetb which is the same size as my 1tb drives, and I can use it exactly as I would use the 1tb partition at /dev/sdf1.</p>
<p>Now it&#8217;s time to create the RAID 5 array from these four volumes.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ mdadm <span style="color: #660033;">-v</span> <span style="color: #660033;">--create</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md1 <span style="color: #660033;">--chunk</span>=<span style="color: #000000;">128</span> <span style="color: #660033;">--level</span>=<span style="color: #000000;">5</span> <span style="color: #660033;">--raid-devices</span>=<span style="color: #000000;">4</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdf1 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdh1 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sdi1 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>vg_tb<span style="color: #000000; font-weight: bold;">/</span>onetb
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: layout defaults to left-symmetric
mdadm: <span style="color: #c20cb9; font-weight: bold;">size</span> <span style="color: #000000; font-weight: bold;">set</span> to 976756608K
mdadm: array <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md1 started.</pre></div></div>

<p>The array will begin syncing, and you can watch it by running:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">watch</span> <span style="color: #660033;">-n</span> <span style="color: #000000;">1</span> <span style="color: #ff0000;">&quot;cat /proc/mdstat&quot;</span>
Personalities : <span style="color: #7a0874; font-weight: bold;">&#91;</span>raid6<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>raid5<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>raid4<span style="color: #7a0874; font-weight: bold;">&#93;</span>
md1 : active raid5 dm-<span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> sdi1<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> sdh1<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> sdf1<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
      <span style="color: #000000;">2930269824</span> blocks level <span style="color: #000000;">5</span>, 128k chunk, algorithm <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>UUU_<span style="color: #7a0874; font-weight: bold;">&#93;</span>
      <span style="color: #7a0874; font-weight: bold;">&#91;</span>=<span style="color: #000000; font-weight: bold;">&gt;</span>...................<span style="color: #7a0874; font-weight: bold;">&#93;</span>  recovery =  <span style="color: #000000;">5.5</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">54017536</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">976756608</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">finish</span>=593.1min <span style="color: #007800;">speed</span>=25925K<span style="color: #000000; font-weight: bold;">/</span>sec
&nbsp;
md0 : active raid5 sdg1<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> sdc1<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">3</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> sde1<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> sdd1<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
      <span style="color: #000000;">2197715712</span> blocks level <span style="color: #000000;">5</span>, 64k chunk, algorithm <span style="color: #000000;">2</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">4</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>UUUU<span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
unused devices: <span style="color: #000000; font-weight: bold;">&lt;</span>none<span style="color: #000000; font-weight: bold;">&gt;</span></pre></div></div>

<p>While this is syncing, we can create the ext3 filesystem.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ mke2fs <span style="color: #660033;">-j</span> <span style="color: #660033;">-b</span> <span style="color: #000000;">4096</span> <span style="color: #660033;">-m</span> <span style="color: #000000;">0</span> <span style="color: #660033;">-E</span> <span style="color: #007800;">stride</span>=<span style="color: #000000;">32</span>,stripe-width=<span style="color: #000000;">96</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>md1</pre></div></div>

<p>This creates an ext2 filesystem with journaling (ext3), the block size is 4kb, and 0% of the blocks are reserved for the superuser. The stride is calculated as the raid block size / ext2 block size (128k / 4k = 32). The stripe width is calculated as the stride value times the number of data disks in the array. In a 4-disk RAID 5 array, there are three data disks, one being for the parity data. </p>
<p>This will take some time, and will significantly slow down the sync process. Mine dropped from 25mb/s to around 1mb/s. I figure I&#8217;ll let it create the filesystem so I can start copying data to it right away, and let it finish its sync on its own time.</p>
<p>While you&#8217;re at it, you should set up <a href="http://munin.projects.linpro.no/">munin</a> to monitor the SMART data from all the drives as well as the status of the array using my <a href="http://aaronparecki.com/GitHub">munin-raid-monitor</a> plugin.</p>
<p>Additional Reading:</p>
<div style="font-size:10px">
<ul>
<li><a href="http://linux-raid.osdl.org/index.php/RAID_setup">http://linux-raid.osdl.org/index.php/RAID_setup</a></li>
<li><a href="http://bfish.xaedalus.net/2006/11/software-raid-5-in-ubuntu-with-mdadm/">http://bfish.xaedalus.net/2006/11/software-raid-5-in-ubuntu-with-mdadm/</a></li>
<li><a href="http://www.linuxquestions.org/questions/linux-hardware-18/how-can-i-override-the-5.00-reserved-for-the-super-user-mkfs.ext3-creates-616546/">http://www.linuxquestions.org/questions/linux-hardware-18/how-can-i-override-the-5.00-reserved-for-the-super-user-mkfs.ext3-creates-616546/</a></li>
<li><a href="http://www.linuxconfig.org/Linux_lvm_-_Logical_Volume_Manager">http://www.linuxconfig.org/Linux_lvm_-_Logical_Volume_Manager</a></li>
<li><a href="http://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/LV_create.html">http://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/LV_create.html</a></li>
</ul>
</div>
]]></content:encoded>
			<wfw:commentRss>http://neverusethisfont.com/blog/2009/08/linux-software-raid-and-lvm/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>

