<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="home" title="HomePage" href="HomePage.html" />
<link rel="help" title="HowToUseWiki" href="HowToUseWiki.html" />
<link rel="copyright" title="GNU General Public License" href="http://www.gnu.org/copyleft/gpl.html#SEC1" />
<link rel="author" title="The PhpWiki Programming Team" href="http://phpwiki.org/ThePhpWikiProgrammingTeam" />
<meta http-equiv="Content-Style-Type" content="text/css" />
<meta http-equiv="Content-Language" content="en" />
<meta name="robots" content="noindex,nofollow" />
<meta name="language" content="en" />
<meta name="document-type" content="Public" />
<meta name="document-rating" content="General" />
<meta name="generator" content="PhpWiki" />
<meta name="PHPWIKI_VERSION" content="1.3.14" />

<link rel="stylesheet" type="text/css" charset="iso-8859-1" href="phpwiki-printer.css" />
<title>PhpWiki - lvm</title>
</head>
<body>

<div id="header">
  
<!-- Page title -->
<h1>lvm</h1>
</div>
<div id="content">



<div class="wikitext"><ul><li class="tightenable top bottom">mdadm &amp; lvm exercise</li>
<li class="tightenable top bottom">This is my experience with these 2 tools on sme. They concern hard disks and raids.</li>
<li class="tightenable top bottom">This was confusing for me, so I wanted to write it down for later use.</li>
<li class="tightenable top bottom">I'm not going to explain what a raid is. That is outside the scope of this document.</li>
<li class="tightenable top bottom">I'm not an expert and this info was pulled by from different sources on the internet and man pages.</li>
<li class="tightenable top">You can follow along but I'm going to put a dash (-) to indicate every command. Don't include the dash in the command.</li>
<li class="tightenable bottom">SCENERIO</li>
</ul>
<p class="tightenable top">Normally I would partition a hard disk with 3 partitions to get my linux going: boot, swap and root. Boot is what's used to boot the computer. Swap is a memory swap or virtual memory. Root is everything else including all your documents.</p>
<ul><li class="tightenable bottom">PROBLEM</li>
</ul>
<p class="tightenable top">I can't understand volumes and the lvm.</p>
<ul><li class="tightenable bottom">PLAIN ENGLISH EXERCISE</li>
</ul>
<p class="tightenable top">mdadm &amp; lvm are new tools to sme, replacing other tool that are no longer available.</p>
<p class="tightenable">mdadm stands for multiple device administrator. This is the linux software raid tool. It is one tool that manages drives. You can take 2 hard disks and raid them together to make multiple disk or md. You can view your md's by:
--cat /proc/mdstat</p>
<p class="tightenable bottom">When I do this, I get:
Personalities : <u title="Empty link to: raid1" onmouseover="window.status=&quot;Empty link to: raid1&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">raid1</u>
md2 : active raid1 hda2<u title="Empty link to: 0" onmouseover="window.status=&quot;Empty link to: 0&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">0</u></p>
<blockquote class="tightenable top"><p class="tightenable top bottom">78047936 blocks <span><a href="2.html" class="named-wiki" title="2">2</a><u title="Empty link to: 2/1" onmouseover="window.status=&quot;Empty link to: 2/1&quot;; return true;" onmouseout="window.status='';return true;" class="named-wikiunknown">/1</u></span> <u title="Empty link to: U_" onmouseover="window.status=&quot;Empty link to: U_&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">U_</u></p>
</blockquote>
<p class="tightenable bottom">md1 : active raid1 hda1<u title="Empty link to: 0" onmouseover="window.status=&quot;Empty link to: 0&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">0</u></p>
<blockquote class="tightenable top"><p class="tightenable top bottom">102400 blocks <span><a href="2.html" class="named-wiki" title="2">2</a><u title="Empty link to: 2/1" onmouseover="window.status=&quot;Empty link to: 2/1&quot;; return true;" onmouseout="window.status='';return true;" class="named-wikiunknown">/1</u></span> <u title="Empty link to: U_" onmouseover="window.status=&quot;Empty link to: U_&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">U_</u></p>
</blockquote>
<p class="tightenable">This shows I have 2 md's known as md1 and md2. It also shows that I'm missing a hd. You can see this in the <span><a href="2.html" class="named-wiki" title="2">2</a><u title="Empty link to: 2/1" onmouseover="window.status=&quot;Empty link to: 2/1&quot;; return true;" onmouseout="window.status='';return true;" class="named-wikiunknown">/1</u></span> <u title="Empty link to: U_" onmouseover="window.status=&quot;Empty link to: U_&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">U_</u>. If the md was correct, it would show <span><a href="2.html" class="named-wiki" title="2">2</a><u title="Empty link to: 2/2" onmouseover="window.status=&quot;Empty link to: 2/2&quot;; return true;" onmouseout="window.status='';return true;" class="named-wikiunknown">/2</u></span> <u title="Empty link to: UU" onmouseover="window.status=&quot;Empty link to: UU&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">UU</u>. Fixing it is beyond this doc.</p>
<p class="tightenable">Sme automatically creates md's during installation, *even with only 1 disk. Here's how it stacks up:
1 disk: One-way RAID1 mirror
2 disks: Two-way RAID1 mirror
3-5 disks: RAID5
6+ disks: RAID6
NOTE: All disks must be the same size in 7.0</p>
<p class="tightenable">Previously, you would end here because your md's would be your boot, swap and root &quot;partitions.&quot; But not in v7. This is just the beginning.</p>
<p class="tightenable">Some md's are used at this level. md1 is the boot &quot;partition.&quot; It's not passed to lvm because you can't boot with lvm easily (yet). Some md's are passed to the lvm.</p>
<p class="tightenable">lvm stands for linux volume manager. This is the linux volume raid tool. It is a group of many of tools that manages volumes (as compared to a single tool). This whole lvm thing is hard for me to understand but basically I think of it as a raid for a raid. This only made sense for when going through an exercise. When the md's are passed on, lvm sees them as physical volume or pv's (which is interesting because in my mind the volumes aren't physical, they're logical). It's easier for me if I think of them as volume disks. You can view your pv's by:
--pvscan</p>
<dl><dt class="tightenable bottom">When I do this, I get</dt>
<dd class="tightenable top">PV /dev/md2   VG vg_primary   lvm2 <span><a href="74.41%20GB%20.html" class="named-wiki" title="74.41 GB ">74.41 GB </a><u title="Empty link to: 74.41 GB / 32.00 MB free" onmouseover="window.status=&quot;Empty link to: 74.41 GB / 32.00 MB free&quot;; return true;" onmouseout="window.status='';return true;" class="named-wikiunknown">/ 32.00 MB free</u></span>
Total: 1 <u title="Empty link to: 74.41 GB" onmouseover="window.status=&quot;Empty link to: 74.41 GB&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">74.41 GB</u> / in use: 1 <u title="Empty link to: 74.41 GB" onmouseover="window.status=&quot;Empty link to: 74.41 GB&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">74.41 GB</u> / in no VG: 0 <u title="Empty link to: 0" onmouseover="window.status=&quot;Empty link to: 0&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">0</u></dd>
</dl>
<p class="tightenable">You can see a detail view of the pv by doing a:
--pvdisplay</p>
<dl><dt class="tightenable bottom">When I do this, I get</dt>
<dd class="tightenable top">--- Physical volume ---
PV Name               /dev/md2
VG Name               vg_primary
PV Size               74.41 GB / not usable 0
Allocatable           yes
PE Size (KByte)       32768
Total PE              2381
Free PE               1
Allocated PE          2380
PV UUID               kppa2F-77j7-l0VL-otIE-zeAn-9Cty-PX4qEm</dd>
</dl>
<p class="tightenable">Basically, the same info with a little extra details. You'll notice the pv name is: /dev/md2.</p>
<p class="tightenable">Physical volumes are then grouped together to create volume groups or vg's (this is that raid on raid thing because you are grouping raids together). It's easier for me if I thing of them as volume raids. To make things simple, in this example we only have 1 pv so sme doesn't group anything together. It just uses the 1 pv as the vg. You can view your vg's by doing a:
--vgscan</p>
<dl><dt class="tightenable bottom">When I do this, I get</dt>
<dd class="tightenable top">Reading all physical volumes.  This may take a while...
Found volume group &quot;vg_primary&quot; using metadata type lvm2</dd>
</dl>
<p class="tightenable">You can see a detail view of the vg by doing a:
--vgdisplay</p>
<dl><dt class="tightenable bottom">When I do this, I get</dt>
<dd class="tightenable top">--- Volume group ---
VG Name               vg_primary
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               74.41 GB
PE Size               32.00 MB
Total PE              2381
Alloc PE / Size       2380 / 74.38 GB
Free  PE / Size       1 / 32.00 MB
VG UUID               aUVYMh-vIud-5rKK-PJJU-6goM-lELz-CY2u67</dd>
</dl>
<p class="tightenable">Once again, basically the same info with a little extra details. You'll notice the vg name is: vg_primary</p>
<p class="tightenable">Volume groups are then broken up into logical volumes or lv's. It's easier for me if I think of them as volume partitions. You can view your lv's by doing a:
--lvscan</p>
<dl><dt class="tightenable bottom">When I do this, I get</dt>
<dd class="tightenable top">ACTIVE            '/dev/vg_primary/lv_root' <u title="Empty link to: 73.62 GB" onmouseover="window.status=&quot;Empty link to: 73.62 GB&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">73.62 GB</u> inherit
ACTIVE            '/dev/vg_primary/lv_swap' <u title="Empty link to: 768.00 MB" onmouseover="window.status=&quot;Empty link to: 768.00 MB&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">768.00 MB</u> inherit</dd>
</dl>
<p class="tightenable">You can see a detail view of the lv by doing a:
--lvdisplay</p>
<dl><dt class="tightenable bottom">When I do this, I get</dt>
<dd class="tightenable top"><p class="tightenable top bottom">--- Logical volume ---
LV Name                /dev/vg_primary/lv_root
VG Name                vg_primary
LV UUID                KVKgor-3s4Z-L2ML-V8Yq-<u title="Empty link to: YwQg" onmouseover="window.status=&quot;Empty link to: YwQg&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">YwQg</u>-JzZY-0Rd8P2
LV Write Access        read/write
LV Status              available</p>
<ul><li class="tightenable top bottom">open                 1</li>
</ul>
<p class="tightenable top">LV Size                73.62 GB
Current LE             2356
Segments               1
Allocation             inherit
Read ahead sectors     0
Block device           253:0</p>
<p class="tightenable bottom">--- Logical volume ---
LV Name                /dev/vg_primary/lv_swap
VG Name                vg_primary
LV UUID                F1LZFK-<u title="Empty link to: DqJy" onmouseover="window.status=&quot;Empty link to: DqJy&quot;; return true;" onmouseout="window.status='';return true;" class="wikiunknown">DqJy</u>-eDim-cf1M-F7RP-Z3KV-Gs4Zq1
LV Write Access        read/write
LV Status              available</p>
<ul><li class="tightenable top bottom">open                 1</li>
</ul>
<p class="tightenable top bottom">LV Size                768.00 MB
Current LE             24
Segments               1
Allocation             inherit
Read ahead sectors     0
Block device           253:1</p>
</dd>
</dl>
<p class="tightenable">Once again, basically the same info with a little extra details. You'll notice the lv names are: lv_root &amp; lv_swap</p>
<ul><li class="tightenable bottom">OVERVIEW</li>
</ul>
<p class="tightenable top">Here's an visual overview for people who learn by seeing.
You can see in the crude diagram below we still end up with our boot, swap and root.</p>
<blockquote class="tightenable"><p class="tightenable top bottom">hda1   hdc1</p>
<blockquote class="tightenable top bottom"><blockquote class="tightenable top bottom"><p class="tightenable top bottom">\   /</p>
<blockquote class="tightenable top bottom"><p class="tightenable top bottom">\ /</p>
</blockquote>
</blockquote>
<p class="tightenable top bottom">md1 &amp; md2</p>
<blockquote class="tightenable top bottom"><p class="tightenable top bottom">|     |</p>
</blockquote>
<p class="tightenable top bottom">boot  pv (named: /dev/md2)</p>
<blockquote class="tightenable top bottom"><blockquote class="tightenable top bottom"><blockquote class="tightenable top bottom"><blockquote class="tightenable top bottom"><p class="tightenable top bottom">|
|</p>
</blockquote>
<p class="tightenable top bottom">vg (named: vg_primary)
/\</p>
</blockquote>
<p class="tightenable top bottom">/  \</p>
</blockquote>
<p class="tightenable top bottom">/    \</p>
</blockquote>
<p class="tightenable top bottom">lv_root  lv_swap</p>
</blockquote>
</blockquote>
<ul><li class="tightenable bottom">WHY I WOULD WANT THIS</li>
</ul>
<p class="tightenable top">You can add, remove, grow or reduce lv's on the fly! It's kinda like using partition magic or qparted without having to pull your system off-line.
Secondly, lvm is in Centos and Sme. If you run into a problem, the info may help you figure out why.</p>
<ul><li class="tightenable bottom">DEFINITIONS (from base to top)</li>
</ul>
<p class="tightenable top">mdadm (multiple device administration)  =a single tool to manage disks</p>
<p class="tightenable">lvm (linux volume manager)              =a group of tools to manage volumes</p>
<p class="tightenable">hd (hard disk)                          =a hard disk or hard drive (you'll see why this is spelled out later).</p>
<p class="tightenable">md (mulitple device)                    =better known as a raid. This is a group of hd's (partitions actually) in a raid config.</p>
<p class="tightenable">pv (physical volume)                    =a multiple device or md as seen in lvm. I think of this as volume disks.</p>
<p class="tightenable">vg (volume group)                             =a group of pv's together. I think of this as a volume raid.</p>
<p class="tightenable">lv (logical volume)                     =a section of a lv. I think of this as a volume partition.</p>
<ul><li class="tightenable bottom">LINKS</li>
</ul>
<p class="tightenable top"><a href="http://www.tldp.org/HOWTO/LVM-HOWTO" target="" class="namedurl"><span style="white-space: nowrap"><img src="images/http.png" alt="" class="linkicon" border="0" />http://www.tldp.org/HOWTO/LVM-HOWTO</span></a></p>
<p class="tightenable bottom"><a href="http://www.linuxdevcenter.com/pub/a/linux/2006/04/27/managing-disk-space-with-lvm.html?page=1" target="" class="namedurl"><span style="white-space: nowrap"><img src="images/http.png" alt="" class="linkicon" border="0" />http://www.linuxdevcenter.com/pub/a/linux/2006/04/27/managing-disk-space-with-lvm.html?page=1</span></a></p>
</div>

<div id="footer">  <hr class="printer" noshade="noshade" />
<p class="editdate">Owner: &quot;kruhm&quot;  Last edited on June 11, 2006  8:36 am by &quot;kruhm&quot;</p>
</div>

</div>
<!-- Add your Disclaimer here -->
</body>
</html>
