<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>林健的BLOG</title>
	
	<link>http://blog.linjian.org</link>
	<description>有容乃大，无欲则刚</description>
	<lastBuildDate>Sun, 08 Nov 2009 06:31:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/linjian" type="application/rss+xml" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">linjian</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item>
		<title>一道 C 语言指针访存题目的引申</title>
		<link>http://blog.linjian.org/articles/c-pointer-alignment-access/</link>
		<comments>http://blog.linjian.org/articles/c-pointer-alignment-access/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 05:41:48 +0000</pubDate>
		<dc:creator>Jian Lin</dc:creator>
				<category><![CDATA[计算机科学与编程]]></category>
		<category><![CDATA[CPU]]></category>
		<category><![CDATA[C语言]]></category>
		<category><![CDATA[gcc]]></category>
		<category><![CDATA[实验]]></category>
		<category><![CDATA[编译器]]></category>

		<guid isPermaLink="false">http://blog.linjian.org/?p=406</guid>
		<description><![CDATA[　　毕业生求职的时节，非毕业生接触到各种面试、笔试题目的几率也会相应地增加。下面请看一道经典的 C 语言指针访存题目，稍有些经验的朋友应该很快可以看出这个题目考查的是字节序、内存布局等知识点。然后在大脑中略排列一下，就能够给出答案（2000000）。
#include &#60;stdio.h&#62;
&#160;
int main()
{
&#160;&#160; &#160;int a[5] = {1, 2, 3, 4, 5};
&#160;&#160; &#160;int *pa = (int)(&#38;a) + 1;
&#160;&#160; &#160;printf(&#34;%x\n&#34;, *pa);
&#160;&#160; &#160;return 0;
}
　　不过，这个答案是否绝对正确，还要看题目所处的上下文了。如果题目明确说是在常见的 32 位 x86 平台上运行，那就无可厚非；但如果没有指明机器架构，那就要小心一点了，也许命题者真想考查一下求职者对非 x86 平台的了解程度呢。如果考虑机器架构，这个题目应当如何作答呢？粗想一下，我们需要考虑的是字长、字节序和对齐（alignment）访问规则。不过真要做实验看看，会发现这里面还是有一些花样的。如果没有实际经验，只凭教条加推测，很可能想不到其它平台上的一些细节之处。
　　我们换用一段信息量更丰富的程序来进行后续的实验。在不同的平台上，均使用未加特殊参数的 gcc 来编译这段程序——
#include &#60;stdio.h&#62;
&#160;
int main()
{
&#160;&#160; &#160;int x;
&#160;&#160; &#160;int a[5] = {0x11121314, 0x21222324, 0x31323334, 0x41424344, 0x51525354};
&#160;&#160; &#160;for (x = 0; x &#60; 20; x++) {
&#160;&#160; &#160; &#160; &#160;printf(&#34;%02x [...]]]></description>
			<content:encoded><![CDATA[<p>　　毕业生求职的时节，非毕业生接触到各种面试、笔试题目的几率也会相应地增加。下面请看一道经典的 C 语言指针访存题目，稍有些经验的朋友应该很快可以看出这个题目考查的是字节序、内存布局等知识点。然后在大脑中略排列一下，就能够给出答案（2000000）。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">#include &lt;stdio.h&gt;</li>
<li>&nbsp;</li>
<li>int main()</li>
<li>{</li>
<li>&nbsp;&nbsp; &nbsp;int a[5] = {1, 2, 3, 4, 5};</li>
<li>&nbsp;&nbsp; &nbsp;int *pa = (int)(&amp;a) + 1;</li>
<li>&nbsp;&nbsp; &nbsp;printf(&quot;%x\n&quot;, *pa);</li>
<li>&nbsp;&nbsp; &nbsp;return 0;</li>
<li>}</li></ol></div>
<p>　　不过，这个答案是否绝对正确，还要看题目所处的上下文了。如果题目明确说是在常见的 32 位 x86 平台上运行，那就无可厚非；但如果没有指明机器架构，那就要小心一点了，也许命题者真想考查一下求职者对非 x86 平台的了解程度呢。如果考虑机器架构，这个题目应当如何作答呢？粗想一下，我们需要考虑的是字长、字节序和对齐（alignment）访问规则。不过真要做实验看看，会发现这里面还是有一些花样的。如果没有实际经验，只凭教条加推测，很可能想不到其它平台上的一些细节之处。<br />
　　我们换用一段信息量更丰富的程序来进行后续的实验。在不同的平台上，均使用未加特殊参数的 gcc 来编译这段程序——</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">#include &lt;stdio.h&gt;</li>
<li>&nbsp;</li>
<li>int main()</li>
<li>{</li>
<li>&nbsp;&nbsp; &nbsp;int x;</li>
<li>&nbsp;&nbsp; &nbsp;int a[5] = {0x11121314, 0x21222324, 0x31323334, 0x41424344, 0x51525354};</li>
<li>&nbsp;&nbsp; &nbsp;for (x = 0; x &lt; 20; x++) {</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;printf(&quot;%02x &quot;, *(char *)((int)(&amp;a) + x));</li>
<li>&nbsp;&nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp;printf(&quot;\n&quot;);</li>
<li>&nbsp;&nbsp; &nbsp;for (x = 0; x &lt; 8; x++) {</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;printf(&quot;%08x &quot;, *(int *)((int)(&amp;a) + x));</li>
<li>&nbsp;&nbsp; &nbsp;}</li>
<li>&nbsp;&nbsp; &nbsp;printf(&quot;\n&quot;);</li>
<li>&nbsp;&nbsp; &nbsp;return 0;</li>
<li>}</li></ol></div>
<p>　　在 32 位 x86 下的结果不需要多解释。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">uname -a</li>
<li>Linux ubuntu 2.6.31-14-generic #48-Ubuntu SMP Fri Oct 16 14:04:26 UTC 2009 i686 GNU/Linux</li>
<li>./a.out </li>
<li>14 13 12 11 24 23 22 21 34 33 32 31 44 43 42 41 54 53 52 51 </li>
<li>11121314 24111213 23241112 22232411 21222324 34212223 33342122 32333421</li></ol></div>
<p>　　而在 64 位的 x86_64 下，由于 8 字节的指针被截断到了 4 字节的整型长度，故会引发段错误。同样的情况出现在 64 位的 Alpha 机器下。解决办法自然是把运算地址时的 int 修改成 long 或某种显式的 64 位类型。修改后的结果应该与 32 位 x86 一致。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">uname -a</li>
<li>Linux ubuntu 2.6.24-22-generic #1 SMP Mon Nov 24 19:35:06 UTC 2008 x86_64 GNU/Linux</li>
<li>./a.out</li>
<li>Segmentation fault</li></ol></div>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">uname -a</li>
<li>NetBSD sdf 2.1.0_STABLE NetBSD 2.1.0_STABLE (sdf) #0: Fri Mar 30 02:24:32 UTC 2007&nbsp; root@ol:/var/sys/arch/alpha/compile/sdf alpha</li>
<li>./a.out</li>
<li>Memory fault (core dumped)</li></ol></div>
<p>　　有趣的是在 XScale（Intel 实现的 ARMv5）下，虽然同属 little-endian，但非对齐取数时出现了在字内按字节循环的移位的结果。查查 <a href="http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.kui0097a/armcc_ch04s05s02.htm">ARM 的官方文档</a>，这确实是 ARMv5 的特性；而在 ARMv6 以后，非对齐访问则是完全支持的。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">uname -a</li>
<li>Linux zaurus 2.4.18-rmk7-pxa3-embedix #1 Sat, 06 Aug 2005 12:22:55 +0000 armv5tel unknown</li>
<li>./a.out </li>
<li>14 13 12 11 24 23 22 21 34 33 32 31 44 43 42 41 54 53 52 51 </li>
<li>11121314 14111213 13141112 12131411 21222324 24212223 23242122 22232421</li></ol></div>
<p>　　接下来看看 PowerPC，它是 big-endian 的代表，允许 32 位以内的非对齐访问，结果是容易理解的。有关 PowerPC 非对齐访问的一些细节可以参考<a href="http://www.ibm.com/developerworks/library/pa-dalign/">这篇文章</a>。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">uname -a</li>
<li>AIX aix 3 5 00C97AC04C00 powerpc unknown AIX</li>
<li>./a.out</li>
<li>11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44 51 52 53 54</li>
<li>11121314 12131421 13142122 14212223 21222324 22232431 23243132 24313233</li></ol></div>
<p>　　同样是 big-endium 的 SPARC 则不允许非对齐访问。它会对非对齐访问抛出 SIGBUS。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">uname -a</li>
<li>SunOS t1000 5.10 Generic_118833-33 sun4v sparc SUNW,Sun-Fire-T1000 Solaris</li>
<li>./a.out</li>
<li>11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44 51 52 53 54</li>
<li>Bus Error (core dumped)</li></ol></div>
<p>　　最后看看我们中科院计算所的龙芯（Loongson）2E，它是兼容 MIPS 架构的处理器。很多教科书告诉我们说通常的 MIPS 是不允许非对齐访问的（部分 MIPS 实现提供了非对齐访问指令，并申请了专利），但我们在龙芯下却得到了和 x86 相同的、允许非对齐访问的结果，这又是为什么呢？初步查到的原因是“<a href="http://www.lemote.com/bbs/archiver/?tid-7667.html">（针对龙芯修改过的 Linux）内核里确实有一个异常处理函数负责处理 lw 访问非对齐地址引起的异常</a>”。这也许是龙芯绕开 MIPS 专利的一种办法？我会向龙芯团队的同学求证一下，也希望熟悉 MIPS 或龙芯的朋友给我一个确切的答案。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">uname -a</li>
<li>Linux Loongson-1 2.6.18.1lemote #1 Sat Jan 13 16:02:26 CST 2007 mips GNU/Linux</li>
<li>./a.out</li>
<li>14 13 12 11 24 23 22 21 34 33 32 31 44 43 42 41 54 53 52 51</li>
<li>11121314 24111213 23241112 22232411 21222324 34212223 33342122 32333421</li></ol></div>
<p>　　不过用心思考的朋友也许会发现上面一系列实验存在的一个疏漏：没有考虑编译器的影响。一方面，编译器可能对整型的字长有不同的规定（例如 Windows 下的某些编译器即使在 32 位 x86 上也会把 int 定义为 16 位）；另一方面，编译器可以对不支持非对齐访问的处理器生成一定的指令序列、通过多次访存来模拟非对齐访问。我们看下面的例子：还是在 SPARC 平台上，改用 Solaris 自带的 Sun CC 来编译实验程序，这时就不会出现“Bus Error”，而会输出和 PowerPC 一样的结果。因为 SunCC 默认会使用“<a href="http://docs.sun.com/app/docs/doc/820-7598/bjavc">-xmemalign</a>”参数来生成适当的访存指令序列。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">uname -a</li>
<li>SunOS t1000 5.10 Generic_118833-33 sun4v sparc SUNW,Sun-Fire-T1000 Solaris</li>
<li>cc data.c</li>
<li>./a.out</li>
<li>11 12 13 14 21 22 23 24 31 32 33 34 41 42 43 44 51 52 53 54</li>
<li>11121314 12131421 13142122 14212223 21222324 22232431 23243132 24313233</li></ol></div>
<p>　　这样看来，在不指定机器架构和编译器等上下文的情况下，要正确且完美地回答一开始的那道题目还是需要一定知识积累的。答案省略，留给大家自己求解。在面试、笔试诸如 Sun SPARC、IBM PowerPC、中科院计算所微处理器中心等部门或者做 ARM 等嵌入式开发的公司时，最好先了解清楚它们的产品常识。<br />
　　（部分实验环境来源于 <a href="http://www.unix-center.net/">Unix-Center.Net</a>，在此致谢）</p>
<hr />原文链接：<a href="http://blog.linjian.org/articles/c-pointer-alignment-access/">http://blog.linjian.org/articles/c-pointer-alignment-access/</a>，作者：<a href="http://blog.linjian.org/">林健</a>。
<br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/">知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议</a>进行许可。
<br />(Digital fingerprint: 
 993d4981d6d552510db9a08493b2dbec)<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://blog.linjian.org/articles/compiler-standard-strict-smart/" title="编译器与标准——严格还是智能？">编译器与标准——严格还是智能？</a></li><li><a href="http://blog.linjian.org/articles/c-cpp-register-difference/" title="C和C++处理register关键字的一处差异">C和C++处理register关键字的一处差异</a></li><li><a href="http://blog.linjian.org/articles/sizeof-interesting-problems/" title="sizeof的一些牛角尖问题">sizeof的一些牛角尖问题</a></li><li><a href="http://blog.linjian.org/articles/innovation-exploration-loongson/" title="从《创新求索录》看龙芯的“自主创新”">从《创新求索录》看龙芯的“自主创新”</a></li><li><a href="http://blog.linjian.org/articles/windows-posix-sua/" title="试用Windows的UNIX/POSIX子系统（SUA）">试用Windows的UNIX/POSIX子系统（SUA）</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.linjian.org/articles/c-pointer-alignment-access/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sharp Zaurus SL-C750 (Sharp CEC SL-7500)</title>
		<link>http://blog.linjian.org/articles/sharp-zaurus-sl-c750/</link>
		<comments>http://blog.linjian.org/articles/sharp-zaurus-sl-c750/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 15:49:20 +0000</pubDate>
		<dc:creator>Jian Lin</dc:creator>
				<category><![CDATA[IT杂谈]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PDA]]></category>
		<category><![CDATA[Sharp]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://blog.linjian.org/?p=405</guid>
		<description><![CDATA[　　与很多家庭具有工程背景的朋友一样，我最早接触的计算机是 Sharp PC-1500。不久前 @Sisyphusliu 师兄把他几年前折腾过的一台 Sharp Zaurus SL-C750（中国版称为 Sharp CEC SL-7500C）借给了我玩。时隔多年再次使用 Sharp 的“小电脑”，我的感觉还是比较亲切的。

　　从 Wikipedia 上的介绍看到，Zaurus 系列是 Sharp 于 1993 至 2007 年间推出的、定位于 PDA 的掌上数码产品。2003 年上市的 SL-C750 能够配置 400MHz 的 XScale 处理器和 64MB RAM + 64MB Flash，比现在的一些中低端 PDA 还要强。然而这种定位不上不下、博而不专的掌上产品在这几年似乎没有被大众市场所接纳。从当时的那些 PDA 到后来的 UMPC、MID 等，往往只是 IT 圈子里少数 Geek 的玩物，普通用户对于这类产品的最大优势——“可折腾性”并不买账。
　　SL-C750 上预装了定制化的 Linux 发行版，但这台机已被师兄刷上了更加灵活的 pdaXrom embedded Linux，并更移植了不少应用上去。我曾试图重刷一个更新的系统上去，但在交叉编译屡屡出错之后，上网查阅却发现有关 Zaurus 的论坛早已冷清，很多下载链接失效。在缺乏时间和经验的情况下还是先放下了这个想法，只是实验性地交叉编译了几个简单的库和应用上去。
　　我在 tweethacking [...]]]></description>
			<content:encoded><![CDATA[<p>　　与很多家庭具有工程背景的朋友一样，我最早接触的计算机是 <a href="http://en.wikipedia.org/wiki/Sharp_PC-1500">Sharp PC-1500</a>。不久前 <a href="https://twitter.com/sisyphusliu">@Sisyphusliu</a> 师兄把他几年前折腾过的一台 <a href="http://www.sharp.co.jp/products/slc750/index.html">Sharp Zaurus SL-C750</a>（中国版称为 <a href="http://news.sohu.com/25/96/news215409625.shtml">Sharp CEC SL-7500C</a>）借给了我玩。时隔多年再次使用 Sharp 的“小电脑”，我的感觉还是比较亲切的。<br />
<a href="http://picasaweb.google.com/lh/photo/V9JHgnv2abavGMCi-lIV6Q?feat=embedwebsite"><img src="http://www.linjian.org/imagoxy/getimg.php?u=%3D%3DwRQpkLx0iWtAlUBh0UvADN2M3LBJ2bxkka0dWbxk3LjFmQBFUQBFUQBF0LJhVUf10X3IFT2N1LZFlQFlXMU1yXRp1Xv02bj5CdoB3Zn5SNox2LvoDc0RHa" title="" alt="Sharp Zaurus SL C750 (Sharp CEC SL 7500)" /></a><br />
　　从 <a href="http://en.wikipedia.org/wiki/Sharp_Zaurus">Wikipedia 上的介绍</a>看到，Zaurus 系列是 Sharp 于 1993 至 2007 年间推出的、定位于 PDA 的掌上数码产品。2003 年上市的 SL-C750 能够配置 400MHz 的 XScale 处理器和 64MB RAM + 64MB Flash，比现在的一些中低端 PDA 还要强。然而这种定位不上不下、博而不专的掌上产品在这几年似乎没有被大众市场所接纳。从当时的那些 PDA 到后来的 UMPC、MID 等，往往只是 IT 圈子里少数 Geek 的玩物，普通用户对于这类产品的最大优势——“可折腾性”并不买账。<br />
　　SL-C750 上预装了定制化的 Linux 发行版，但这台机已被师兄刷上了更加灵活的 <a href="http://www.pdaxrom.org/">pdaXrom embedded Linux</a>，并更移植了不少应用上去。我曾试图重刷一个更新的系统上去，但在交叉编译屡屡出错之后，上网查阅却发现有关 Zaurus 的论坛早已冷清，很多下载链接失效。在缺乏时间和经验的情况下还是先放下了这个想法，只是实验性地交叉编译了几个简单的库和应用上去。<br />
　　我在 <a href="http://tweethacking.com/">tweethacking</a> 上看到有人用小 LCD 或 LED 做 twitter 显示器；还有人推荐重度用户们专门买一个<a href="http://zedomax.com/blog/2009/10/12/mini-usb-lcd-screens-review/">迷你显示器</a>来监视 twitter 更新。其实这种事用 SL-C750 这类掌上设备绰绰有余：只需要 Firefox 加一个自动刷新插件。不过放心，我可不是重度用户，演示一下而已，不会真这么用的。<br />
<a href="http://picasaweb.google.com/lh/photo/RE5v5xVnS15ujsR5Vix6fA?feat=embedwebsite"><img src="http://www.linjian.org/imagoxy/getimg.php?u=%3D%3DwRQpkLy0iWtAlUBh0UvADN2M3LzJnRm1ySWVnb3I1LnFmQBFUQBFUQBF0LJVjRJ5kN3IFT2N1LZFlQFlXMU1yXRp1Xv02bj5CdoB3Zn5iNox2LvoDc0RHa" title="" alt="Sharp Zaurus SL C750 (Sharp CEC SL 7500)" /></a><br />
　　最后给大家展示一个噱头：在 Sharp Zaurus SL-C750 上运行 Windows 7！呵呵，这当然是开玩笑了。具体是怎么回事，看看视频就知道了：</p>
<div style="text-align:center;"><object id="articlevblog" width="480" height="370" ><param name="allowScriptAccess" value="always" /><embed pluginspage="http://www.macromedia.com/go/getflashplayer" src="http://vhead.blog.sina.com.cn/player/outer_player.swf?auto=0&#038;vid=25791737&#038;uid=1400322911&#038;pid=346&#038;tid=1" type="application/x-shockwave-flash" name="articlevblog" allowFullScreen="true" allowScriptAccess="always" width="480" height="370"></embed></object></div>
<p>　　（也可以直接在<a href="http://you.video.sina.com.cn/b/25791737-1400322911.html">新浪播客</a>或 <a href="http://www.youtube.com/watch?v=FMG-iyMdfKI">Youtube</a> 上查看）</p>
<hr />原文链接：<a href="http://blog.linjian.org/articles/sharp-zaurus-sl-c750/">http://blog.linjian.org/articles/sharp-zaurus-sl-c750/</a>，作者：<a href="http://blog.linjian.org/">林健</a>。
<br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/">知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议</a>进行许可。
<br />(Digital fingerprint: 
 993d4981d6d552510db9a08493b2dbec)<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://blog.linjian.org/articles/dropbear-pam-patch/" title="让 Dropbear 更好地支持 PAM">让 Dropbear 更好地支持 PAM</a></li><li><a href="http://blog.linjian.org/articles/create-your-private-bit-ly-and-twitpic/" title="Create your private bit.ly and twitpic">Create your private bit.ly and twitpic</a></li><li><a href="http://blog.linjian.org/articles/ubuntu-getty-input-at/" title="解决 Ubuntu 登录时用户名中不能含有“@”的问题">解决 Ubuntu 登录时用户名中不能含有“@”的问题</a></li><li><a href="http://blog.linjian.org/articles/ubuntu-jaunty-dropbox/" title="解决 Ubuntu 9.04 下启动 Dropbox 出错的问题">解决 Ubuntu 9.04 下启动 Dropbox 出错的问题</a></li><li><a href="http://blog.linjian.org/articles/biaoge-essay-twitter/" title="彪哥语录——人肉twitter">彪哥语录——人肉twitter</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.linjian.org/articles/sharp-zaurus-sl-c750/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>让 Dropbear 更好地支持 PAM</title>
		<link>http://blog.linjian.org/articles/dropbear-pam-patch/</link>
		<comments>http://blog.linjian.org/articles/dropbear-pam-patch/#comments</comments>
		<pubDate>Thu, 22 Oct 2009 06:45:02 +0000</pubDate>
		<dc:creator>Jian Lin</dc:creator>
				<category><![CDATA[Linux与开源]]></category>
		<category><![CDATA[bug]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PAM]]></category>
		<category><![CDATA[SSH]]></category>

		<guid isPermaLink="false">http://blog.linjian.org/?p=404</guid>
		<description><![CDATA[　　Dropbear 是一套来自澳大利亚的 *nix SSH 工具集，以体积微小著称，因此在嵌入式环境被广泛中使用。Dropbear 支持 Linux PAM，但直到目前最新的 0.52 版本，它对 PAM 的支持仍极其有限，只能做基本的身份认证（auth、account），不支持会话与密码管理（session、password）。在使用时，我发现即使是 Dropbear 已实现的 PAM 特性也存在一些不大不小的问题，需要自己动手解决。不过作者在 configure 的帮助中已经说明了现在只是“Try to include PAM support”，并且在与 PAM 相关的源代码注释中多次告知用户可以在什么地方 add、edit、hack 一些代码来满足自己特定的需求。我在编译部署 Dropbear 时，为了正常使用 PAM 认证，做了如下工作（基于 0.52 版本）：
　　1．开启 PAM 支持
　　不要以为 configure 时加入 --enable-pam 参数就开启了 PAM 支持，仔细看 configure 输出的最后一句：Now edit options.h to choose features。我们需要自行修改 options.h，定义 ENABLE_SVR_PAM_AUTH 宏，同时将与其冲突的 ENABLE_SVR_PASSWORD_AUTH 宏注释掉，这样 PAM 相关的代码才会被启用。
　　2．修正每次 PAM [...]]]></description>
			<content:encoded><![CDATA[<p>　　<a href="http://matt.ucc.asn.au/dropbear/dropbear.html">Dropbear</a> 是一套来自澳大利亚的 *nix SSH 工具集，以体积微小著称，因此在嵌入式环境被广泛中使用。Dropbear 支持 <a href="http://www.kernel.org/pub/linux/libs/pam/">Linux PAM</a>，但直到目前最新的 0.52 版本，它对 PAM 的支持仍极其有限，只能做基本的身份认证（auth、account），不支持会话与密码管理（session、password）。在使用时，我发现即使是 Dropbear 已实现的 PAM 特性也存在一些不大不小的问题，需要自己动手解决。不过作者在 configure 的帮助中已经说明了现在只是“Try to include PAM support”，并且在与 PAM 相关的源代码注释中多次告知用户可以在什么地方 add、edit、hack 一些代码来满足自己特定的需求。我在编译部署 Dropbear 时，为了正常使用 PAM 认证，做了如下工作（基于 0.52 版本）：<br />
　　1．开启 PAM 支持<br />
　　不要以为 configure 时加入 --enable-pam 参数就开启了 PAM 支持，仔细看 configure 输出的最后一句：Now edit options.h to choose features。我们需要自行修改 options.h，定义 ENABLE_SVR_PAM_AUTH 宏，同时将与其冲突的 ENABLE_SVR_PASSWORD_AUTH 宏注释掉，这样 PAM 相关的代码才会被启用。<br />
　　2．修正每次 PAM 会话（conversation）之后立即销毁密码的 bug<br />
　　svr-authpam.c 中的 pamConvFunc 函数实现了将客户端消息传递给服务端 PAM 的会话。为安全起见，第 119 行使用 m_burn 函数将用完的消息中的密码销毁（使用 0x66 字符覆盖）。但我们知道，在一次 pam_authenticate 调用中有可能配置了多个 PAM（pam_unix.so、pam_ldap.so……）陆续调用应用程序提供的会话函数来取用户名、密码，如果在第一次会话之后立即销毁密码，后续的会话就无法正常工作了。因此，需要等待所有 PAM 会话结束之后再销毁密码。我们可以注释掉 119 行；而 pam_authenticate 之后销毁密码的工作在 svr_auth_pam 函数中已经实现，不用新增。<br />
　　3．去除 PAM 会话函数只识别“password:”提示符为密码消息的限制<br />
　　svr-authpam.c 的第 101 行限制了密码消息的提示符为“password:”，但一些 PAM 有可能使用其它自定义的提示符，这使得 Dropbear 拒绝传送密码。事实上像 OpenSSH 等软件只是通过消息的类型为 PAM_PROMPT_ECHO_OFF 来认定其内容为密码，而不在意提示符是什么。因此，我们可以去除此处对提示符的判断，让使用自定义提示符的 PAM 也能与之兼容。<br />
　　4．解决 PAM 和基于 <a href="http://www.gnu.org/s/libc/manual/html_node/Name-Service-Switch.html">NSS</a> 的用户映射无法同时工作的问题<br />
　　有的应用系统结合使用 PAM 以及 GNU C Library 提供的 NSS 特性实现应用级的用户到本地系统用户的映射。在这类系统中，用户提供给 PAM 的应用级用户名在 NSS 中被映射为本地系统级用户名，用户只持有应用级的密码而不用知道本地系统级的密码。login、OpenSSH、vsftp 等程序对此种需求的支持良好，但 Dropbear 的实现却是首先调用 getpwnam 获得本地系统级用户名（已经由 NSS 映射过的），再用这个用户名去调用 PAM 认证，这就使得 PAM 得到的是“本地系统级用户名+应用级密码”的组件，自然验证失败。我们可以修改 Dropbear 的实现，在 svr-authpam.c 的 recv_msg_userauth_request 函数中保存客户端输入的用户名，在 svr-authpam.c 的 svr_auth_pam 函数中读取前面保存的用户名，而不要使用 NSS 输出在 ses.authstate.pw_name 的本地用户名。<br />
　　所有修改如下，如果你也需要在 Dropbear 中支持 PAM 认证，可以直接打上这些 patch。我有空向 Dropbear 的作者反馈一下吧。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">dropbear-0.52$ cat options.h.diff</li>
<li>152c152</li>
<li>&lt; #define ENABLE_SVR_PASSWORD_AUTH</li>
<li>---</li>
<li>&gt; /*#define ENABLE_SVR_PASSWORD_AUTH*/</li>
<li>154c154</li>
<li>&lt; /*#define ENABLE_SVR_PAM_AUTH*/</li>
<li>---</li>
<li>&gt; #define ENABLE_SVR_PAM_AUTH</li></ol></div>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">dropbear-0.52$ cat svr-auth.c.diff</li>
<li>36a37,38</li>
<li>&gt; char client_login_username[256];</li>
<li>&gt; </li>
<li>142a145,146</li>
<li>&gt; 	strncpy(client_login_username, username, 256);</li>
<li>&gt;</li></ol></div>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">dropbear-0.52$ cat svr-authpam.c.diff</li>
<li>41a42,43</li>
<li>&gt; extern char client_login_username[256];</li>
<li>&gt; </li>
<li>101c103</li>
<li>&lt; 			if (!(strcmp(compare_message, &quot;password:&quot;) == 0)) {</li>
<li>---</li>
<li>&gt; 			if (/*!(strcmp(compare_message, &quot;password:&quot;) == 0)*/ 0) {</li>
<li>119c121</li>
<li>&lt; 			m_burn(userDatap-&gt;passwd, strlen(userDatap-&gt;passwd));</li>
<li>---</li>
<li>&gt; 			/*m_burn(userDatap-&gt;passwd, strlen(userDatap-&gt;passwd));*/</li>
<li>198c200</li>
<li>&lt; 	userData.user = ses.authstate.pw_name;</li>
<li>---</li>
<li>&gt; 	userData.user = m_strdup(client_login_username);</li>
<li>247a250,252</li>
<li>&gt; 	if (userData.user != NULL) {</li>
<li>&gt; 		m_free(userData.user);</li>
<li>&gt; 	}</li></ol></div>
<hr />原文链接：<a href="http://blog.linjian.org/articles/dropbear-pam-patch/">http://blog.linjian.org/articles/dropbear-pam-patch/</a>，作者：<a href="http://blog.linjian.org/">林健</a>。
<br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/">知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议</a>进行许可。
<br />(Digital fingerprint: 
 993d4981d6d552510db9a08493b2dbec)<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://blog.linjian.org/articles/ubuntu-getty-input-at/" title="解决 Ubuntu 登录时用户名中不能含有“@”的问题">解决 Ubuntu 登录时用户名中不能含有“@”的问题</a></li><li><a href="http://blog.linjian.org/articles/godaddy-economy-plan-hosting-ssh/" title="Godaddy Economy Plan Hosting SSH 体验">Godaddy Economy Plan Hosting SSH 体验</a></li><li><a href="http://blog.linjian.org/articles/sharp-zaurus-sl-c750/" title="Sharp Zaurus SL-C750 (Sharp CEC SL-7500)">Sharp Zaurus SL-C750 (Sharp CEC SL-7500)</a></li><li><a href="http://blog.linjian.org/articles/vcardassistant-s60v2/" title="vCard Assistant：将 vCard 导入 Nokia S60v2 手机的辅助工具">vCard Assistant：将 vCard 导入 Nokia S60v2 手机的辅助工具</a></li><li><a href="http://blog.linjian.org/articles/ubuntu-jaunty-dropbox/" title="解决 Ubuntu 9.04 下启动 Dropbox 出错的问题">解决 Ubuntu 9.04 下启动 Dropbox 出错的问题</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.linjian.org/articles/dropbear-pam-patch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>从磁盘映像中挂载或提取指定的 LVM 逻辑卷</title>
		<link>http://blog.linjian.org/articles/linux-mount-lvm-image/</link>
		<comments>http://blog.linjian.org/articles/linux-mount-lvm-image/#comments</comments>
		<pubDate>Mon, 19 Oct 2009 05:40:57 +0000</pubDate>
		<dc:creator>Jian Lin</dc:creator>
				<category><![CDATA[Linux与开源]]></category>
		<category><![CDATA[LVM]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[存储]]></category>
		<category><![CDATA[磁盘]]></category>
		<category><![CDATA[虚拟机]]></category>

		<guid isPermaLink="false">http://blog.linjian.org/?p=403</guid>
		<description><![CDATA[　　前面提到了如何从磁盘映像中挂载或提取指定分区，现在我们再看看如何从含有 LVM 分区的映像中挂载或提取指定的逻辑卷（LV）。由于 LVM 分区内部有自己的盘区（PE）分配方法，因此逻辑卷在映像中并不一定是物理连续的，不能通过找到其偏移地址直接挂载。不过只要本地系统安装了 LVM 支持，就可以使用 LVM 自带的实用工具完成硬盘映像中逻辑卷的挂载。
　　首先查看一下本地系统已经挂载过的物理卷（PV）、卷组（VG）和逻辑卷。我们看到，系统已经安装并激活了 VolGroup01 卷组。事实上 VolGroup01 中的 LogVol00 是本地系统的根分区，LogVol01 是交换分区。
[root@centos CentOS]# pvscan
&#160; PV /dev/sda2&#160; &#160;VG VolGroup01&#160; &#160;lvm2 [136.00 GB / 0&#160; &#160; free]
&#160; Total: 1 [136.00 GB] / in use: 1 [136.00 GB] / in no VG: 0 [0&#160; &#160;]
[root@centos CentOS]# vgscan
&#160; Reading all physical volumes.&#160; This may take [...]]]></description>
			<content:encoded><![CDATA[<p>　　前面提到了如何<a href="http://blog.linjian.org/articles/linux-mount-part-image/">从磁盘映像中挂载或提取指定分区</a>，现在我们再看看如何从含有 <a href="http://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)">LVM</a> 分区的映像中挂载或提取指定的逻辑卷（LV）。由于 LVM 分区内部有自己的<a href="http://en.wikipedia.org/wiki/Extent_(file_systems)">盘区（PE）</a>分配方法，因此逻辑卷在映像中并不一定是物理连续的，不能通过找到其偏移地址直接挂载。不过只要本地系统安装了 LVM 支持，就可以使用 LVM 自带的实用工具完成硬盘映像中逻辑卷的挂载。<br />
　　首先查看一下本地系统已经挂载过的物理卷（PV）、卷组（VG）和逻辑卷。我们看到，系统已经安装并激活了 VolGroup01 卷组。事实上 VolGroup01 中的 LogVol00 是本地系统的根分区，LogVol01 是交换分区。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">[root@centos CentOS]# pvscan</li>
<li>&nbsp; PV /dev/sda2&nbsp; &nbsp;VG VolGroup01&nbsp; &nbsp;lvm2 [136.00 GB / 0&nbsp; &nbsp; free]</li>
<li>&nbsp; Total: 1 [136.00 GB] / in use: 1 [136.00 GB] / in no VG: 0 [0&nbsp; &nbsp;]</li>
<li>[root@centos CentOS]# vgscan</li>
<li>&nbsp; Reading all physical volumes.&nbsp; This may take a while...</li>
<li>&nbsp; Found volume group &quot;VolGroup01&quot; using metadata type lvm2</li>
<li>[root@centos CentOS]# lvscan</li>
<li>&nbsp; ACTIVE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '/dev/VolGroup01/LogVol00' [134.06 GB] inherit</li>
<li>&nbsp; ACTIVE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '/dev/VolGroup01/LogVol01' [1.94 GB] inherit</li></ol></div>
<p>　　实验使用的 centos5-2-gnome.img 是一个安装了 CentOS 并通过 LVM 管理磁盘的映像文件。使用 fdisk 命令查看其分区结构，其中 centos5-2-gnome.img2 是 LVM 分区，fdisk 不能提供 LVM 的详细信息。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">[root@centos CentOS]# fdisk -l -u centos5-2-gnome.img</li>
<li>last_lba(): I don't know how to handle files with mode 81a4</li>
<li>You must set cylinders.</li>
<li>You can do this from the extra functions menu.</li>
<li>&nbsp;</li>
<li>Disk centos5-2-gnome.img: 0 MB, 0 bytes</li>
<li>255 heads, 63 sectors/track, 0 cylinders, total 0 sectors</li>
<li>Units = sectors of 1 * 512 = 512 bytes</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Device Boot&nbsp; &nbsp; &nbsp; Start&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End&nbsp; &nbsp; &nbsp; Blocks&nbsp; &nbsp;Id&nbsp; System</li>
<li>centos5-2-gnome.img1&nbsp; &nbsp;*&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 63&nbsp; &nbsp; &nbsp; 208844&nbsp; &nbsp; &nbsp; 104391&nbsp; &nbsp;83&nbsp; Linux</li>
<li>centos5-2-gnome.img2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 208845&nbsp; &nbsp; &nbsp;8385929&nbsp; &nbsp; &nbsp;4088542+&nbsp; 8e&nbsp; Linux LVM</li></ol></div>
<p>　　使用 Linux 的 loop 设备控制命令——losetup：首先用 -f 参数查找一个空闲的 loop 节点；然后通过 -o 参数指定 LVM 分区在映像中的偏移量（参考 fdisk 的输出），将其挂载在空闲的 loop 节点上；最后使用 -a 参数确认挂载成功。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">[root@centos CentOS]# losetup -f</li>
<li>/dev/loop4</li>
<li>[root@centos CentOS]# losetup -o $((208845*512)) /dev/loop4 centos5-2-gnome.img</li>
<li>[root@centos CentOS]# losetup -a</li>
<li>...</li>
<li>/dev/loop4: [fd00]:26706086 (centos5-2-gnome.img), offset 106928640</li></ol></div>
<p>　　再一次查看系统中存在的 LVM 设施。我们看到，映像中的 VolGroup00 卷组已被扫描到，其中有 LogVol00、LogVol01 两个未激活的分区。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">[root@centos CentOS]# pvscan</li>
<li>&nbsp; PV /dev/loop4&nbsp; &nbsp;VG VolGroup00&nbsp; &nbsp;lvm2 [3.88 GB / 0&nbsp; &nbsp; free]</li>
<li>&nbsp; PV /dev/sda2&nbsp; &nbsp; VG VolGroup01&nbsp; &nbsp;lvm2 [136.00 GB / 0&nbsp; &nbsp; free]</li>
<li>&nbsp; Total: 2 [139.88 GB] / in use: 2 [139.88 GB] / in no VG: 0 [0&nbsp; &nbsp;]</li>
<li>[root@centos CentOS]# vgscan</li>
<li>&nbsp; Reading all physical volumes.&nbsp; This may take a while...</li>
<li>&nbsp; Found volume group &quot;VolGroup00&quot; using metadata type lvm2</li>
<li>&nbsp; Found volume group &quot;VolGroup01&quot; using metadata type lvm2</li>
<li>[root@centos CentOS]# lvscan</li>
<li>&nbsp; inactive&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '/dev/VolGroup00/LogVol00' [2.91 GB] inherit</li>
<li>&nbsp; inactive&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '/dev/VolGroup00/LogVol01' [992.00 MB] inherit</li>
<li>&nbsp; ACTIVE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '/dev/VolGroup01/LogVol00' [134.06 GB] inherit</li>
<li>&nbsp; ACTIVE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '/dev/VolGroup01/LogVol01' [1.94 GB] inherit</li></ol></div>
<p>　　这个例子中，映像中的卷组与本地已挂载的卷组名称不同，不会出现歧义。但如果映像中的卷组恰与本地已挂载的卷组重名，则可以使用 vgrename 命令修改映像中的卷组名称。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">[root@centos CentOS]# vgrename --help</li>
<li>&nbsp; vgrename: Rename a volume group</li>
<li>&nbsp;</li>
<li>vgrename</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[-A|--autobackup y|n]</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[-d|--debug]</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[-h|--help]</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[-t|--test]</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[-v|--verbose]</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;[--version]</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;OldVolumeGroupPath NewVolumeGroupPath |</li>
<li>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;OldVolumeGroupName NewVolumeGroupName</li></ol></div>
<p>　　使用 vgchange 命令激活 VolGroup00 卷组，再次查看逻辑卷的状态，LogVol00、LogVol01 已经可用。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">[root@centos CentOS]# vgchange -ay VolGroup00</li>
<li>&nbsp; 2 logical volume(s) in volume group &quot;VolGroup00&quot; now active</li>
<li>[root@centos CentOS]# lvscan</li>
<li>&nbsp; ACTIVE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '/dev/VolGroup00/LogVol00' [2.91 GB] inherit</li>
<li>&nbsp; ACTIVE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '/dev/VolGroup00/LogVol01' [992.00 MB] inherit</li>
<li>&nbsp; ACTIVE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '/dev/VolGroup01/LogVol00' [134.06 GB] inherit</li>
<li>&nbsp; ACTIVE&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; '/dev/VolGroup01/LogVol01' [1.94 GB] inherit</li></ol></div>
<p>　　现在便可以使用 lvscan 输出的逻辑卷设备文件名来挂载对应的文件系统了。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">[root@centos CentOS]# mount /dev/VolGroup00/LogVol00 ./part/</li>
<li>[root@centos CentOS]# ls ./part/</li>
<li>bin&nbsp; boot&nbsp; dev&nbsp; etc&nbsp; home&nbsp; lib&nbsp; lost+found&nbsp; media&nbsp; misc&nbsp; mnt</li>
<li>net&nbsp; opt&nbsp; proc&nbsp; root&nbsp; sbin&nbsp; selinux&nbsp; srv&nbsp; sys&nbsp; tmp&nbsp; usr&nbsp; var</li>
<li>[root@centos CentOS]# umount ./part/</li></ol></div>
<p>　　如果要提取其中的分区，也可以直接对逻辑卷设备文件或 /dev/mapper/ 下对应的设备文件操作。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">[root@centos CentOS]# dd if=/dev/VolGroup00/LogVol00 of=LogVol00.img</li>
<li>6094848+0 records in</li>
<li>6094848+0 records out</li>
<li>3120562176 bytes (3.1 GB) copied, 113.93 seconds, 27.4 MB/s</li></ol></div>
<p>　　试挂载提取出来的分区。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">[root@centos CentOS]# mount -o loop LogVol00.img ./part/</li>
<li>[root@centos CentOS]# ls ./part/</li>
<li>bin&nbsp; boot&nbsp; dev&nbsp; etc&nbsp; home&nbsp; lib&nbsp; lost+found&nbsp; media&nbsp; misc&nbsp; mnt</li>
<li>net&nbsp; opt&nbsp; proc&nbsp; root&nbsp; sbin&nbsp; selinux&nbsp; srv&nbsp; sys&nbsp; tmp&nbsp; usr&nbsp; var</li>
<li>[root@centos CentOS]# umount ./part/</li></ol></div>
<p>　　卸载文件系统之后，别忘了卸载卷组和 loop 节点。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">[root@centos CentOS]# vgchange -an VolGroup00</li>
<li>&nbsp; 0 logical volume(s) in volume group &quot;VolGroup00&quot; now active</li>
<li>[root@centos CentOS]# losetup -d /dev/loop4</li></ol></div>
<hr />原文链接：<a href="http://blog.linjian.org/articles/linux-mount-lvm-image/">http://blog.linjian.org/articles/linux-mount-lvm-image/</a>，作者：<a href="http://blog.linjian.org/">林健</a>。
<br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/">知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议</a>进行许可。
<br />(Digital fingerprint: 
 993d4981d6d552510db9a08493b2dbec)<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://blog.linjian.org/articles/linux-mount-part-image/" title="从磁盘映像中挂载或提取指定分区">从磁盘映像中挂载或提取指定分区</a></li><li><a href="http://blog.linjian.org/articles/ubuntu-jaunty-dropbox/" title="解决 Ubuntu 9.04 下启动 Dropbox 出错的问题">解决 Ubuntu 9.04 下启动 Dropbox 出错的问题</a></li><li><a href="http://blog.linjian.org/articles/storage-trust-model/" title="浅谈存储系统的信任边界">浅谈存储系统的信任边界</a></li><li><a href="http://blog.linjian.org/articles/install-puppy-linux/" title="借助虚拟机，在移动硬盘中安装Puppy Linux">借助虚拟机，在移动硬盘中安装Puppy Linux</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.linjian.org/articles/linux-mount-lvm-image/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create your private bit.ly and twitpic</title>
		<link>http://blog.linjian.org/articles/create-your-private-bit-ly-and-twitpic/</link>
		<comments>http://blog.linjian.org/articles/create-your-private-bit-ly-and-twitpic/#comments</comments>
		<pubDate>Thu, 15 Oct 2009 15:45:47 +0000</pubDate>
		<dc:creator>Jian Lin</dc:creator>
				<category><![CDATA[Web与移动平台]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[服务]]></category>
		<category><![CDATA[网站]]></category>

		<guid isPermaLink="false">http://blog.linjian.org/?p=402</guid>
		<description><![CDATA[As you know that some web 2.0 services, such as twitter web clients, URL shorteners, and picture hosting services cannot be accessed steadily in Mainland China. Perhaps you know how to break through the “wall”, but as information promulgators, we would better make our resources accessible for masses without special network skills or the lazy [...]]]></description>
			<content:encoded><![CDATA[<p>As you know that some web 2.0 services, such as twitter web clients, URL shorteners, and picture hosting services cannot be accessed steadily in Mainland China. Perhaps you know how to break through the “wall”, but as information promulgators, we would better make our resources accessible for masses without special network skills or the lazy ones. A few months ago, I wrote <a href="http://blog.linjian.org/articles/imagoxy-image-proxy/">Imagoxy</a>, a picasa proxy for my blog readers. And these days a private URL shortener and a private picture hosting service are built for my twitter followers.</p>
<p>I chose a <a href="http://www.free8.com/kongjian">free PHP hosting service</a> with advertisements to host these web applications. For one thing, I do not want my paid host be punished for being related to them accidentally, while free spaces are easily replaceable. For another, advertisements are only appended to htmls, and yet URL forwarding and picture files are not affected.</p>
<p>There are <a href="http://www.webresourcesdepot.com/7-open-source-and-free-url-shortener-scripts-to-create-your-own/">lots of free URL shortener scripts</a> based on PHP and MySQL. I prefer <a href="http://www.tighturl.com/project/">TightURL</a>, which is relatively simpler than the others, since web pages with rich features such as AJAX may go wrong for appended advertisements. <a href="http://www.tighturl.com/sourcecode/INSTALL">Apache's RewriteEngine should be enabled</a> to make the short URL more graceful. And you can also modify “tighturl.*.tmpl” to make it more friendly to users and external caller scripts. Like most of public URL shorteners, TightURL can be dragged  into browser's bookmarks for convenience.</p>
<p>I had not found a free and simple enough PHP application to host pictures for twitter. So I wrote a tiny script for myself. It saves uploaded picture and send a tweet via <a href="http://apiwiki.twitter.com/Libraries">twitter API</a> (with shortened URL). I employed <a href="http://code.google.com/p/php-twitter/">PHP Twitter</a> to call twitter API for its simplicity. The script is accessible from my cellphone, so I can upload the taken photos instantly. I will release the script after more security measure taken.</p>
<p>More services can be deployed on free / advertisement web hosting sites. However, these sites are also usually banned by the “wall”. You should backup your data periodically and be ready to migrate at all times. The only unaltered entrance for your twitter followers is your domain name – unless you have too much influence infuriating somebody.</p>
<p>At last, my private services' domain name is “Jian.me”. It originates from my given name. It's interesting that “Jian” can be thought as “简” or “减” for URL shortener using.</p>
<hr />原文链接：<a href="http://blog.linjian.org/articles/create-your-private-bit-ly-and-twitpic/">http://blog.linjian.org/articles/create-your-private-bit-ly-and-twitpic/</a>，作者：<a href="http://blog.linjian.org/">林健</a>。
<br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/">知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议</a>进行许可。
<br />(Digital fingerprint: 
 993d4981d6d552510db9a08493b2dbec)<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://blog.linjian.org/articles/sharp-zaurus-sl-c750/" title="Sharp Zaurus SL-C750 (Sharp CEC SL-7500)">Sharp Zaurus SL-C750 (Sharp CEC SL-7500)</a></li><li><a href="http://blog.linjian.org/articles/internet-kaopulity/" title="互联网需要 Kaopulity 精神">互联网需要 Kaopulity 精神</a></li><li><a href="http://blog.linjian.org/articles/identity-20-4-conclusion/" title="Identity 2.0 何时真正到来？（四）用户价值决定前途走向">Identity 2.0 何时真正到来？（四）用户价值决定前途走向</a></li><li><a href="http://blog.linjian.org/articles/identity-20-3-i-name/" title="Identity 2.0 何时真正到来？（三）生财有道的 i-name">Identity 2.0 何时真正到来？（三）生财有道的 i-name</a></li><li><a href="http://blog.linjian.org/articles/identity-20-2-information-card/" title="Identity 2.0 何时真正到来？（二）处境尴尬的 Information Card">Identity 2.0 何时真正到来？（二）处境尴尬的 Information Card</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.linjian.org/articles/create-your-private-bit-ly-and-twitpic/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>我的肖像又一次被“误用”了……</title>
		<link>http://blog.linjian.org/articles/my-photo-misused-again/</link>
		<comments>http://blog.linjian.org/articles/my-photo-misused-again/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 16:41:53 +0000</pubDate>
		<dc:creator>Jian Lin</dc:creator>
				<category><![CDATA[生活空间]]></category>
		<category><![CDATA[博客]]></category>
		<category><![CDATA[照片]]></category>
		<category><![CDATA[肖像]]></category>

		<guid isPermaLink="false">http://blog.linjian.org/?p=400</guid>
		<description><![CDATA[　　上一次是 2007 年 2 月，参考这里。
　　这一次很“荣幸”，是在 ZDNet“最受欢迎的 50 大中国技术博客”页面：

　　第 27 名，林昊同志，用的是我林健的肖像。两个名字可以说是一字之差，也可以说是 50% 的误差。这是 ZDNet 编辑粗心搞错了呢，还是林昊朋友在故意开玩笑？这个网页左下角的广告正好说明了我的感觉：好囧呀。
　　看了看这个名单，还不错，第 13 名高昂、第 21 名刘未鹏、第 44 名简朝阳都是我们《我是一只 IT 小小鸟》的作者，把我的照片混在里面还不至于太离谱。正巧林昊也是一位博文视点的作者，他的《OSGi 原理与最佳实践》我有机会要找来看看，服务框架方面的东西还是挺有意思的。这个博客名单里面还有几位我曾谋过面的 IT 达人，以及 RSS 订阅列表中的对象，看来我还是挺 IN 的呵。
　　期待我的博客哪天真的上个什么（非负面的）排行榜吧，哈哈！

　　Update (2009-10-13 12:34)：与 ZDNet 沟通后，他们已经修正，换上了原版帅哥林昊。

　　P.S. 同学报告，还有转载文章也照抄了我的肖像——

原文链接：http://blog.linjian.org/articles/my-photo-misused-again/，作者：林健。
本作品采用知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议进行许可。
(Digital fingerprint: 
 993d4981d6d552510db9a08493b2dbec)相关文章冒用我的肖像是没有必要的Beijing Open Party 活动归来，意外遇到一系列牛人日全食，没有专业设备或方法拍不好教你在新浪Blog上显示来访者IP及地理位置我们闲了会写点什么文字？]]></description>
			<content:encoded><![CDATA[<p>　　上一次是 2007 年 2 月，参考<a href="http://blog.linjian.org/articles/do-not-use-my-photo/">这里</a>。<br />
　　这一次很“荣幸”，是在 ZDNet“<a href="http://blog.zdnet.com.cn/popblogger50.shtml">最受欢迎的 50 大中国技术博客</a>”页面：<br />
<a href="http://picasaweb.google.com/lh/photo/60VOwvwzUiEXe7WyNbGiBw?feat=embedwebsite"><img src="http://www.linjian.org/imagoxy/getimg.php?u=%3DcGcq5SMtM3ZvxmYtATNvADN2M3LJh3cBdWRyAjUiJ1LjllQBFUQBFUQBF0LJJmcJVTTQFmT0N1LZFlQFlXMU1yXRp1Xv02bj5CdoB3Zn5CNox2LvoDc0RHa" title="" alt="我的肖像又一次被“误用”了……" /></a><br />
　　第 27 名，<a href="http://www.blogjava.net/BlueDavy/">林昊</a>同志，用的是我<a href="http://blog.linjian.org/">林健</a>的肖像。两个名字可以说是一字之差，也可以说是 50% 的误差。这是 ZDNet 编辑粗心搞错了呢，还是林昊朋友在故意开玩笑？这个网页左下角的广告正好说明了我的感觉：好囧呀。<br />
　　看了看这个名单，还不错，第 13 名<a href="http://www.gaoang.com/">高昂</a>、第 21 名<a href="http://mindhacks.cn/">刘未鹏</a>、第 44 名<a href="http://www.jianzhaoyang.com/">简朝阳</a>都是我们《<a href="http://blog.linjian.org/articles/it-small-birds/">我是一只 IT 小小鸟</a>》的作者，把我的照片混在里面还不至于太离谱。正巧林昊也是一位博文视点的作者，他的《<a href="http://www.china-pub.com/195813">OSGi 原理与最佳实践</a>》我有机会要找来看看，服务框架方面的东西还是挺有意思的。这个博客名单里面还有几位我曾谋过面的 IT 达人，以及 RSS 订阅列表中的对象，看来我还是挺 IN 的呵。<br />
　　期待我的博客哪天真的上个什么（非负面的）排行榜吧，哈哈！</p>
<hr />
　　Update (2009-10-13 12:34)：与 ZDNet 沟通后，他们已经修正，换上了原版帅哥林昊。</p>
<hr />
　　P.S. 同学报告，还有转载文章也照抄了我的肖像——<br />
<a href="http://picasaweb.google.com/lh/photo/RA16nb6QDjl2xUhh9RYvvQ?feat=embedwebsite"><img src="http://www.linjian.org/imagoxy/getimg.php?u=%3DcGcq5iMtM3ZvxmYtATNvADN2M3LvlWLXlmb1IlQDl0LnllQBFUQBFUQBF0LJRTclVzRQFmT0N1LZFlQFlXMU1yXRp1Xv02bj5CdoB3Zn5iNox2LvoDc0RHa" title="" alt="我的肖像又一次被“误用”了……" /></a></p>
<hr />原文链接：<a href="http://blog.linjian.org/articles/my-photo-misused-again/">http://blog.linjian.org/articles/my-photo-misused-again/</a>，作者：<a href="http://blog.linjian.org/">林健</a>。
<br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/">知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议</a>进行许可。
<br />(Digital fingerprint: 
 993d4981d6d552510db9a08493b2dbec)<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://blog.linjian.org/articles/do-not-use-my-photo/" title="冒用我的肖像是没有必要的">冒用我的肖像是没有必要的</a></li><li><a href="http://blog.linjian.org/articles/beijing-open-party-2009-04/" title="Beijing Open Party 活动归来，意外遇到一系列牛人">Beijing Open Party 活动归来，意外遇到一系列牛人</a></li><li><a href="http://blog.linjian.org/articles/total-solar-eclipse-photo/" title="日全食，没有专业设备或方法拍不好">日全食，没有专业设备或方法拍不好</a></li><li><a href="http://blog.linjian.org/articles/sina-blog-show-ip/" title="教你在新浪Blog上显示来访者IP及地理位置">教你在新浪Blog上显示来访者IP及地理位置</a></li><li><a href="http://blog.linjian.org/articles/what-we-write-when-free/" title="我们闲了会写点什么文字？">我们闲了会写点什么文字？</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.linjian.org/articles/my-photo-misused-again/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>纪念陈志行教授</title>
		<link>http://blog.linjian.org/articles/chenzhixing-memories/</link>
		<comments>http://blog.linjian.org/articles/chenzhixing-memories/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 13:06:06 +0000</pubDate>
		<dc:creator>Jian Lin</dc:creator>
				<category><![CDATA[生活空间]]></category>
		<category><![CDATA[化学]]></category>
		<category><![CDATA[博弈]]></category>
		<category><![CDATA[围棋]]></category>

		<guid isPermaLink="false">http://blog.linjian.org/?p=399</guid>
		<description><![CDATA[　　今天是中国电脑围棋的先行者、中山大学化学系陈志行教授逝世一周年的日子。
陈志行、徐心和教授与北理工团队
　　我认识陈老先生是在 2007 年重庆工学院举办的第二届中国机器博弈锦标赛上。作为中国计算机博弈界的元老，陈教授既是那次比赛的特邀嘉宾，也是重量级的参赛选手。为了鼓励新手，陈教授宣布自己只参加对弈而不计算成绩。在每局比赛中，陈教授总是同年轻的选手亲切地交流，点评他们程序的优劣、向他们传授围棋与编程两方面的经验。我当时参加的不是围棋项目，自己也不怎么懂围棋，但在旁边观战时却能够深切地感受到他条理的思路和无私的精神。陈教授对自己当时已处于肺癌晚期的事实毫不避讳，对于自己不能完成的事业仍怀有理性的规划，因此对年轻人也充满了殷切的期望。
手谈 v.s. 理治棋壮（围棋）
　　陈志行教授研制的《手谈》软件在计算博弈界与围棋界可谓无人不晓，《手谈》在上世纪末、本世纪初的多项国际赛事中屡屡夺魁。可惜在盗版软件泛滥的大环境下，《手谈》的商业版本在国内并没有太大的营利，其主要市场在日本等周边国家，让发行商 KOEI 占尽了风头。陈教授 2000 年还出版过《电脑围棋小洞天》一书，讲述了他的电脑围棋生涯、经验和感悟，然而这毕竟属于一个小众领域，这本书的印量并不大，成为了业界同仁的经典收藏。
《手谈》（中文版）与《电脑围棋小洞天》
　　“少年好学志于行”——这是陈志行教授名字的来历，也是他给予青年人的赠言。在陈教授逝世一周年的日子，让我们以此句自勉。
原文链接：http://blog.linjian.org/articles/chenzhixing-memories/，作者：林健。
本作品采用知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议进行许可。
(Digital fingerprint: 
 993d4981d6d552510db9a08493b2dbec)相关文章化学出身的计算机达人祝贺北理工／六子棋遐想祝贺北京理工大学BitStronger团队再创佳绩校园博弈大赛小记我校团队获全国机器博弈锦标赛六子棋亚军]]></description>
			<content:encoded><![CDATA[<p>　　今天是中国电脑围棋的先行者、中山大学化学系<a href="http://www.google.com/search?q=%E4%B8%AD%E5%B1%B1%E5%A4%A7%E5%AD%A6+%E9%99%88%E5%BF%97%E8%A1%8C">陈志行教授</a>逝世一周年的日子。</p>
<p style="text-align: center;"><a href="http://picasaweb.google.com/lh/photo/pP92HJ7YrGF-YSQROZtH1A?feat=embedwebsite"><img src="http://www.linjian.org/imagoxy/getimg.php?u=%3D%3DwRQpkL4p3YtIXZn52byR3c0lmYvADN2M3LRV1TzdnRy1mY590LNllQBFUQBFUQBF0LJJWajJmQ5EWT0N1LZFlQFlXMU1yXRp1Xv02bj5CdoB3Zn5CNox2LvoDc0RHa" title="" alt="纪念陈志行教授" /></a><br />陈志行、徐心和教授与北理工团队</p>
<p>　　我认识陈老先生是在 2007 年重庆工学院举办的第二届<a href="http://zh.wikipedia.org/wiki/%E4%B8%AD%E5%9B%BD%E6%9C%BA%E5%99%A8%E5%8D%9A%E5%BC%88%E9%94%A6%E6%A0%87%E8%B5%9B">中国机器博弈锦标赛</a>上。作为中国计算机博弈界的元老，陈教授既是那次比赛的特邀嘉宾，也是重量级的参赛选手。为了鼓励新手，陈教授宣布自己只参加对弈而不计算成绩。在每局比赛中，陈教授总是同年轻的选手亲切地交流，点评他们程序的优劣、向他们传授围棋与编程两方面的经验。我当时参加的不是围棋项目，自己也不怎么懂围棋，但在旁边观战时却能够深切地感受到他条理的思路和无私的精神。陈教授对自己当时已处于肺癌晚期的事实毫不避讳，对于自己不能完成的事业仍怀有理性的规划，因此对年轻人也充满了殷切的期望。</p>
<p style="text-align: center;"><a href="http://picasaweb.google.com/lh/photo/WsimAr_uRoVaku5w448nwg?feat=embedwebsite"><img src="http://www.linjian.org/imagoxy/getimg.php?u=%3DcEUK5Ce6NWLn5Waxdmbvh2YvADN2M3LBJlb2pXVUBTRrVzLRllQBFUQBFUQBF0LJxkczgXY5EWT0N1LZFlQFlXMU1yXRp1Xv02bj5CdoB3Zn5CNox2LvoDc0RHa" title="" alt="纪念陈志行教授" /></a><br />手谈 v.s. 理治棋壮（围棋）</p>
<p>　　陈志行教授研制的《手谈》软件在计算博弈界与围棋界可谓无人不晓，《手谈》在上世纪末、本世纪初的多项国际赛事中屡屡夺魁。可惜在盗版软件泛滥的大环境下，《手谈》的商业版本在国内并没有太大的营利，其主要市场在日本等周边国家，让发行商 KOEI 占尽了风头。陈教授 2000 年还出版过《电脑围棋小洞天》一书，讲述了他的电脑围棋生涯、经验和感悟，然而这毕竟属于一个小众领域，这本书的印量并不大，成为了业界同仁的经典收藏。</p>
<p style="text-align: center;"><a href="http://picasaweb.google.com/lh/photo/A2De5530TO6p39eTAg1cMQ?feat=embedwebsite"><img src="http://www.linjian.org/imagoxy/getimg.php?u=HBlSusGbhRHZuFGavADN2M3LvFUOKJlZKhGUQV2LVllQBFUQBFUQBF0LJtkeoVHW5EWT0N1LZFlQFlXMU1yXRp1Xv02bj5CdoB3Zn5iNox2LvoDc0RHa" title="" alt="纪念陈志行教授" /></a><br />《手谈》（中文版）与《电脑围棋小洞天》</p>
<p>　　“少年好学志于行”——这是陈志行教授名字的来历，也是他给予青年人的赠言。在陈教授逝世一周年的日子，让我们以此句自勉。</p>
<hr />原文链接：<a href="http://blog.linjian.org/articles/chenzhixing-memories/">http://blog.linjian.org/articles/chenzhixing-memories/</a>，作者：<a href="http://blog.linjian.org/">林健</a>。
<br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/">知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议</a>进行许可。
<br />(Digital fingerprint: 
 993d4981d6d552510db9a08493b2dbec)<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://blog.linjian.org/articles/chemistry-computer/" title="化学出身的计算机达人">化学出身的计算机达人</a></li><li><a href="http://blog.linjian.org/articles/connect6-bit-champion/" title="祝贺北理工／六子棋遐想">祝贺北理工／六子棋遐想</a></li><li><a href="http://blog.linjian.org/articles/bitstronger-win-again/" title="祝贺北京理工大学BitStronger团队再创佳绩">祝贺北京理工大学BitStronger团队再创佳绩</a></li><li><a href="http://blog.linjian.org/articles/bit-computer-game-competition/" title="校园博弈大赛小记">校园博弈大赛小记</a></li><li><a href="http://blog.linjian.org/articles/ccgc-connect6-runner-up/" title="我校团队获全国机器博弈锦标赛六子棋亚军">我校团队获全国机器博弈锦标赛六子棋亚军</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.linjian.org/articles/chenzhixing-memories/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>从磁盘映像中挂载或提取指定分区</title>
		<link>http://blog.linjian.org/articles/linux-mount-part-image/</link>
		<comments>http://blog.linjian.org/articles/linux-mount-part-image/#comments</comments>
		<pubDate>Sun, 11 Oct 2009 14:48:44 +0000</pubDate>
		<dc:creator>Jian Lin</dc:creator>
				<category><![CDATA[Linux与开源]]></category>
		<category><![CDATA[mount]]></category>
		<category><![CDATA[存储]]></category>
		<category><![CDATA[磁盘]]></category>
		<category><![CDATA[虚拟机]]></category>

		<guid isPermaLink="false">http://blog.linjian.org/?p=398</guid>
		<description><![CDATA[　　最近在做虚拟机相关的事，需要处理一些磁盘和分区的映像文件。如何从一个磁盘映像中挂载指定的分区到本地 Linux 文件系统呢？理论上说，可以用 dd 把该分区从磁盘映像中提取出来再挂载，不过 mount 提供了针对 loop 设备的偏移量参数，方便直接从磁盘映像中挂载指定分区。笔记如下：
　　演示用的磁盘映像使用 qemu-img 制作。我们使用原生的 raw 格式，等价于磁盘上的原始数据流，保证它在任何 Linux 系统上都可以直接挂载。使用 Windows PE 工具盘启动该 qemu 虚拟机，创建一系列不同格式的分区并在其中建立几个文件。
root@lj-laptop:/opt/vm# qemu-img create -f raw vmtest.img 5G
root@lj-laptop:/opt/vm# qemu -hda ./vmtest.img -cdrom /dev/cdrom -boot d -m 256M -localtime
　　磁盘分区结构如截图：

　　回到宿主系统，使用 fdisk 的 -l、-u 参数查看磁盘映像。其中 -u 表示以扇区为单位显示分区起止位置，方便后续计算。
root@lj-laptop:/opt/vm# fdisk -l -u vmtest.img 
You must set cylinders.
You can do this from the [...]]]></description>
			<content:encoded><![CDATA[<p>　　最近在做虚拟机相关的事，需要处理一些磁盘和分区的映像文件。如何从一个磁盘映像中挂载指定的分区到本地 Linux 文件系统呢？理论上说，可以用 dd 把该分区从磁盘映像中提取出来再挂载，不过 mount 提供了针对 <a href="http://en.wikipedia.org/wiki/Loop_device">loop 设备</a>的偏移量参数，方便直接从磁盘映像中挂载指定分区。笔记如下：<br />
　　演示用的磁盘映像使用 qemu-img 制作。我们使用原生的 raw 格式，等价于磁盘上的原始数据流，保证它在任何 Linux 系统上都可以直接挂载。使用 Windows PE 工具盘启动该 qemu 虚拟机，创建一系列不同格式的分区并在其中建立几个文件。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">root@lj-laptop:/opt/vm# qemu-img create -f raw vmtest.img 5G</li>
<li>root@lj-laptop:/opt/vm# qemu -hda ./vmtest.img -cdrom /dev/cdrom -boot d -m 256M -localtime</li></ol></div>
<p>　　磁盘分区结构如截图：<br />
<a href="http://picasaweb.google.com/lh/photo/piJo72xQtDUBNSSIjVasSw?feat=embedwebsite"><img src="http://www.linjian.org/imagoxy/getimg.php?u=%3D%3DwZwpmLV1URR1Cdvh2cuVWZyN2UvADN2M3LRJkW2hFUwVjZQd1LVhlQBFUQBFUQBF0LJx2V2E3NLJES0N1LZFlQFlXMU1yXRp1Xv02bj5CdoB3Zn5yMox2LvoDc0RHa" title="" alt="从磁盘映像中挂载或提取指定分区" /></a><br />
　　回到宿主系统，使用 fdisk 的 -l、-u 参数查看磁盘映像。其中 -u 表示以扇区为单位显示分区起止位置，方便后续计算。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">root@lj-laptop:/opt/vm# fdisk -l -u vmtest.img </li>
<li>You must set cylinders.</li>
<li>You can do this from the extra functions menu.</li>
<li>&nbsp;</li>
<li>Disk vmtest.img: 0 MB, 0 bytes</li>
<li>255 heads, 63 sectors/track, 0 cylinders, total 0 sectors</li>
<li>Units = sectors of 1 * 512 = 512 bytes</li>
<li>Disk identifier: 0xbd86bd86</li>
<li>&nbsp;</li>
<li>&nbsp;&nbsp; &nbsp; Device Boot&nbsp; &nbsp; &nbsp; Start&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;End&nbsp; &nbsp; &nbsp; Blocks&nbsp; &nbsp;Id&nbsp; System</li>
<li>vmtest.img1&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 63&nbsp; &nbsp; &nbsp;8193149&nbsp; &nbsp; &nbsp;4096543+&nbsp; 83&nbsp; Linux</li>
<li>vmtest.img2&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;8193150&nbsp; &nbsp; 10249469&nbsp; &nbsp; &nbsp;1028160&nbsp; &nbsp; 5&nbsp; Extended</li>
<li>vmtest.img3&nbsp; &nbsp; &nbsp; &nbsp; 10249470&nbsp; &nbsp; 10474379&nbsp; &nbsp; &nbsp; 112455&nbsp; &nbsp; 6&nbsp; FAT16</li>
<li>vmtest.img5&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;8193213&nbsp; &nbsp; &nbsp;8610839&nbsp; &nbsp; &nbsp; 208813+&nbsp; 83&nbsp; Linux</li>
<li>vmtest.img6&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;8610903&nbsp; &nbsp; &nbsp;9028529&nbsp; &nbsp; &nbsp; 208813+&nbsp; 82&nbsp; Linux swap / Solaris</li>
<li>vmtest.img7&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;9028593&nbsp; &nbsp; 10249469&nbsp; &nbsp; &nbsp; 610438+&nbsp; &nbsp;b&nbsp; W95 FAT32</li></ol></div>
<p>　　这时我们只需要为 mount 添加 offset 参数，指定分区在磁盘映像中的逻辑地址，即可挂载这一分区。注意 offset 的单位是字节，通常一个扇区是 512 字节，因此需要用 fdisk 输出的 Start 乘以 512。以 vmtest.img3 分区为例。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">root@lj-laptop:/opt/vm# mount -o loop,offset=$((10249470*512)) vmtest.img ./part/</li>
<li>root@lj-laptop:/opt/vm# ls ./part/</li>
<li>InFAT16.txt</li>
<li>root@lj-laptop:/opt/vm# umount ./part/</li></ol></div>
<p>　　如果有必要，我们可以将特定的分区从硬盘映像中提取出来，方便单独使用。通过 dd 可以完成提取，简便起见使用扇区大小 512 字节作为 bs 参数，这样 skip、count 参数很容易从 fdisk 的输出中计算出来。下面提取 vmtest.img5。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">root@lj-laptop:/opt/vm# dd if=vmtest.img of=linux2.img bs=512 skip=8193213 count=$((8610839-8193213+1))</li>
<li>417627+0 records in</li>
<li>417627+0 records out</li>
<li>213825024 bytes (214 MB) copied, 4.67434 s, 45.7 MB/s</li>
<li>root@lj-laptop:/opt/vm# mount -o loop linux2.img ./part/</li>
<li>root@lj-laptop:/opt/vm# ls ./part/</li>
<li>InLinux2.txt&nbsp; lost+found</li>
<li>root@lj-laptop:/opt/vm# umount ./part/</li></ol></div>
<p>　　到这一步，我们已经实现了从磁盘映像中挂载或提取指定分区。其中 fdisk 帮我们完成了磁盘映像的分析，直接将分区的逻辑地址显示给了我们。现在我们再借机复习一下磁盘分区表的格式，试试手工计算相关地址。这里推荐大家阅读网上这篇《<a href="http://www.google.com/search?q=%E8%A7%A3%E8%AF%BBWindows%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E5%88%86%E5%8C%BA%E8%A1%A8%E7%9A%84%E7%A7%98%E5%AF%86">解读 Windows 操作系统分区表的秘密</a>》，其中详解过的概念这里不再赘述，下面的内容权当对这篇文章在 Linux 平台下的补充。<br />
　　首先查看磁盘映像的主引导扇区，其中分区表位于 0x1be 开始的 64 字节。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">root@lj-laptop:/opt/vm# cat vmtest.img | xxd | head -32</li>
<li>...</li>
<li>00001b0: 0000 0000 0000 0000 86bd 86bd 0000 0001&nbsp; ................</li>
<li>00001c0: 0100 83fe 7ffd 3f00 0000 3f04 7d00 0000&nbsp; ......?...?.}...</li>
<li>00001d0: 41fe 05fe bf7d 7e04 7d00 8060 1f00 0000&nbsp; A....}~.}..`....</li>
<li>00001e0: 817e 06fe bf8b fe64 9c00 8e6e 0300 0000&nbsp; .~.....d...n....</li>
<li>00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa&nbsp; ..............U.</li></ol></div>
<p>　　对于 vmtest.img1 和 vmtest.img3 这两个主分区，我们读出它们的起始逻辑地址分别为 0x3f 和 0x9c64fe（注意在分区表中以 Little-endian 存储），换算成十进制与 fdisk 输出的一致。bash 的算术表达式支持十六进制字面值，挂载方式同上。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">root@lj-laptop:/opt/vm# mount -o loop,offset=$((0x3f*512)) vmtest.img ./part/</li>
<li>root@lj-laptop:/opt/vm# ls ./part/</li>
<li>InLinux.txt&nbsp; lost+found</li>
<li>root@lj-laptop:/opt/vm# umount ./part/</li>
<li>root@lj-laptop:/opt/vm# mount -o loop,offset=$((0x9c64fe*512)) vmtest.img ./part/</li>
<li>root@lj-laptop:/opt/vm# ls ./part/</li>
<li>InFAT16.txt</li>
<li>root@lj-laptop:/opt/vm# umount ./part/</li></ol></div>
<p>　　对于扩展分区 vmtest.img2，我们通过 dd 定位到它所指向的第一个逻辑分区 vmtest.img5 前面的卷引导记录，查看逻辑分区的链式分区表。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">root@lj-laptop:/opt/vm# dd if=vmtest.img bs=512 skip=$((0x7d047e)) | xxd | head -32</li>
<li>...</li>
<li>00001b0: 0000 0000 0000 0000 0000 0000 0000 0001&nbsp; ................</li>
<li>00001c0: 41fe 83fe bf17 3f00 0000 5b5f 0600 0000&nbsp; A.....?...[_....</li>
<li>00001d0: 8118 05fe bf31 9a5f 0600 9a5f 0600 0000&nbsp; .....1._..._....</li>
<li>00001e0: 0000 0000 0000 0000 0000 0000 0000 0000&nbsp; ................</li>
<li>00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa&nbsp; ..............U.</li></ol></div>
<p>　　vmtest.img5 相对于 vmtest.img2 的偏移量为 0x3f，按此地址挂载。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">root@lj-laptop:/opt/vm# mount -o loop,offset=$(((0x7d047e+0x3f)*512)) vmtest.img ./part/</li>
<li>root@lj-laptop:/opt/vm# ls ./part/</li>
<li>InLinux2.txt&nbsp; lost+found</li>
<li>root@lj-laptop:/opt/vm# umount ./part/</li></ol></div>
<p>　　沿着链式分区表的第二条记录（即链表指针）指示的偏移量，我们可以找到第二、第三个逻辑分区（vmtest.img6、vmtest.img7）前面的卷引导记录以及这两个分区的逻辑地址。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">root@lj-laptop:/opt/vm# dd if=vmtest.img bs=512 skip=$((0x7d047e+0x65f9a)) | xxd | head -32</li>
<li>...</li>
<li>00001b0: 0000 0000 0000 0000 0000 0000 0000 0001&nbsp; ................</li>
<li>00001c0: 8118 82fe bf31 3f00 0000 5b5f 0600 0000&nbsp; .....1?...[_....</li>
<li>00001d0: 8132 05fe bf7d 34bf 0c00 4ca1 1200 0000&nbsp; .2...}4...L.....</li>
<li>00001e0: 0000 0000 0000 0000 0000 0000 0000 0000&nbsp; ................</li>
<li>00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa&nbsp; ..............U.</li>
<li>root@lj-laptop:/opt/vm# dd if=vmtest.img bs=512 skip=$((0x7d047e+0xcbf34)) | xxd | head -32</li>
<li>...</li>
<li>00001b0: 0000 0000 0000 0000 0000 0000 0000 0001&nbsp; ................</li>
<li>00001c0: 8132 0bfe bf7d 3f00 0000 0da1 1200 0000&nbsp; .2...}?.........</li>
<li>00001d0: 0000 0000 0000 0000 0000 0000 0000 0000&nbsp; ................</li>
<li>00001e0: 0000 0000 0000 0000 0000 0000 0000 0000&nbsp; ................</li>
<li>00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa&nbsp; ..............U.</li></ol></div>
<p>　　取得了相应的地址，挂载或提取分区当然是轻而易举的。下面挂载了 vmtest.img7、提取了 vmtest.img5。</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">root@lj-laptop:/opt/vm# mount -o loop,offset=$(((0x7d047e+0xcbf34+0x3f)*512)) vmtest.img ./part/</li>
<li>root@lj-laptop:/opt/vm# ls ./part/</li>
<li>InFAT32.txt</li>
<li>root@lj-laptop:/opt/vm# umount ./part/</li>
<li>root@lj-laptop:/opt/vm# dd if=vmtest.img of=linux2.img bs=512 skip=$((0x7d047e+0x3f)) count=$((0x65f5b))</li>
<li>417627+0 records in</li>
<li>417627+0 records out</li>
<li>213825024 bytes (214 MB) copied, 4.65149 s, 46.0 MB/s</li>
<li>root@lj-laptop:/opt/vm# mount -o loop ./linux2.img ./part/</li>
<li>root@lj-laptop:/opt/vm# ls ./part/</li>
<li>InLinux2.txt&nbsp; lost+found</li>
<li>root@lj-laptop:/opt/vm# umount ./part/</li></ol></div>
<hr />原文链接：<a href="http://blog.linjian.org/articles/linux-mount-part-image/">http://blog.linjian.org/articles/linux-mount-part-image/</a>，作者：<a href="http://blog.linjian.org/">林健</a>。
<br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/">知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议</a>进行许可。
<br />(Digital fingerprint: 
 993d4981d6d552510db9a08493b2dbec)<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://blog.linjian.org/articles/linux-mount-lvm-image/" title="从磁盘映像中挂载或提取指定的 LVM 逻辑卷">从磁盘映像中挂载或提取指定的 LVM 逻辑卷</a></li><li><a href="http://blog.linjian.org/articles/ubuntu-jaunty-dropbox/" title="解决 Ubuntu 9.04 下启动 Dropbox 出错的问题">解决 Ubuntu 9.04 下启动 Dropbox 出错的问题</a></li><li><a href="http://blog.linjian.org/articles/storage-trust-model/" title="浅谈存储系统的信任边界">浅谈存储系统的信任边界</a></li><li><a href="http://blog.linjian.org/articles/install-puppy-linux/" title="借助虚拟机，在移动硬盘中安装Puppy Linux">借助虚拟机，在移动硬盘中安装Puppy Linux</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.linjian.org/articles/linux-mount-part-image/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>解决 Ubuntu 登录时用户名中不能含有“@”的问题</title>
		<link>http://blog.linjian.org/articles/ubuntu-getty-input-at/</link>
		<comments>http://blog.linjian.org/articles/ubuntu-getty-input-at/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 05:19:20 +0000</pubDate>
		<dc:creator>Jian Lin</dc:creator>
				<category><![CDATA[Linux与开源]]></category>
		<category><![CDATA[getty]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[PAM]]></category>

		<guid isPermaLink="false">http://blog.linjian.org/?p=397</guid>
		<description><![CDATA[　　最近的项目需要在 Linux 中配置自定义的 PAM 做用户认证。在这个 PAM 中，用户名是 Email 的形式。该 PAM 在 CentOS 5.3 下工作正常，但在 Ubuntu 9.04 下，登录过程输入用户名时一旦按下 Email 中的“@”，之前输入的字符就会被清空（相当于 Ctrl-U，kill character 的效果），导致无法登录。我开始认为这是键盘映射的问题，但用 loadkeys 恢复标准键盘映射之后问题依旧。这也不像 stty 的错误，因为在同一个终端上登录到 shell 之后再输入“@”是正常的。于是 google 之，在相关的 HOWTO 页面找到了以下信息：

Under xdm, the default erase and kill characters are # and @, as in good old Unix Version 6.
At the first attempt, you are [...]]]></description>
			<content:encoded><![CDATA[<p>　　最近的项目需要在 Linux 中配置自定义的 <a href="http://www.kernel.org/pub/linux/libs/pam/">PAM</a> 做用户认证。在这个 PAM 中，用户名是 Email 的形式。该 PAM 在 CentOS 5.3 下工作正常，但在 Ubuntu 9.04 下，登录过程输入用户名时一旦按下 Email 中的“@”，之前输入的字符就会被清空（相当于 Ctrl-U，kill character 的效果），导致无法登录。我开始认为这是键盘映射的问题，但用 loadkeys 恢复标准键盘映射之后问题依旧。这也不像 stty 的错误，因为在同一个终端上登录到 shell 之后再输入“@”是正常的。于是 google 之，在相关的 <a href="http://tldp.org/HOWTO/Keyboard-and-Console-HOWTO-5.html">HOWTO</a> 页面找到了以下信息：</p>
<blockquote><p>
Under xdm, the default erase and kill characters are # and @, as in good old Unix Version 6.<br />
At the first attempt, you are talking to getty. At the second attempt, you are talking to login, a different program.
</p></blockquote>
<p>　　看来“@”变成 kill character 不是无中生有，而是有历史依据的；同时输入不了“@”的关键在 getty，而不在 login（实验发现如果第一遍用户名、密码输入错误，第二遍输入用户名时是可以输入“@”的，这印证了问题确实在 getty 而不在 login）。于是我 man getty，发现了问题所在：Ubuntu 上的采用的 getty 是 <a href="http://manpages.ubuntu.com/manpages/jaunty/en/man8/getty.8.html">agetty</a>，而 CentOS 上采用的是 <a href="http://sourceforge.net/projects/mingetty/">mingetty</a>。agetty 的 Manual 指出，“@”、“#”分别被用作 kill character 和 erase character，而 mingetty 并没有这一非标准的定义。agetty 的 Manual 没有说明如何取消“@”、“#”的特殊功能，我查看了它的源代码（位于 util-linux-ng 包）才发现这个特性是写死在代码中的。看来要在用户名中输入“@”，只能设法绕开 agetty。我的方法是在 Ubuntu 中安装 mingetty，然后设置系统启动时用 mingetty 代替 agetty 开启终端（/etc/event.d/tty*）：</p>
<div class="hl-surround"><ol class="hl-main ln-show" title="Double click to hide line number." ondblclick = "linenumber(this)"><li class="hl-firstline">$ sudo apt-get install mingetty</li>
<li>$ tail -1 /etc/event.d/tty1</li>
<li>exec /sbin/mingetty tty1</li></ol></div>
<p>　　重启之后，就可以用 Email 形式的用户名登录了。</p>
<hr />原文链接：<a href="http://blog.linjian.org/articles/ubuntu-getty-input-at/">http://blog.linjian.org/articles/ubuntu-getty-input-at/</a>，作者：<a href="http://blog.linjian.org/">林健</a>。
<br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/">知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议</a>进行许可。
<br />(Digital fingerprint: 
 993d4981d6d552510db9a08493b2dbec)<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://blog.linjian.org/articles/dropbear-pam-patch/" title="让 Dropbear 更好地支持 PAM">让 Dropbear 更好地支持 PAM</a></li><li><a href="http://blog.linjian.org/articles/sharp-zaurus-sl-c750/" title="Sharp Zaurus SL-C750 (Sharp CEC SL-7500)">Sharp Zaurus SL-C750 (Sharp CEC SL-7500)</a></li><li><a href="http://blog.linjian.org/articles/ubuntu-jaunty-dropbox/" title="解决 Ubuntu 9.04 下启动 Dropbox 出错的问题">解决 Ubuntu 9.04 下启动 Dropbox 出错的问题</a></li><li><a href="http://blog.linjian.org/articles/godaddy-economy-plan-hosting-ssh/" title="Godaddy Economy Plan Hosting SSH 体验">Godaddy Economy Plan Hosting SSH 体验</a></li><li><a href="http://blog.linjian.org/articles/unix-center-qyjohn/" title="赞Unix-Center.Net的蒋清野先生">赞Unix-Center.Net的蒋清野先生</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.linjian.org/articles/ubuntu-getty-input-at/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>互联网需要 Kaopulity 精神</title>
		<link>http://blog.linjian.org/articles/internet-kaopulity/</link>
		<comments>http://blog.linjian.org/articles/internet-kaopulity/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 17:15:34 +0000</pubDate>
		<dc:creator>Jian Lin</dc:creator>
				<category><![CDATA[IT杂谈]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Kaopulity]]></category>
		<category><![CDATA[怀旧]]></category>
		<category><![CDATA[服务]]></category>

		<guid isPermaLink="false">http://blog.linjian.org/?p=396</guid>
		<description><![CDATA[　　晚上整理旧文件时，我偶然发现了 2001 年申请的一个网络服务：来自 Everyone.net 的免费邮局（起初没有自己的顶级域名，我注册的邮局名为“8.mail.everyone.net”，邮箱后缀是“@8.every1.net”）。那时只是出于好奇，申请之后在同学间做过宣传，只有两三个人上去注册了自己的邮箱。最后连我自己也没怎么使用就慢慢淡忘了。八年过后，Everyone.net 竟然还保留着我的账户，登录、收发邮件一切正常。这种感觉可以用一个新学到的词汇来形容——Kaopulity。
　　这让我联想到了更早申请的另一项免费服务：来自 Webalias.com 的二级域名。这个网站真可谓是十年如一日，1998 年建立，1999 年小幅改版之后到现在界面和功能一直没有变化（Internet Archive 为证）。我在 1999 年申请的几个二级域名（to.up.to、to.stop.to、to.sail.to）至今还可以访问。试问国内有哪个类似的网络服务做到了这一点？
　　上了十年网，又有几个网站能给我留下 Kaopulity 的印象呢？数数看，自己手头有近十年历史的老账号—— Hotmail、Yahoo!、ICQ、搜狐、网易、新浪，还有已经弃用的 QQ（OICQ），其中 Hotmail 和 Yahoo! 没有出过什么大问题，始终是我较为信任的服务。2000 年前后的互联网泡沫时期，我并没有使用太多的国外服务，因此并不了解当时外国的互联网界被折腾到了什么地步。体会较深的便是 163.net、263.net 等邮箱以及网易、3322.net 等个人主页纷纷倒向收费阵营，QQ 以注册号码、申请会员为切入点发明出各种敛财花样，新浪邮箱缩水、大量个人主页服务商停止申请新账号这类事件。其后几年倒下的网站和服务我还能列举出不少——fm365.com、chinese.com、PCICQ、TomQ……免费服务如此，收费服务同样遭殃，我的第一个顶级域名“ljnu.com”（Lin Jian Networt Union）便是随着注册商“中文热站”（hothost.com）的倒台而消失的（据说这家公司是新网的前身？）
　　大学之初，我也是 Gmail 的早期测试用户，然而 2006 年遇到了一波严重的垃圾邮件攻击让我对这个号称能最有效地拦截垃圾邮件的邮箱产生了严重的怀疑。直到后来发现 Google 的服务不断改进和完善，我才在同学的劝说下第二次注册了 Gmail 账号，稳定使用至今。Google 是这个时代的胜利者之一，但在 web 2.0 时代，网站和服务 Unkaopulity 的因素也逐渐变得复杂了。市场竞争中的优胜劣汰始终是最好的理由，“测试版”的标签也是向用户和监管部门双方规避责任的良好借口。无论选择国内还是国外的服务，web 2.0 所谓用户创造内容的特性往往成为其在辉煌时期突然消失的祸根，这种例子不必多说。
　　糊里糊涂地，我们又让云计算走进了日常应用。一夜之间各类网络服务都被披上了“云”的外衣。我们何以建立云的 Kaopulity 模型？这将是一个综合了技术、政策与用户心理的难题。当然，我们经历的 Unkaopulity 多了去了，自己那点文件也值不得下大工夫维护其安全保密，重要的数据和应用本来就应该在可信域内部署和备份，想让云计算达到可用性与可靠性完美兼备是勉为其难。但是我觉得，超越了 Reliability 和 Security 范畴的、广义上的 Kaopulity，即像 [...]]]></description>
			<content:encoded><![CDATA[<p>　　晚上整理旧文件时，我偶然发现了 2001 年申请的一个网络服务：来自 <a href="http://www.everyone.net/">Everyone.net</a> 的免费邮局（起初没有自己的顶级域名，我注册的邮局名为“<a href="http://8.mail.everyone.net/">8.mail.everyone.net</a>”，邮箱后缀是“@8.every1.net”）。那时只是出于好奇，申请之后在同学间做过宣传，只有两三个人上去注册了自己的邮箱。最后连我自己也没怎么使用就慢慢淡忘了。八年过后，Everyone.net 竟然还保留着我的账户，登录、收发邮件一切正常。这种感觉可以用一个新学到的词汇来形容——<a href="http://www.google.com/search?q=kaopulity">Kaopulity</a>。<br />
　　这让我联想到了更早申请的另一项免费服务：来自 <a href="http://webalias.com/">Webalias.com</a> 的二级域名。这个网站真可谓是十年如一日，1998 年建立，1999 年小幅改版之后到现在界面和功能一直没有变化（<a href="http://www.archive.org/">Internet Archive</a> 为证）。我在 1999 年申请的几个二级域名（<a href="http://to.up.to/">to.up.to</a>、<a href="http://to.stop.to/">to.stop.to</a>、<a href="http://to.sail.to/">to.sail.to</a>）至今还可以访问。试问国内有哪个类似的网络服务做到了这一点？<br />
　　上了十年网，又有几个网站能给我留下 Kaopulity 的印象呢？数数看，自己手头有近十年历史的老账号—— Hotmail、Yahoo!、ICQ、搜狐、网易、新浪，还有已经弃用的 QQ（OICQ），其中 Hotmail 和 Yahoo! 没有出过什么大问题，始终是我较为信任的服务。2000 年前后的互联网泡沫时期，我并没有使用太多的国外服务，因此并不了解当时外国的互联网界被折腾到了什么地步。体会较深的便是 163.net、263.net 等邮箱以及网易、3322.net 等个人主页纷纷倒向收费阵营，QQ 以注册号码、申请会员为切入点发明出各种敛财花样，新浪邮箱缩水、大量个人主页服务商停止申请新账号这类事件。其后几年倒下的网站和服务我还能列举出不少——fm365.com、chinese.com、PCICQ、TomQ……免费服务如此，收费服务同样遭殃，我的第一个顶级域名“ljnu.com”（Lin Jian Networt Union）便是随着注册商“中文热站”（hothost.com）的倒台而消失的（据说这家公司是新网的前身？）<br />
　　大学之初，我也是 Gmail 的早期测试用户，然而 2006 年遇到了一波严重的垃圾邮件攻击让我对这个号称能最有效地拦截垃圾邮件的邮箱产生了严重的怀疑。直到后来发现 Google 的服务不断改进和完善，我才在同学的劝说下第二次注册了 Gmail 账号，稳定使用至今。Google 是这个时代的胜利者之一，但在 web 2.0 时代，网站和服务 Unkaopulity 的因素也逐渐变得复杂了。市场竞争中的优胜劣汰始终是最好的理由，“测试版”的标签也是向用户和监管部门双方规避责任的良好借口。无论选择国内还是国外的服务，web 2.0 所谓用户创造内容的特性往往成为其在辉煌时期突然消失的祸根，这种例子不必多说。<br />
　　糊里糊涂地，我们又让云计算走进了日常应用。一夜之间各类网络服务都被披上了“云”的外衣。我们<a href="http://blog.linjian.org/articles/storage-trust-model/">何以建立云的 Kaopulity 模型</a>？这将是一个综合了技术、政策与用户心理的难题。当然，我们经历的 Unkaopulity 多了去了，自己那点文件也值不得下大工夫维护其安全保密，重要的数据和应用本来就应该在可信域内部署和备份，想让云计算达到可用性与可靠性完美兼备是勉为其难。但是我觉得，超越了 Reliability 和 Security 范畴的、广义上的 Kaopulity，即像 Everyone.net、Webalias.com 那样十年如一日的精神，才是当前的互联网服务商需要倍加重视的——因为云时代的服务商承载的不仅仅是应用程序，而是他人的事业，自己的信用。</p>
<hr />原文链接：<a href="http://blog.linjian.org/articles/internet-kaopulity/">http://blog.linjian.org/articles/internet-kaopulity/</a>，作者：<a href="http://blog.linjian.org/">林健</a>。
<br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/2.5/cn/">知识共享署名-非商业性使用-相同方式共享 2.5 中国大陆许可协议</a>进行许可。
<br />(Digital fingerprint: 
 993d4981d6d552510db9a08493b2dbec)<h3  class="related_post_title">相关文章</h3><ul class="related_post"><li><a href="http://blog.linjian.org/articles/create-your-private-bit-ly-and-twitpic/" title="Create your private bit.ly and twitpic">Create your private bit.ly and twitpic</a></li><li><a href="http://blog.linjian.org/articles/identity-20-4-conclusion/" title="Identity 2.0 何时真正到来？（四）用户价值决定前途走向">Identity 2.0 何时真正到来？（四）用户价值决定前途走向</a></li><li><a href="http://blog.linjian.org/articles/identity-20-3-i-name/" title="Identity 2.0 何时真正到来？（三）生财有道的 i-name">Identity 2.0 何时真正到来？（三）生财有道的 i-name</a></li><li><a href="http://blog.linjian.org/articles/identity-20-2-information-card/" title="Identity 2.0 何时真正到来？（二）处境尴尬的 Information Card">Identity 2.0 何时真正到来？（二）处境尴尬的 Information Card</a></li><li><a href="http://blog.linjian.org/articles/identity-20-1-openid/" title="Identity 2.0 何时真正到来？（一）小有所成的 OpenID">Identity 2.0 何时真正到来？（一）小有所成的 OpenID</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.linjian.org/articles/internet-kaopulity/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
