<?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>Sysadmandine</title>
	<atom:link href="http://amandine.aupetit.info/feed/" rel="self" type="application/rss+xml" />
	<link>http://amandine.aupetit.info</link>
	<description>One day, sysadmins will rule the world...</description>
	<lastBuildDate>Mon, 07 May 2012 21:08:14 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Sticky bit</title>
		<link>http://amandine.aupetit.info/220/sticky-bit/</link>
		<comments>http://amandine.aupetit.info/220/sticky-bit/#comments</comments>
		<pubDate>Fri, 04 May 2012 17:33:22 +0000</pubDate>
		<dc:creator>Amandine</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[access rights]]></category>
		<category><![CDATA[linux filesystem]]></category>
		<category><![CDATA[sticky bit]]></category>

		<guid isPermaLink="false">http://amandine.aupetit.info/?p=220</guid>
		<description><![CDATA[I recently had an interview in which I got asked about the sticky bit. Honnestly, I can&#8217;t remember what this is. Of course I know it has something to do with access rights on a Linux filesystem, and I remember having checked Wikipedia or man at least 10 times about it but it just doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had an interview in which I got asked about the <strong>sticky bit</strong>. Honnestly, I can&#8217;t remember what this is. Of course I know it has something to do with access rights on a Linux filesystem, and I remember having checked Wikipedia or man at least 10 times about it but it just doesn&#8217;t stick in my head. So I&#8217;ll try to dig a little in its behaviour to make it stay up there !</p>
<p><strong>How to set it</strong></p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">chmod</span> +t somefile-or-dir<br />
<span style="color: #c20cb9; font-weight: bold;">chmod</span> 1xxx somefile-or-dir</div></div>
<p><strong>Let&#8217;s play</strong><br />
I created 2 directories and 2 files, one with sticky bit set and one without for each type:<br />
<span id="more-220"></span></p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">drwxrwxr-x &nbsp;<span style="color: #000000;">2</span> amandine amgrp <span style="color: #000000;">4</span>,0K <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">20</span> dirWithoutStickyBit<br />
drwxrwxr-t &nbsp;<span style="color: #000000;">2</span> amandine amgrp <span style="color: #000000;">4</span>,0K <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">20</span> dirWithStickyBit<br />
<span style="color: #660033;">-rw-rw-r-T</span> &nbsp;<span style="color: #000000;">1</span> amandine amgrp &nbsp; &nbsp;<span style="color: #000000;">0</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">20</span> fileWithStickyBit<br />
<span style="color: #660033;">-rw-rw-r--</span> &nbsp;<span style="color: #000000;">1</span> amandine amgrp &nbsp; &nbsp;<span style="color: #000000;">0</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">20</span> fileWithoutStickyBit</div></div>
<p>First I noticed that the sticky bit on the directory is shown as &#8220;t&#8221; in place of the last x, and as &#8220;T&#8221; for the file. Maybe it&#8217;s because the file isn&#8217;t world executable? Let&#8217;s verify that :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">amandine$ </span><span style="color: #c20cb9; font-weight: bold;">chmod</span> +x fileWithStickyBit<br />
<span style="color: #666666;">amandine$ </span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lah</span><br />
drwxrwxr-x &nbsp;<span style="color: #000000;">2</span> amandine amgrp <span style="color: #000000;">4</span>,0K <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">20</span> dirWithoutStickyBit<br />
drwxrwxr-t &nbsp;<span style="color: #000000;">2</span> amandine amgrp <span style="color: #000000;">4</span>,0K <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">20</span> dirWithStickyBit<br />
<span style="color: #660033;">-rwxrwxr-t</span> &nbsp;<span style="color: #000000;">1</span> amandine amgrp &nbsp; &nbsp;<span style="color: #000000;">0</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">20</span> fileWithStickyBit<br />
<span style="color: #660033;">-rw-rw-r-x</span> &nbsp;<span style="color: #000000;">1</span> amandine amgrp &nbsp; &nbsp;<span style="color: #000000;">0</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">20</span> fileWithoutStickyBit</div></div>
<p>Ok, so &#8220;T&#8221; means sticky bit on but world executable off, &#8220;t&#8221; means both on.</p>
<p>The user &#8220;amandine&#8221; owns everything, and both users &#8220;amandine&#8221; and &#8220;test&#8221; belong to &#8220;amgroup&#8221;. Of course &#8220;amandine&#8221; can delete, rename and edit everything. What about user &#8220;test&#8221; ?</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">test$ </span><span style="color: #c20cb9; font-weight: bold;">mv</span> dirWithoutStickyBit dirWithoutStickyBit2<br />
<span style="color: #666666;">test$ </span><span style="color: #c20cb9; font-weight: bold;">mv</span> dirWithStickyBit dirWithStickyBit2<br />
<span style="color: #666666;">test$ </span><span style="color: #c20cb9; font-weight: bold;">mv</span> fileWithoutStickyBit fileWithoutStickyBit2<br />
<span style="color: #666666;">test$ </span><span style="color: #c20cb9; font-weight: bold;">mv</span> fileWithStickyBit fileWithStickyBit2<br />
<span style="color: #666666;">test$ </span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; fileWithoutStickyBit2<br />
<span style="color: #666666;">test$ </span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #7a0874; font-weight: bold;">test</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; fileWithStickyBit2<br />
<span style="color: #666666;">test$ </span><span style="color: #c20cb9; font-weight: bold;">touch</span> dirWithoutStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file1<br />
<span style="color: #666666;">test$ </span><span style="color: #c20cb9; font-weight: bold;">touch</span> dirWithStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file1</div></div>
<p>Ok. Nothing different, &#8220;test&#8221; can do everything too. Did I miss the point?? Let&#8217;s play more.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;height:300px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">amandine$ </span><span style="color: #c20cb9; font-weight: bold;">touch</span> dirWithoutStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file2<br />
<span style="color: #666666;">amandine$ </span><span style="color: #c20cb9; font-weight: bold;">touch</span> dirWithStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file2<br />
<span style="color: #666666;">amandine$ </span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lah</span> <span style="color: #000000; font-weight: bold;">*</span><br />
<span style="color: #660033;">-rwxrwxr-x</span> <span style="color: #000000;">1</span> amandine amgrp &nbsp; &nbsp;<span style="color: #000000;">5</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">38</span> fileWithoutStickyBit2<br />
<span style="color: #660033;">-rwxrwxr-t</span> <span style="color: #000000;">1</span> amandine amgrp &nbsp; &nbsp;<span style="color: #000000;">5</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">38</span> fileWithStickyBit2<br />
<br />
dirWithoutStickyBit2:<br />
drwxrwxr-x <span style="color: #000000;">2</span> amandine amgrp &nbsp; &nbsp;<span style="color: #000000;">4</span>,0K <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">44</span> .<br />
drwxrwxrwx <span style="color: #000000;">4</span> amandine amandine <span style="color: #000000;">4</span>,0K <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">38</span> ..<br />
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">test</span> &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">test</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">43</span> file1<br />
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> amandine amandine &nbsp; &nbsp;<span style="color: #000000;">0</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">44</span> file2<br />
<br />
dirWithStickyBit2:<br />
drwxrwxr-t <span style="color: #000000;">2</span> amandine amgrp &nbsp; &nbsp;<span style="color: #000000;">4</span>,0K <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">44</span> .<br />
drwxrwxrwx <span style="color: #000000;">4</span> amandine amandine <span style="color: #000000;">4</span>,0K <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">38</span> ..<br />
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">test</span> &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">test</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">43</span> file1<br />
<span style="color: #660033;">-rw-r--r--</span> <span style="color: #000000;">1</span> amandine amandine &nbsp; &nbsp;<span style="color: #000000;">0</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">44</span> file2<br />
<br />
<span style="color: #666666;">amandine$ </span><span style="color: #c20cb9; font-weight: bold;">rm</span> dirWithoutStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file1<br />
rm: remove write-protected regular empty <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #ff0000;">'dirWithoutStickyBit2/file1'</span>? y<br />
<span style="color: #666666;">amandine$ </span><span style="color: #c20cb9; font-weight: bold;">rm</span> dirWithStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file1<br />
rm: remove write-protected regular empty <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #ff0000;">'dirWithStickyBit2/file1'</span>? y</div></div>
<p>Now with user &#8220;test&#8221; :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">test$ </span><span style="color: #c20cb9; font-weight: bold;">rm</span> dirWithoutStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file2<br />
rm: remove write-protected regular empty <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #ff0000;">'dirWithoutStickyBit2/file2'</span>? y<br />
<span style="color: #666666;">test$ </span><span style="color: #c20cb9; font-weight: bold;">rm</span> dirWithStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file2<br />
rm: remove write-protected regular empty <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #ff0000;">'dirWithStickyBit2/file2'</span>? y<br />
rm: cannot remove <span style="color: #ff0000;">'dirWithStickyBit2/file2'</span>: Permission denied</div></div>
<p>Ha! Here&#8217;s one difference! I can&#8217;t delete another&#8217;s user file in a sticky bit enabled directory.</p>
<p>What about editing :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;height:300px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">amandine$ </span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lah</span> <span style="color: #000000; font-weight: bold;">*</span><br />
<span style="color: #660033;">-rwxrwxr-x</span> <span style="color: #000000;">1</span> amandine amgrp &nbsp; &nbsp;<span style="color: #000000;">5</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">38</span> fileWithoutStickyBit2<br />
<span style="color: #660033;">-rwxrwxr-t</span> <span style="color: #000000;">1</span> amandine amgrp &nbsp; &nbsp;<span style="color: #000000;">5</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">38</span> fileWithStickyBit2<br />
<br />
dirWithoutStickyBit2:<br />
total 12K<br />
drwxrwxr-x <span style="color: #000000;">2</span> amandine amgrp &nbsp; &nbsp;<span style="color: #000000;">4</span>,0K <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">56</span> .<br />
drwxrwxrwx <span style="color: #000000;">4</span> amandine amandine <span style="color: #000000;">4</span>,0K <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">38</span> ..<br />
<span style="color: #660033;">-rw-rw-r--</span> <span style="color: #000000;">1</span> amandine amgrp &nbsp; &nbsp; &nbsp; <span style="color: #000000;">9</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">56</span> file3<br />
<br />
dirWithStickyBit2:<br />
total 12K<br />
drwxrwxr-t <span style="color: #000000;">2</span> amandine amgrp &nbsp; &nbsp;<span style="color: #000000;">4</span>,0K <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">56</span> .<br />
drwxrwxrwx <span style="color: #000000;">4</span> amandine amandine <span style="color: #000000;">4</span>,0K <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">38</span> ..<br />
<span style="color: #660033;">-rw-rw-r--</span> <span style="color: #000000;">1</span> amandine amgrp &nbsp; &nbsp; &nbsp; <span style="color: #000000;">9</span> <span style="color: #000000;">2012</span>-05-04 <span style="color: #000000;">16</span>:<span style="color: #000000;">56</span> file3<br />
<span style="color: #666666;">amandine$ </span><span style="color: #c20cb9; font-weight: bold;">cat</span> dirWithoutStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file3<br />
that<span style="color: #ff0000;">'s amandine'</span>s <span style="color: #c20cb9; font-weight: bold;">file</span><br />
<span style="color: #666666;">amandine$ </span><span style="color: #c20cb9; font-weight: bold;">cat</span> dirWithStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file3<br />
that<span style="color: #ff0000;">'s amandine'</span>s <span style="color: #c20cb9; font-weight: bold;">file</span><br />
<br />
<span style="color: #666666;">test$ </span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;no, that's test's file&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; dirWithoutStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file3<br />
<span style="color: #666666;">test$ </span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;no, that's test's file&quot;</span> <span style="color: #000000; font-weight: bold;">&amp;</span>gt; dirWithStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file3<br />
<span style="color: #666666;">test$ </span><span style="color: #c20cb9; font-weight: bold;">cat</span> dirWithoutStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file3<br />
no, that<span style="color: #ff0000;">'s test'</span>s <span style="color: #c20cb9; font-weight: bold;">file</span><br />
<span style="color: #666666;">test$ </span><span style="color: #c20cb9; font-weight: bold;">cat</span> dirWithStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file3<br />
no, that<span style="color: #ff0000;">'s test'</span>s <span style="color: #c20cb9; font-weight: bold;">file</span></div></div>
<p>&#8220;test&#8221; can still edit both files.</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">test$ </span><span style="color: #c20cb9; font-weight: bold;">mv</span> dirWithoutStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file3 dirWithoutStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file4<br />
<span style="color: #666666;">test$ </span><span style="color: #c20cb9; font-weight: bold;">mv</span> dirWithStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file3 dirWithStickyBit2<span style="color: #000000; font-weight: bold;">/</span>file4<br />
mv: cannot move <span style="color: #ff0000;">'dirWithStickyBit2/file3'</span> to <span style="color: #ff0000;">'dirWithStickyBit2/file4'</span>: Operation not permitted</div></div>
<p>but he can&#8217;t rename or delete them.</p>
<p>Ok for sticky bit on directories, but what&#8217;s the point of having a sticky bit switched on for a single file?</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">man</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span><br />
<span style="color: #7a0874; font-weight: bold;">&#91;</span>...<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
RESTRICTED DELETION FLAG OR STICKY BIT<br />
The restricted deletion flag or sticky bit is a single bit, whose<br />
interpretation depends on the <span style="color: #c20cb9; font-weight: bold;">file</span> type. &nbsp;For directories, it prevents<br />
unprivileged <span style="color: #c20cb9; font-weight: bold;">users</span> from removing or renaming a <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #000000; font-weight: bold;">in</span> the directory<br />
unless they own the <span style="color: #c20cb9; font-weight: bold;">file</span> or the directory; this is called the restricted<br />
deletion flag <span style="color: #000000; font-weight: bold;">for</span> the directory, and is commonly found on world-<br />
writable directories like <span style="color: #000000; font-weight: bold;">/</span>tmp. &nbsp;For regular files on some older<br />
systems, the bit saves the program<span style="color: #ff0000;">'s text image on the swap device<br />
so it will load more quickly when run; this is called the sticky bit.<br />
[...]</span></div></div>
<p>Ok, and on newer systems? Seems it&#8217;s just not used anymore on most systems :<br />
<a href="http://en.wikipedia.org/wiki/Sticky_bit Wikipedia"><em>From Wikipedia :</em> </a><br />
<strong>Linux</strong> : [...] the Linux kernel ignores the sticky bit on files. [...]<br />
<strong>*BSD</strong> : [...]The sticky bit can still be set on files, but without any effect.[...]<br />
<strong>MAC OS X</strong> : [...]the sticky bit has no effect on executable files[...]</p>
<p>except on solaris : [...] <strong>Solaris</strong> (as of Solaris 2.5) defines special behavior when the sticky bit is set on non-executable files: those files, when accessed, will not be cached by the kernel. This is usually set on swap files to prevent access on the file from flushing more important data from the system cache. [...]</p>
<p><strong>Summary</strong><br />
The sticky bit on a directory allows users to create and modify their own files in it, edit other&#8217;s files if they are allowed to, but not delete or rename other&#8217;s files even if the classic rights allows them to normally do it. Typical usage of the sticky bit is /tmp .</p>
<p><em>That wasn&#8217;t so hard to learn after all ! ;)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://amandine.aupetit.info/220/sticky-bit/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Apache2 Rewritemap</title>
		<link>http://amandine.aupetit.info/214/apache2-rewritemap/</link>
		<comments>http://amandine.aupetit.info/214/apache2-rewritemap/#comments</comments>
		<pubDate>Wed, 16 Feb 2011 17:24:52 +0000</pubDate>
		<dc:creator>Amandine</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[mod_rewrite]]></category>
		<category><![CDATA[rewrite]]></category>
		<category><![CDATA[rewritemap]]></category>

		<guid isPermaLink="false">http://amandine.aupetit.info/?p=214</guid>
		<description><![CDATA[I love apache mod_rewrite. I often fight with it, but if you really want it you can do whatever you want. This time I wanted to find a way to call a file named after the called subdomain. I have a website called www.yellow-sub.net, and there is some subdomains like the-beatles.yellow-sub.net, john-lennon.yellow-sub.net and so on [...]]]></description>
			<content:encoded><![CDATA[<p>I love apache mod_rewrite. I often fight with it, but if you really want it you can do whatever you want. This time I wanted to find a way to call a file named after the called subdomain. I have a website called www.yellow-sub.net, and there is some subdomains like the-beatles.yellow-sub.net, john-lennon.yellow-sub.net and so on for each part of the website (That&#8217;s a SEO consideration in the beginning). I have only one virtual host for that website because I find it easier to manage like that, and I didn&#8217;t want to put the logic in the files for some reasons (and because working with rewrite rules is fun). </p>
<p>This is what I want :</p>
<ul>
<li>you call -> you get</li>
<li>www.yellow-sub.net -> index.php?page=somepage</li>
<li>the-beatles.yellow-sub.net -> index.php?page=somepage-the-beatles</li>
<li>blahblah.yellow-sub.net -> index.php?page=somepage-blahblah</li>
</ul>
<p>The page parameter will in fact call a different page with name &#8220;somepage-blahblah.html&#8221;, and I wanted it to work for every single subdomain (if it doesn&#8217;t exist it will anyway be redirected to www home page)</p>
<p>The closest way I found was to use %{HTTP_HOST} in my rewriterule :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>HTTP_HOST<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">!</span>^www\.yellow-sub\.net$ <span style="color: #7a0874; font-weight: bold;">&#91;</span>NC<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
RewriteRule ^<span style="color: #000000; font-weight: bold;">/</span>$ <span style="color: #000000; font-weight: bold;">/</span>index.php?<span style="color: #007800;">page</span>=somepage-<span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>HTTP_HOST<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>L<span style="color: #7a0874; font-weight: bold;">&#93;</span></div></div>
<p><span id="more-214"></span><br />
But this way I had to name my files somepage-the-beatles.yellow-sub.net.html instead of somepage-the-beatles.html, wich is not so bad but quite annoying when I want to copy that from beta (different domain name) to live or from live to beta. </p>
<p>So I found the Rewritemap parameter in the apache documentation website. And That&#8217;s just an amazing new feature I didn&#8217;t know about : it will let you do whatever you want with your rewrite rules! I let you read the manual page, It&#8217;s well written and I won&#8217;t explain something already well explained : <a href="http://httpd.apache.org/docs/current/en/mod/mod_rewrite.html#rewritemap">See that Rewritemap doc</a></p>
<p>I used the last MapType : External Rewriting Program that allows you to write your own script in whatever programming language you fancy, taking stdin and writing to stdout. Mine is very simple, in bash :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/bash</span><br />
<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line; <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$line</span> <span style="color: #000000; font-weight: bold;">|</span><span style="color: #c20cb9; font-weight: bold;">cut</span> -d. <span style="color: #660033;">-f1</span><br />
<span style="color: #000000; font-weight: bold;">done</span>;</div></div>
<p>I guess that&#8217;s a good practive to Keep It Simple, Stupid, as advised in the manual, cause it will be running as apache child, not called when needed. You can test it by giving it something to process :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #7a0874; font-weight: bold;">echo</span> the-beatles.yellow-sub.net <span style="color: #000000; font-weight: bold;">|/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>subdomain.sh <br />
the-beatles</div></div>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>subdomain.sh<br />
blabla.yellow-sub.net <span style="color: #666666; font-style: italic;"># this is what I wrote</span><br />
blabla <span style="color: #666666; font-style: italic;"># this is what he said</span><br />
hgzsfver.erg.erg.reg.ezefg &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
hgzsfver<br />
^C</div></div>
<p>To use it in you Virtualhost section :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Rewritemap subdomain prg:<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>subdomain.sh<br />
RewriteCond <span style="color: #000000; font-weight: bold;">%</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>HTTP_HOST<span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #000000; font-weight: bold;">!</span>^www\.yellow-sub\.net$ <span style="color: #7a0874; font-weight: bold;">&#91;</span>NC<span style="color: #7a0874; font-weight: bold;">&#93;</span><br />
RewriteRule ^<span style="color: #000000; font-weight: bold;">/</span>$ <span style="color: #000000; font-weight: bold;">/</span>index.php?<span style="color: #007800;">page</span>=somepage-<span style="color: #800000;">${subdomain:%{HTTP_HOST}</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>L<span style="color: #7a0874; font-weight: bold;">&#93;</span></div></div>
<p>Don&#8217;t be messy with the interesting part ${subdomain:%{HTTP_HOST}}, I sillily wrote a % instead of the $ and spent half an hour to figure it out! (no errors anywhere, the script was launched, it just didn&#8217;t work at all).</p>
<p>Reload apache to watch it running now :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp;xxxx ? &nbsp; &nbsp; &nbsp; &nbsp;Ss &nbsp; &nbsp; <span style="color: #000000;">0</span>:00 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2 <span style="color: #660033;">-k</span> start<br />
xxxxx ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span>:00 &nbsp;\_ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2 <span style="color: #660033;">-k</span> start<br />
xxxxx ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span>:00 &nbsp;\_ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2 <span style="color: #660033;">-k</span> start<br />
xxxxx ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span>:08 &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; \_ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php5-cgi<br />
xxxxx ? &nbsp; &nbsp; &nbsp; &nbsp;Ss &nbsp; &nbsp; <span style="color: #000000;">0</span>:00 &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; \_ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php5-cgi<br />
xxxxx ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span>:02 &nbsp;<span style="color: #000000; font-weight: bold;">|</span> &nbsp; <span style="color: #000000; font-weight: bold;">|</span> &nbsp; \_ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php5-cgi<br />
xxxxx ? &nbsp; &nbsp; &nbsp; &nbsp;S &nbsp; &nbsp; &nbsp;<span style="color: #000000;">0</span>:00 &nbsp;\_ <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>apache2<span style="color: #000000; font-weight: bold;">/</span>scripts<span style="color: #000000; font-weight: bold;">/</span>subdomain.sh<br />
xxxxx ? &nbsp; &nbsp; &nbsp; &nbsp;Sl &nbsp; &nbsp; <span style="color: #000000;">0</span>:<span style="color: #000000;">46</span> &nbsp;\_ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2 <span style="color: #660033;">-k</span> start<br />
xxxxx ? &nbsp; &nbsp; &nbsp; &nbsp;Sl &nbsp; &nbsp; <span style="color: #000000;">0</span>:<span style="color: #000000;">48</span> &nbsp;\_ <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>apache2 <span style="color: #660033;">-k</span> start</div></div>
<p>You can watch it in action using the Rewritelog :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xxx.xxx.xxx.xxx - - <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">17</span><span style="color: #000000; font-weight: bold;">/</span>Feb<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2011</span>:08:<span style="color: #000000;">39</span>:<span style="color: #000000;">50</span> +0100<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>the-beatles.yellow-sub.net<span style="color: #000000; font-weight: bold;">/</span>sid<span style="color: #666666; font-style: italic;">#c85408][rid#1017528/initial] (5) map lookup OK: map=subdomain key=the-beatles.yellow-sub.net -&gt; val=the-beatles</span></div></div>
<p>And now my files are just called the way I wanted to :)<br />
I have to say, I love this feature more because I can imagine a lot of new functions in my rewriterules than because it solved my problem, for which I had other options anyway (not as sexy ones, but solutions though.)</p>
<p>The question now is : it is safe? What are the risks of using such a script within apache? If you have anything to say about that, please tell me :)</p>
<p>Have fun with mod_rewrite!</p>
]]></content:encoded>
			<wfw:commentRss>http://amandine.aupetit.info/214/apache2-rewritemap/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to resolv .42 domains</title>
		<link>http://amandine.aupetit.info/208/how-to-resolv-42-domains/</link>
		<comments>http://amandine.aupetit.info/208/how-to-resolv-42-domains/#comments</comments>
		<pubDate>Wed, 29 Dec 2010 20:21:36 +0000</pubDate>
		<dc:creator>Amandine</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[42registry]]></category>
		<category><![CDATA[bind]]></category>
		<category><![CDATA[dns]]></category>

		<guid isPermaLink="false">http://amandine.aupetit.info/?p=208</guid>
		<description><![CDATA[I&#8217;m sure you heard of the new unofficial domain registry 42registry, who let you register domains like something.42. If you didn&#8217;t, go on there website and read, cause I found this very interesting, funny, and it made me want to try :)
So, after registering sysadmandine.42 domain name, I tried to surf on it. But I [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m sure you heard of the new unofficial domain registry 42registry, who let you register domains like something.42. If you didn&#8217;t, go on there website and read, cause I found this very interesting, funny, and it made me want to try :)</p>
<p>So, after registering <a href="http://www.sysadmandine.42">sysadmandine.42</a> domain name, I tried to surf on it. But I didn&#8217;t want to spend time to configure a secured but open bind on one of my servers, so I opted for the easy way : my local computer is on Ubuntu, Ubuntu is perfectly able to provide me a bind, so let&#8217;s go :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> bind9</div></div>
<p><span id="more-208"></span><br />
Then one line of config like they say on the <a href="http://www.42registry.org/">42registry</a> website :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>bind<span style="color: #000000; font-weight: bold;">/</span>named.conf.default-zones</div></div>
<p>add :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">zone <span style="color: #ff0000;">&quot;42&quot;</span> IN <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
<span style="color: #7a0874; font-weight: bold;">type</span> forward;<br />
forwarders <span style="color: #7a0874; font-weight: bold;">&#123;</span>91.191.147.246; 91.191.147.243; 79.143.243.129; 178.20.71.2; 217.174.201.33; 83.169.77.115;<span style="color: #7a0874; font-weight: bold;">&#125;</span>;<br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span></div></div>
<p>restart bind (surprisingly, just reload didn&#8217;t do it) :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>bind9 restart</div></div>
<p>Check that it&#8217;s working :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">dig</span> <span style="color: #000000; font-weight: bold;">@</span>localhost www.sysadmandine.42</div></div>
<p>(you have to see a ANSWER section id it&#8217;s working)</p>
<p>And then tell your system to use it :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">vim</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>resolv.conf</div></div>
<p>Put this on the first line :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">nameserver 127.0.0.1</div></div>
<p>That&#8217;s it ! Now you just have to open your firefox or any other browser (be careful with chrome or chromium though, ther&#8217;s a trick to make it work with those ones, check the <a href="http://www.42registry.org/">42registry</a> website to know how.), and try some domains !<br />
* <a href="http://www.sysadmandine.42/">http://www.sysadmandine.42/</a> (of course)<br />
* <a href="http://nic.42/">http://nic.42/</a><br />
* I couldn&#8217;t find more websites in .42, do you know some?</p>
]]></content:encoded>
			<wfw:commentRss>http://amandine.aupetit.info/208/how-to-resolv-42-domains/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Add disk space to a .img disk image (for use with xen for example)</title>
		<link>http://amandine.aupetit.info/187/add-disk-space-to-a-img-disk-image-for-use-with-xen-for-example/</link>
		<comments>http://amandine.aupetit.info/187/add-disk-space-to-a-img-disk-image-for-use-with-xen-for-example/#comments</comments>
		<pubDate>Fri, 13 Aug 2010 08:27:41 +0000</pubDate>
		<dc:creator>Amandine</dc:creator>
				<category><![CDATA[Sysadmin]]></category>

		<guid isPermaLink="false">http://amandine.aupetit.info/?p=187</guid>
		<description><![CDATA[Sometimes, you need more space on a virtual machine disk than you thought in the beginning. Hopefully, if your domU disk is in a .img file, you can do it quite easily (you can do it easily with lvm partition too, even if it&#8217;s a different method). Here&#8217;s how to do it, as root of [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes, you need more space on a virtual machine disk than you thought in the beginning. Hopefully, if your domU disk is in a .img file, you can do it quite easily (you can do it easily with lvm partition too, even if it&#8217;s a different method). Here&#8217;s how to do it, as root of course :</p>
<p>- Check your partitions in your domU :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">df</span> <span style="color: #660033;">-h</span><br />
Filesystem &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Size &nbsp;Used Avail Use<span style="color: #000000; font-weight: bold;">%</span> Mounted on<br />
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xvda2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10G &nbsp;706M &nbsp;8.8G &nbsp; <span style="color: #000000;">8</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span><br />
varrun &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2.1G &nbsp; 44K &nbsp;2.1G &nbsp; <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<br />
varlock &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.1G &nbsp; &nbsp; <span style="color: #000000;">0</span> &nbsp;2.1G &nbsp; <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<br />
udev &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2.1G &nbsp; 16K &nbsp;2.1G &nbsp; <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>dev<br />
devshm &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2.1G &nbsp; &nbsp; <span style="color: #000000;">0</span> &nbsp;2.1G &nbsp; <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>shm</div></div>
<p>- create empty file of the size we want to add : (10gb here)</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">if</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>zero <span style="color: #007800;">of</span>=<span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>temp_expand <span style="color: #007800;">bs</span>=1024k <span style="color: #007800;">count</span>=<span style="color: #000000;">10000</span></div></div>
<p><span id="more-187"></span><br />
- stop your domU</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xm shutdown mydomU</div></div>
<p>- backup img files</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-a</span> <span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>mydomU <span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>mydomU-bak</div></div>
<p>- add the empty file to the img file :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>temp_expand <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>mydomU<span style="color: #000000; font-weight: bold;">/</span>disk.img</div></div>
<p><em>You can repeat this step as many times as you need</em></p>
<p>- tell the filesystem to check and adapt its size :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">resize2fs <span style="color: #660033;">-f</span> <span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>mydomU<span style="color: #000000; font-weight: bold;">/</span>disk.img</div></div>
<p>- restart your domU</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">xm create <span style="color: #660033;">-c</span> mydomU.cfg</div></div>
<p>- check in your domU that everything is ok</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">df</span> <span style="color: #660033;">-h</span><br />
Filesystem &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Size &nbsp;Used Avail Use<span style="color: #000000; font-weight: bold;">%</span> Mounted on<br />
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xvda2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 30G &nbsp;711M &nbsp; 28G &nbsp; <span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span><br />
varrun &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2.1G &nbsp; 44K &nbsp;2.1G &nbsp; <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<br />
varlock &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.1G &nbsp; &nbsp; <span style="color: #000000;">0</span> &nbsp;2.1G &nbsp; <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<br />
udev &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2.1G &nbsp; 20K &nbsp;2.1G &nbsp; <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>dev<br />
devshm &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2.1G &nbsp; &nbsp; <span style="color: #000000;">0</span> &nbsp;2.1G &nbsp; <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>shm</div></div>
<p>Voila! Your disk is now bigger :)</p>
<p>You can also use this method to create a brand new blank disk image, and add it as a new disk for you domU :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;">if</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>zero <span style="color: #007800;">of</span>=<span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>mydomU<span style="color: #000000; font-weight: bold;">/</span>otherdisk.img <span style="color: #007800;">bs</span>=1024k <span style="color: #007800;">count</span>=<span style="color: #000000;">150000</span></div></div>
<p>or</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>temp_expand <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>mydomU<span style="color: #000000; font-weight: bold;">/</span>otherdisk.img</div></div>
<p>add the new disk (xvda3) to your /etc/xen/mydomU.cfg :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">disk &nbsp; &nbsp; &nbsp; &nbsp;= <span style="color: #7a0874; font-weight: bold;">&#91;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'tap:aio:/xen/domains/mydomU/swap.img,xvda1,w'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'tap:aio:/xen/domains/mydomU/disk.img,xvda2,w'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">'tap:aio:/xen/domains/mydomU/otherdisk.img,xvda3,w'</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">&#93;</span></div></div>
<p>after rebooting you domU, check if the new disk is available :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">fdisk <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xvda3 <br />
<br />
Disk <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xvda3: <span style="color: #000000;">125.8</span> GB, <span style="color: #000000;">125829120000</span> bytes<br />
<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;">15297</span> cylinders<br />
Units = cylinders of <span style="color: #000000;">16065</span> <span style="color: #000000; font-weight: bold;">*</span> <span style="color: #000000;">512</span> = <span style="color: #000000;">8225280</span> bytes<br />
Disk identifier: 0x00000000<br />
<br />
Disk <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xvda3 doesn<span style="color: #ff0000;">'t contain a valid partition table</span></div></div>
<p>You&#8217;re now free to create your filesystem on this disk, and to mount it wherever you want!</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ mkfs.ext3 <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xvda3<br />
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mysql<br />
$ <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xvda3 <span style="color: #000000; font-weight: bold;">/</span>mysql<span style="color: #000000; font-weight: bold;">/</span><br />
$ <span style="color: #c20cb9; font-weight: bold;">df</span> <span style="color: #660033;">-h</span><br />
Filesystem &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Size &nbsp;Used Avail Use<span style="color: #000000; font-weight: bold;">%</span> Mounted on<br />
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xvda2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 30G &nbsp;711M &nbsp; 28G &nbsp; <span style="color: #000000;">3</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span><br />
varrun &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2.1G &nbsp; 44K &nbsp;2.1G &nbsp; <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<br />
varlock &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2.1G &nbsp; &nbsp; <span style="color: #000000;">0</span> &nbsp;2.1G &nbsp; <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<br />
udev &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2.1G &nbsp; 20K &nbsp;2.1G &nbsp; <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>dev<br />
devshm &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;2.1G &nbsp; &nbsp; <span style="color: #000000;">0</span> &nbsp;2.1G &nbsp; <span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>shm<br />
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>xvda3 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;117G &nbsp;188M &nbsp;111G &nbsp; <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #000000; font-weight: bold;">/</span>mysql</div></div>
<p><em>This Howto was made under Ubuntu Hardy, Xen 3.2</em></p>
]]></content:encoded>
			<wfw:commentRss>http://amandine.aupetit.info/187/add-disk-space-to-a-img-disk-image-for-use-with-xen-for-example/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Apache2 mod_rewrite and %{REQUEST_FILENAME}</title>
		<link>http://amandine.aupetit.info/135/apache2-mod_rewrite/</link>
		<comments>http://amandine.aupetit.info/135/apache2-mod_rewrite/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 20:33:50 +0000</pubDate>
		<dc:creator>Amandine</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[apache2]]></category>
		<category><![CDATA[rewrite]]></category>

		<guid isPermaLink="false">http://amandine.aupetit.info/?p=135</guid>
		<description><![CDATA[I&#8217;m trying to develop a new website to increase my php object oriented skills. For this new website, I want every request for any url that doesn&#8217;t match a actual file on the disk to be redirected to index.php (to handle parameters in fact). Easy with apache2 rewrite rules :
&#160; &#160; &#160; &#160; &#160;RewriteCond %{REQUEST_FILENAME} [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m trying to develop a new website to increase my php object oriented skills. For this new website, I want every request for any url that doesn&#8217;t match a actual file on the disk to be redirected to index.php (to handle parameters in fact). Easy with apache2 rewrite rules :</p>
<div class="codecolorer-container apache default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-f<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-d<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">RewriteCond</span> %{REQUEST_FILENAME} !-l &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">RewriteRule</span> ^/(.*)$ &nbsp; &nbsp; &nbsp; &nbsp; /index.php?rt=$1 [L,QSA]</div></div>
<p>This means : if the requested file is not a real file, and isn&#8217;t a directory, and isn&#8217;t a symlink, then redirect to index.php.</p>
<p>I was really surprised to discover that it doesn&#8217;t work. Though, everybody seems to use this syntax ! I checked my apache version : Apache/2.2.9 (Debian), nothing special with this one I guess.<br />
To understand what Apache was doing with my rewrites, I activated the rewrite log :</p>
<div class="codecolorer-container apache default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">RewriteLog</span> /var/log/apache2/rewrite.log &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">RewriteLogLevel</span> <span style="color: #ff0000;">5</span></div></div>
<p><span id="more-135"></span><br />
Here&#8217;s what I got (the interesting part, cause I got a looot more !) :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[blah blah blah] (2) init rewrite engine with requested uri /toto.htm<br />
[blah blah blah] (3) applying pattern '^/(.*)$' to uri '/toto.htm'<br />
[blah blah blah] (4) RewriteCond: input='/toto.htm' pattern='!-f' =&gt; matched<br />
[blah blah blah] (4) RewriteCond: input='/toto.htm' pattern='!-d' =&gt; matched<br />
[blah blah blah] (4) RewriteCond: input='/toto.htm' pattern='!-l' =&gt; matched<br />
[blah blah blah] (2) rewrite '/toto.htm' -&gt; '/index.php?rt=toto.htm'</div></div>
<p>So apaches verifies only &#8216;/toto.htm&#8217; and not the whole path for &#8220;%{REQUEST_FILENAME}&#8221;? I thought though it was the whole path&#8230; let&#8217;s verify in the doc.<br />
From <a href="http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html">http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html</a>, by habit (cause I used apache 2.0 a lot more than apache 2.2 from now on) :</p>
<blockquote><p>REQUEST_FILENAME : The full local filesystem path to the file or script matching the request.</p></blockquote>
<p>Hmm. But I use apache version 2.2, so what do they say here <a href="http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html">http://httpd.apache.org/docs/2.2/mod/mod_rewrite.html</a> :</p>
<blockquote><p>REQUEST_FILENAME : The full local filesystem path to the file or script matching the request, if this has already been determined by the server at the time REQUEST_FILENAME is referenced. Otherwise, such as when used in virtual host context, the same value as REQUEST_URI.</p></blockquote>
<p>Ow. </p>
<blockquote><p>REQUEST_URI : The resource requested in the HTTP request line. (In the example above, this would be &#8220;/index.html&#8221;.)</p></blockquote>
<p>Ok, I understand, I use virtual hosts (like everybody, uh?), so the real syntax for my needs is :</p>
<div class="codecolorer-container apache default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">RewriteCond</span> %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">RewriteCond</span> %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">RewriteCond</span> %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-l &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00007f;">RewriteRule</span> ^/(.*)$ &nbsp; &nbsp; &nbsp; &nbsp; /index.php?rt=$1 [L,QSA]</div></div>
<p>This works even if it doubles the &#8220;/&#8221; between each variable (one / at the end of DOCUMENT_ROOT, and another at the beginning of REQUEST_FILENAME).</p>
<p>Here&#8217;s the rewrite log showing that it works :</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">[blah blah blah] (2) init rewrite engine with requested uri /toto.htm &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
[blah blah blah] (3) applying pattern '^/(.*)$' to uri '/toto.htm'<br />
[blah blah blah] (4) RewriteCond: input='/path/to/documentroot//toto.htm' pattern='!-f' =&gt; not-matched<br />
[blah blah blah] (1) pass through /toto.htm</div></div>
<p>Now I can disable this log if I want to keep space on my disk.<br />
<em><br />
I must admit I read the description for REQUEST_FILENAME in apache2.2 several times before noticing that it was just the answer&#8230; too used to read too fast! Thanks to <a href="http://mail-archives.apache.org/mod_mbox/httpd-users/200301.mbox/%3C20030120173115.GA19713@boost.horde.net%3E">this old post</a> that made me re-read slower ! ;)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://amandine.aupetit.info/135/apache2-mod_rewrite/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My top 20 linux favourite commands</title>
		<link>http://amandine.aupetit.info/131/my-top-20-linux-favourite-commands/</link>
		<comments>http://amandine.aupetit.info/131/my-top-20-linux-favourite-commands/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 21:38:57 +0000</pubDate>
		<dc:creator>Amandine</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[aptitude]]></category>
		<category><![CDATA[awk]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[dstat]]></category>
		<category><![CDATA[fdisk]]></category>
		<category><![CDATA[grep]]></category>
		<category><![CDATA[host]]></category>
		<category><![CDATA[kill]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mdadm]]></category>
		<category><![CDATA[mtr]]></category>
		<category><![CDATA[netstat]]></category>
		<category><![CDATA[nmap]]></category>
		<category><![CDATA[ps]]></category>
		<category><![CDATA[screen]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[sfdisk]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tcpdump]]></category>
		<category><![CDATA[telnet]]></category>
		<category><![CDATA[vim]]></category>
		<category><![CDATA[xargs]]></category>

		<guid isPermaLink="false">http://amandine.aupetit.info/?p=131</guid>
		<description><![CDATA[Here&#8217;s my linux favourite commands, by type :
Scripting
1. egrep : aaah&#8230; if I had to keep only one, this would be the one I&#8217;d choose&#8230; can&#8217;t spend 10 minutes without using it.
2. sed : because I always need to replace something by something else 10 times on each line in huge files
3. xargs : helps [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s my linux favourite commands, by type :</p>
<p><strong>Scripting</strong><br />
1. egrep : aaah&#8230; if I had to keep only one, this would be the one I&#8217;d choose&#8230; can&#8217;t spend 10 minutes without using it.<br />
2. sed : because I always need to replace something by something else 10 times on each line in huge files<br />
3. xargs : helps me avoid the for loop, shorter to write, easier to remember and understand when you find it in history<br />
4. awk : for me the most difficult one to use, but I so know that it can do just what I want that I always take the time.<br />
<span id="more-131"></span><br />
<strong>System</strong><br />
5. kill : ha ha, makes me feel I&#8217;m powerful<br />
6. ps fauxww : makes me think I can watch everything that&#8217;s happening in real time. Like watching 10 movies at the same time.<br />
7. aptitude : I like his way of telling me everything of what he&#8217;s doing&#8230; so chatty !<br />
8. dstat : this one is really good : tells me a lot of things and with colors, I think he just knows what I&#8217;m looking for each time I call him.</p>
<p><strong>Network</strong><br />
9. ssh : is it necessary to say something about it? without him I&#8217;d be nothing.<br />
10. telnet : I like the raw output, no interpretation, he&#8217;s stupid and this is sometimes really appreciable<br />
11. host : simple tool for so great usefulness, even the basic usage is perfect<br />
12. nmap : I looove knowing everything about hosts I can&#8217;t access&#8230;<br />
13. tcpdump : really useful when you really dont understand what&#8217;s happening.<br />
14. netstat : nmap from the inside. Feels like a treasure hunt sometimes.<br />
15. mtr : seems just easy and fast, but also gives a lot of interesting information.</p>
<p><strong>Tools</strong><br />
16. vim : makes me save so much time<br />
17. screen : How did they live before screen? And I use only a small amount of its potential&#8230;</p>
<p><strong>Storage</strong><br />
18. fdisk : boring in the begenning, fun once you know it by heart<br />
19. sfdisk : really handy to mirror a disk partitionning scheme<br />
20. mdadm : I love mdadm. Just love it, don&#8217;t know why.</p>
]]></content:encoded>
			<wfw:commentRss>http://amandine.aupetit.info/131/my-top-20-linux-favourite-commands/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>htpasswd encryption</title>
		<link>http://amandine.aupetit.info/117/htpasswd-encryption/</link>
		<comments>http://amandine.aupetit.info/117/htpasswd-encryption/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 20:53:49 +0000</pubDate>
		<dc:creator>Amandine</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[crypt]]></category>
		<category><![CDATA[htpasswd]]></category>
		<category><![CDATA[password]]></category>
		<category><![CDATA[salt]]></category>

		<guid isPermaLink="false">http://amandine.aupetit.info/?p=117</guid>
		<description><![CDATA[I was wondering how crypt does the encryption of passwords. Once I needed to compare two .htpasswd files, I was quite sure that both had the same password for the same user, but the encrypted strings didn&#8217;t match. I tried to regenerate the encrypted string several times, and here&#8217;s what I got :
$ htpasswd -nb [...]]]></description>
			<content:encoded><![CDATA[<p>I was wondering how crypt does the encryption of passwords. Once I needed to compare two .htpasswd files, I was quite sure that both had the same password for the same user, but the encrypted strings didn&#8217;t match. I tried to regenerate the encrypted string several times, and here&#8217;s what I got :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ htpasswd <span style="color: #660033;">-nb</span> someuser somepwd<br />
someuser:qQD5GYrJQSIwk<br />
$ htpasswd <span style="color: #660033;">-nb</span> someuser somepwd<br />
someuser:zD9H4NFRuDjk6<br />
$ htpasswd <span style="color: #660033;">-nb</span> someuser somepwd<br />
someuser:IK572FjeWHPYw<br />
$ htpasswd <span style="color: #660033;">-nb</span> someuser somepwd<br />
someuser:O2UkOjX3ynZCU<br />
$ htpasswd <span style="color: #660033;">-nb</span> someuser somepwd<br />
someuser:9hPT7IR<span style="color: #000000; font-weight: bold;">/</span>CN7MA</div></div>
<p><span id="more-117"></span><br />
So, how does it work? How is it possible to compare a password with its encrypted version when you can&#8217;t be sure to have the same encryption string each time you encrypt it?<br />
I googled and found that it has something to do with the &#8220;salt&#8221;. the salt seems to be the 2 first letters of the string, and the password is generated considering those. To be sure, I generated the same password enough times to see :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">1000</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span> htpasswd <span style="color: #660033;">-nb</span> someuser somepwd <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> htpasswdtest; <span style="color: #000000; font-weight: bold;">done</span>;<br />
<span style="color: #c20cb9; font-weight: bold;">sort</span> htpasswdtest</div></div>
<p>After looking closely to the sorted file, I can say that every time the first 2 letters are identical, the second part of the encrypted string is also identical. </p>
<p>To try to generate a password with a specified salt, you can use the perl crypt function :</p>
<div class="codecolorer-container perl default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="perl codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">perl <span style="color: #339933;">-</span><span style="color: #b1b100;">le</span> <span style="color: #ff0000;">'print crypt(&quot;somepwd&quot;, &quot;qQ&quot;)'</span><br />
qQD5GYrJQSIwk</div></div>
<p>And then you can see that this comand outputs exactly the same string as the htpasswd had generated above !<br />
Mystery solved ! ;)</p>
]]></content:encoded>
			<wfw:commentRss>http://amandine.aupetit.info/117/htpasswd-encryption/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>shell scripting : seq prints a sequence of numbers</title>
		<link>http://amandine.aupetit.info/124/shell-seq-sequence-of-numbers/</link>
		<comments>http://amandine.aupetit.info/124/shell-seq-sequence-of-numbers/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 21:00:38 +0000</pubDate>
		<dc:creator>Amandine</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[sequence]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://amandine.aupetit.info/?p=124</guid>
		<description><![CDATA[I often need to execute a loop x times, and I&#8217;m just too lazy to write a i++ style algorithm&#8230; the command seq is made for me :)
Easy to use, just does what I need from it, here&#8217;s a extract from the man page :
NAME
&#160; &#160; &#160; &#160;seq - print a sequence of numbers

SYNOPSIS
&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>I often need to execute a loop x times, and I&#8217;m just too lazy to write a i++ style algorithm&#8230; the command seq is made for me :)</p>
<p>Easy to use, just does what I need from it, here&#8217;s a extract from the man page :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">NAME<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #c20cb9; font-weight: bold;">seq</span> - print a sequence of numbers<br />
<br />
SYNOPSIS<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>OPTION<span style="color: #7a0874; font-weight: bold;">&#93;</span>... LAST<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>OPTION<span style="color: #7a0874; font-weight: bold;">&#93;</span>... FIRST LAST<br />
&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>OPTION<span style="color: #7a0874; font-weight: bold;">&#93;</span>... FIRST INCREMENT LAST</div></div>
<p>So&#8230;<br />
<span id="more-124"></span></p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">10</span><br />
<span style="color: #000000;">1</span><br />
<span style="color: #000000;">2</span><br />
<span style="color: #000000;">3</span><br />
<span style="color: #000000;">4</span><br />
<span style="color: #000000;">5</span><br />
<span style="color: #000000;">6</span><br />
<span style="color: #000000;">7</span><br />
<span style="color: #000000;">8</span><br />
<span style="color: #000000;">9</span><br />
<span style="color: #000000;">10</span></div></div>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">5</span> <span style="color: #000000;">10</span><br />
<span style="color: #000000;">5</span><br />
<span style="color: #000000;">6</span><br />
<span style="color: #000000;">7</span><br />
<span style="color: #000000;">8</span><br />
<span style="color: #000000;">9</span><br />
<span style="color: #000000;">10</span></div></div>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">10</span> <span style="color: #000000;">2</span> <span style="color: #000000;">20</span><br />
<span style="color: #000000;">10</span><br />
<span style="color: #000000;">12</span><br />
<span style="color: #000000;">14</span><br />
<span style="color: #000000;">16</span><br />
<span style="color: #000000;">18</span><br />
<span style="color: #000000;">20</span></div></div>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'hello!'</span>; <span style="color: #000000; font-weight: bold;">done</span>;<br />
hello<span style="color: #000000; font-weight: bold;">!</span><br />
hello<span style="color: #000000; font-weight: bold;">!</span><br />
hello<span style="color: #000000; font-weight: bold;">!</span><br />
hello<span style="color: #000000; font-weight: bold;">!</span><br />
hello<span style="color: #000000; font-weight: bold;">!</span></div></div>
<p>Great ! :p</p>
]]></content:encoded>
			<wfw:commentRss>http://amandine.aupetit.info/124/shell-seq-sequence-of-numbers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pound</title>
		<link>http://amandine.aupetit.info/30/pound/</link>
		<comments>http://amandine.aupetit.info/30/pound/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 12:00:29 +0000</pubDate>
		<dc:creator>Amandine</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[load-balancing]]></category>
		<category><![CDATA[pound]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://amandine.aupetit.info/?p=30</guid>
		<description><![CDATA[Pound is a wonderful tool. It does just what you want, and does it good. Well, most of the time actually. Let me present it.
Pound is made by a Swiss company named Apsis GmbH (http://www.apsis.ch/), and its purpose is to achieve 3 goals :
- reverse proxy
- load balancing
- HTTPS front-end
You don&#8217;t need to use all [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Pound is a wonderful tool</strong>. It does just what you want, and does it good. Well, most of the time actually. Let me present it.</p>
<p>Pound is made by a Swiss company named Apsis GmbH (<a href="http://www.apsis.ch/">http://www.apsis.ch/</a>), and its purpose is to achieve 3 goals :<br />
- reverse proxy<br />
- load balancing<br />
- HTTPS front-end</p>
<p>You don&#8217;t need to use all 3 features, but you might need it anyway. Don&#8217;t assume it can do other things : No caching, no webserver, no acceleration. Just what it&#8217;s meant for.</p>
<p><span id="more-30"></span></p>
<p><strong>Why to use pound with an example</strong><br />
Now let&#8217;s say you have several (n) webservers, running at the same time, and maybe for several websites. Maybe you have the luck to have a public IP address for each of your webservers or websites, and assigned one website to one webserver. Then, if one of the webserver goes down or fails, then you have one website down.</p>
<p>You might have thought to spread all the websites on a part or even all of the wervers, and load-balance them with dns <a href="http://en.wikipedia.org/wiki/Round-robin">Round-robin</a>. But now, if one server fails, what happens? Your website will seem to be down each 1/n call, because round robin is just simple load balancing, it doesn&#8217;t know if a server is alive or not. So, maybe you could use heartbeat to take one server IP when it goes down, and then overload another webserver. And the more server you have, the more it becomes tricky.</p>
<p>Or you could use pound. Pound wil be the single entry point for all of your websites. It takes everything, and dispatch query amongst servers according to their header hostname. So, you can have one website per server, but it&#8217;s kind of stupid cause if one server goes down the website is still down. Let&#8217;s just spread all the websites on all the servers, and assign different priorities to specialize each server and partition the traffic, in order to avoid some website to slow done another website.</p>
<p>For example, you have 3 websites and 4 servers :<br />
server1 : pound<br />
server2 : web1 with priority 9, web2 with priority 1, web3 with priority 1<br />
server3 : web1 with priority 1, web2 with priority 9, web3 with priority 1<br />
server4 : web1 with priority 1, web2 with priority 1, web3 with priority 9</p>
<p>In this example, 9 of 11 pages for web1 will be served by server1, and 2 of 11 pages by server 2 ans server 3. If server1 goes down, the traffic will be automatically and fairly spread amongst server2 and server3, so that the overload shouldn&#8217;t slow down too much another server/website and end by getting all of them down. Same with the other websites of course.</p>
<p><strong>Installation</strong><br />
If you&#8217;re on Debian or Ubuntu, just aptitude it :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> pound</div></div>
<p>If not, install it your distro way (as long as you have version 2.x and above, it should be ok.), or download it from the <a href="http://www.apsis.ch/pound/index_html">official website</a>, and in this case I can just invite you the read the README file, it&#8217;s really well explained. </p>
<p>I will now assume that you run Pound on Ubuntu or Debian.<br />
Once installed via aptitude, edit the file /etc/default/pound and change &#8220;startup=0&#8243; in &#8220;startup=1&#8243;, or pound will refuse to start.</p>
<p><strong>Setup and configuration options</strong><br />
The configuration takes place in one single file : /etc/pound/pound.cfg The example config is simple but gathers the main options.</p>
<div class="codecolorer-container c default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;height:300px;"><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #339933;">## Minimal sample pound.cfg</span><br />
<span style="color: #339933;">##</span><br />
<span style="color: #339933;">## see pound(8) for details</span><br />
<br />
<br />
<span style="color: #339933;">######################################################################</span><br />
<span style="color: #339933;">## global options:</span><br />
<br />
User &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #ff0000;">&quot;www-data&quot;</span><br />
Group &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">&quot;www-data&quot;</span><br />
<span style="color: #339933;">#RootJail &nbsp; &nbsp; &nbsp; &quot;/chroot/pound&quot;</span><br />
<br />
<span style="color: #339933;">## Logging: (goes to syslog by default)</span><br />
<span style="color: #339933;">## &nbsp; &nbsp; &nbsp;0 &nbsp; &nbsp; &nbsp; no logging</span><br />
<span style="color: #339933;">## &nbsp; &nbsp; &nbsp;1 &nbsp; &nbsp; &nbsp; normal</span><br />
<span style="color: #339933;">## &nbsp; &nbsp; &nbsp;2 &nbsp; &nbsp; &nbsp; extended</span><br />
<span style="color: #339933;">## &nbsp; &nbsp; &nbsp;3 &nbsp; &nbsp; &nbsp; Apache-style (common log format)</span><br />
LogLevel &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000dd;">1</span><br />
<br />
<span style="color: #339933;">## check backend every X secs:</span><br />
Alive &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">30</span><br />
<br />
<span style="color: #339933;">## use hardware-accelleration card supported by openssl(1):</span><br />
<span style="color: #339933;">#SSLEngine &nbsp; &nbsp; &nbsp;&quot;&lt;hw&gt;&quot;</span><br />
<br />
<span style="color: #339933;"># poundctl control socket</span><br />
Control <span style="color: #ff0000;">&quot;/var/run/pound/poundctl.socket&quot;</span><br />
<br />
<br />
<span style="color: #339933;">######################################################################</span><br />
<span style="color: #339933;">## listen, redirect and ... to:</span><br />
<br />
<span style="color: #339933;">## redirect all requests on port 8080 (&quot;ListenHTTP&quot;) to the local webserver (see &quot;Service&quot; below):</span><br />
ListenHTTP<br />
&nbsp; &nbsp; &nbsp; &nbsp; Address 127.0.0.1<br />
&nbsp; &nbsp; &nbsp; &nbsp; Port &nbsp; &nbsp;<span style="color: #0000dd;">8080</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #339933;">## allow PUT and DELETE also (by default only GET, POST and HEAD)?:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; xHTTP &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000dd;">0</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; Service<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; BackEnd<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Address 127.0.0.1<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Port &nbsp; &nbsp;<span style="color: #0000dd;">80</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; End<br />
&nbsp; &nbsp; &nbsp; &nbsp; End<br />
End</div></div>
<p></hw></p>
]]></content:encoded>
			<wfw:commentRss>http://amandine.aupetit.info/30/pound/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More loop devices</title>
		<link>http://amandine.aupetit.info/73/more-loop-devices/</link>
		<comments>http://amandine.aupetit.info/73/more-loop-devices/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 14:39:38 +0000</pubDate>
		<dc:creator>Amandine</dc:creator>
				<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[xen]]></category>

		<guid isPermaLink="false">http://amandine.aupetit.info/?p=73</guid>
		<description><![CDATA[I have this very special server at work : a sunfire x4200 8 core 8GB RAM
To use the full given power, I tried to install xen on ubuntu, but it were freezing all the time. It seems to be a &#8220;TAP&#8221; problem, but I couldn&#8217;t fix it.
So I tried a Debian 5.0.3 dom0, and the [...]]]></description>
			<content:encoded><![CDATA[<p>I have this very special server at work : a sunfire x4200 8 core 8GB RAM<br />
To use the full given power, I tried to install xen on ubuntu, but it were freezing all the time. It seems to be a &#8220;TAP&#8221; problem, but I couldn&#8217;t fix it.<br />
So I tried a Debian 5.0.3 dom0, and the problem is slightly different : now the domU won&#8217;t find its drives if I use &#8220;tap:aio&#8221;.<br />
Ok, go back to the old &#8220;file:&#8221; driver.<br />
This one is using <a href="http://en.wikipedia.org/wiki/Loop_device">loop devices</a> to enable the drives, and only 8 default loop devices are enabled on debian (/dev/loop0 to /dev/loop7). As I want 7 domU, and at least 2 drives for each one (root and swap), I need more than 8 of these.<br />
Here&#8217;s how to add more loop devices :<br />
<span id="more-73"></span><br />
On Debian and ubuntu loop is a module, and you can specify the number of loop devices you want in /etc/modules. Replace :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">loop</div></div>
<p>by</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">loop <span style="color: #007800;">max_loop</span>=<span style="color: #000000;">64</span></div></div>
<p>(64 for example)</p>
<p>Then you have to disable the module :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rmmod loop</div></div>
<p>and re-enable it :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">modprobe loop</div></div>
<p>But the new devices won&#8217;t append automatically for sure, so if you don&#8217;t see them in /dev/loop*, you can make them appear this way :<br />
Edit /sbin/MAKEDEV and change :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; loop<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> part <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000;">0</span> <span style="color: #000000;">1</span> <span style="color: #000000;">2</span> <span style="color: #000000;">3</span> <span style="color: #000000;">4</span> <span style="color: #000000;">5</span> <span style="color: #000000;">6</span> <span style="color: #000000;">7</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; makedev loop<span style="color: #007800;">$part</span> b <span style="color: #000000;">7</span> <span style="color: #007800;">$part</span> <span style="color: #007800;">$disk</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">done</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span></div></div>
<p>By:</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; &nbsp; &nbsp; loop<span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">for</span> part <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">0</span> <span style="color: #000000;">63</span><span style="color: #000000; font-weight: bold;">`</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; makedev loop<span style="color: #007800;">$part</span> b <span style="color: #000000;">7</span> <span style="color: #007800;">$part</span> <span style="color: #007800;">$disk</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">done</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span></div></div>
<p>And execute</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666;">$ </span>MAKEDEV loop</div></div>
<p>For me this step didn&#8217;t work either, so I had to create it really by hand :</p>
<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:635px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">seq</span> <span style="color: #000000;">0</span> <span style="color: #000000;">63</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>; <span style="color: #000000; font-weight: bold;">do</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">mknod</span> <span style="color: #660033;">-m0660</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop<span style="color: #007800;">$i</span> b <span style="color: #000000;">7</span> <span style="color: #007800;">$i</span><br />
&nbsp; &nbsp; <span style="color: #c20cb9; font-weight: bold;">chown</span> root.disk <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>loop<span style="color: #007800;">$i</span><br />
<span style="color: #000000; font-weight: bold;">done</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://amandine.aupetit.info/73/more-loop-devices/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

