<?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>I am LAZY bones ?</title>
	<atom:link href="http://li2z.cn/feed/" rel="self" type="application/rss+xml" />
	<link>http://li2z.cn</link>
	<description>all linux</description>
	<lastBuildDate>Wed, 10 Mar 2010 06:38:01 +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>linux下的“虚拟光驱”</title>
		<link>http://li2z.cn/2010/03/10/virtual_cdrom_in_linux/</link>
		<comments>http://li2z.cn/2010/03/10/virtual_cdrom_in_linux/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 06:38:01 +0000</pubDate>
		<dc:creator>bones7456</dc:creator>
				<category><![CDATA[CLI软件]]></category>

		<guid isPermaLink="false">http://li2z.cn/?p=1397</guid>
		<description><![CDATA[每当有人问我“你的linux下有没有类似‘虚拟光驱’的软件呢？”的时候，我就会轻轻一笑，自豪地说“别把事情想得太复杂，linux下根本就不用什么另外的软件，就能虚拟光驱了。”，然后那人一般就会似懂非懂地说一句：“哦。。这样啊~”
下面，就来介绍几个虚拟光驱相关的命令：
把物理光盘做成iso镜像，下面几个命令几乎等效，假设设备是/dev/cdrom：

cp /dev/cdrom xxx.iso


dd if=/dev/cdrom of=xxx.iso


mkisofs -r -o xxx.iso /dev/cdrom


readcd -v dev=/dev/cdrom -f xxx.iso

其中，用mkisofs还可以把一个文件夹模拟成iso：

mkisofs -o xxx.iso /path/to/tree

如果要使用iso文件的话，就更简单了，可以mount到任意目录下：

mount -o loop xxx.iso /path

注意以上某些命令可能需要root权限。
不过，还有个终极问题没有解决，我手头有一张《浙江省汽车驾驶人理科考试智能》的光盘，估计是用了什么防拷贝技术，使用以上方法都无法正确生成ISO文件，也无法全部复制里面的内容，具体操作过程如下：

lily@LLY:~$ sudo mount -o ro,loop /dev/sr0 qc
lily@LLY:~$ ls qc
试题10.db  试题11.db  试题12.db  试题1.db  试题2.db  试题3.db  试题4.db  试题5.db  试题6.db  试题7.db  试题8.db  试题9.db
lily@LLY:~$ sudo umount qc
lily@LLY:~$ sudo mount [...]]]></description>
			<content:encoded><![CDATA[<p>每当有人问我“你的linux下有没有类似‘虚拟光驱’的软件呢？”的时候，我就会轻轻一笑，自豪地说“别把事情想得太复杂，linux下根本就不用什么另外的软件，就能虚拟光驱了。”，然后那人一般就会似懂非懂地说一句：“哦。。这样啊~”<br />
下面，就来介绍几个虚拟光驱相关的命令：<br />
把物理光盘做成iso镜像，下面几个命令几乎等效，假设设备是/dev/cdrom：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>cdrom xxx.iso</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">dd</span> <span style="color: #007800;"><span style="color: #000000; font-weight: bold;">if</span></span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>cdrom <span style="color: #007800;">of</span>=xxx.iso</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mkisofs <span style="color: #660033;">-r</span> <span style="color: #660033;">-o</span> xxx.iso <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>cdrom</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">readcd <span style="color: #660033;">-v</span> <span style="color: #007800;">dev</span>=<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>cdrom <span style="color: #660033;">-f</span> xxx.iso</pre></div></div>

<p>其中，用mkisofs还可以把一个文件夹模拟成iso：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">mkisofs <span style="color: #660033;">-o</span> xxx.iso <span style="color: #000000; font-weight: bold;">/</span>path<span style="color: #000000; font-weight: bold;">/</span>to<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">tree</span></pre></div></div>

<p>如果要使用iso文件的话，就更简单了，可以mount到任意目录下：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> loop xxx.iso <span style="color: #000000; font-weight: bold;">/</span>path</pre></div></div>

<p>注意以上某些命令可能需要root权限。</p>
<p>不过，还有个终极问题没有解决，我手头有一张《浙江省汽车驾驶人理科考试智能》的光盘，估计是用了什么防拷贝技术，使用以上方法都无法正确生成ISO文件，也无法全部复制里面的内容，具体操作过程如下：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">lily<span style="color: #000000; font-weight: bold;">@</span>LLY:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> ro,loop <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sr0 qc
lily<span style="color: #000000; font-weight: bold;">@</span>LLY:~$ <span style="color: #c20cb9; font-weight: bold;">ls</span> qc
试题10.db  试题11.db  试题12.db  试题1.db  试题2.db  试题3.db  试题4.db  试题5.db  试题6.db  试题7.db  试题8.db  试题9.db
lily<span style="color: #000000; font-weight: bold;">@</span>LLY:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">umount</span> qc
lily<span style="color: #000000; font-weight: bold;">@</span>LLY:~$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> ro <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>sr0 qc
lily<span style="color: #000000; font-weight: bold;">@</span>LLY:~$ <span style="color: #c20cb9; font-weight: bold;">ls</span> qc
<span style="color: #000000;">2009</span>理论模拟考试.exe  AutoRun.ico  AutoRun.rdt  system               试题10.db  试题1.db  试题4.db  试题7.db
AutoRun.ard           autorun.inf  htm          安装使用说明.html    试题11.db  试题2.db  试题5.db  试题8.db
AutoRun.exe           autorun.pro  image.jpg    读安装使用说明.html  试题12.db  试题3.db  试题6.db  试题9.db
lily<span style="color: #000000; font-weight: bold;">@</span>LLY:~$ <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #660033;">-r</span> qc qc1
<span style="color: #c20cb9; font-weight: bold;">cp</span>: 正在读入<span style="color: #ff0000;">&quot;qc/试题3.db&quot;</span>: 输入<span style="color: #000000; font-weight: bold;">/</span>输出错误
<span style="color: #c20cb9; font-weight: bold;">cp</span>: 正在读入<span style="color: #ff0000;">&quot;qc/试题4.db&quot;</span>: 输入<span style="color: #000000; font-weight: bold;">/</span>输出错误
<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>lily<span style="color: #000000; font-weight: bold;">@</span>LLY:~$ <span style="color: #c20cb9; font-weight: bold;">ls</span> qc1
<span style="color: #000000;">2009</span>理论模拟考试.exe  AutoRun.ico  AutoRun.rdt  system               试题10.db  试题1.db  试题4.db  试题7.db
AutoRun.ard           autorun.inf  htm          安装使用说明.html    试题11.db  试题2.db  试题5.db  试题8.db
AutoRun.exe           autorun.pro  image.jpg    读安装使用说明.html  试题12.db  试题3.db  试题6.db  试题9.db
lily<span style="color: #000000; font-weight: bold;">@</span>LLY:~$ <span style="color: #c20cb9; font-weight: bold;">du</span> <span style="color: #660033;">-s</span> qc qc1
<span style="color: #000000;">398463</span>	qc
<span style="color: #000000;">349720</span>	qc1</pre></div></div>

<p>有谁知道这种变态的光盘怎么搞定吗？</p>
]]></content:encoded>
			<wfw:commentRss>http://li2z.cn/2010/03/10/virtual_cdrom_in_linux/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>点击触摸板模拟左键单击</title>
		<link>http://li2z.cn/2010/03/07/synaptics_tapbutton/</link>
		<comments>http://li2z.cn/2010/03/07/synaptics_tapbutton/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 11:40:00 +0000</pubDate>
		<dc:creator>bones7456</dc:creator>
				<category><![CDATA[流水帐]]></category>

		<guid isPermaLink="false">http://li2z.cn/?p=1393</guid>
		<description><![CDATA[这几天估计是比较背，刚说我的神舟本2年都没啥问题，结果，前几天发现光驱读盘能力不行了，最近又发现触摸板的左键也不灵了，要按得很重才能产生一次有效的单击事件，双击就更难了。这样下去，手指都要按残了，唉~
然后试了下，轻触触摸板模拟鼠标单击的功能在我的gentoo下默认是无效的，于是第一个想到的就是 xorg.conf 这个即将成为历史的东西。但是我已经不用这个配置文件很久了，现在为了触摸板，没办法，看来只能再请它出山了。于是翻出我的配置文件，在 Section &#8220;InputDevice&#8221; 一节里加上 Option	&#8220;TapButton1&#8243; &#8220;1&#8243; 这行，一边心里在纳闷为什么X不默认启用这项呢？
加完重启了X以后，在登录界面试了一下，嘿嘿，果然可以了点击了，于是兴高采烈地登录我的gnome，结果再一看，怎么又不行了呢？明明刚才还可以的啊。难道是gnome的问题？上网一查，发现果然是，在gnome的“系统”->“首选项”->“鼠标”->“触摸板”里，有一项“Enable mouse clicks with touchpad”，勾上这个就好了。
然后再一转念，那在 xorg.conf 里的设置不是多此一举了吗？毕竟我不怎么关心登录界面能不能点击啊。
于是重新删除了 xorg.conf 重启X，登录gnome以后，果然也是可以的。
至此终于知道X为什么不默认启用触摸板点击了，哈哈，既然有DE做这个事情，自然就可以偷偷懒了，不过不知道用*box之类的WM的用户是怎么设置呢？
]]></description>
			<content:encoded><![CDATA[<p>这几天估计是比较背，刚说我的神舟本2年都没啥问题，结果，前几天发现光驱读盘能力不行了，最近又发现触摸板的左键也不灵了，要按得很重才能产生一次有效的单击事件，双击就更难了。这样下去，手指都要按残了，唉~<br />
然后试了下，轻触触摸板模拟鼠标单击的功能在我的gentoo下默认是无效的，于是第一个想到的就是 xorg.conf 这个即将成为历史的东西。但是我已经不用这个配置文件很久了，现在为了触摸板，没办法，看来只能再请它出山了。于是翻出我的配置文件，在 Section &#8220;InputDevice&#8221; 一节里加上 Option	&#8220;TapButton1&#8243; &#8220;1&#8243; 这行，一边心里在纳闷为什么X不默认启用这项呢？<br />
加完重启了X以后，在登录界面试了一下，嘿嘿，果然可以了点击了，于是兴高采烈地登录我的gnome，结果再一看，怎么又不行了呢？明明刚才还可以的啊。难道是gnome的问题？上网一查，发现果然是，在gnome的“系统”->“首选项”->“鼠标”->“触摸板”里，有一项“Enable mouse clicks with touchpad”，勾上这个就好了。<br />
然后再一转念，那在 xorg.conf 里的设置不是多此一举了吗？毕竟我不怎么关心登录界面能不能点击啊。<br />
于是重新删除了 xorg.conf 重启X，登录gnome以后，果然也是可以的。<br />
至此终于知道X为什么不默认启用触摸板点击了，哈哈，既然有DE做这个事情，自然就可以偷偷懒了，不过不知道用*box之类的WM的用户是怎么设置呢？</p>
]]></content:encoded>
			<wfw:commentRss>http://li2z.cn/2010/03/07/synaptics_tapbutton/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>清理ubuntu老内核的小脚本</title>
		<link>http://li2z.cn/2010/02/28/clean_ubuntu_kernel/</link>
		<comments>http://li2z.cn/2010/02/28/clean_ubuntu_kernel/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 13:19:27 +0000</pubDate>
		<dc:creator>bones7456</dc:creator>
				<category><![CDATA[流水帐]]></category>

		<guid isPermaLink="false">http://li2z.cn/?p=1390</guid>
		<description><![CDATA[ubuntu用久了，升级了几次内核以后，就免不了需要清理一下老的内核，毕竟一套内核就有170多M的空间呢。但是每次都打一堆字来清理也烦了。虽然Ubuntu 命令技巧（这里再罗嗦几句：如果还有ubuntuer没看过这个，强烈建议看一遍。）里有删除旧内核的命令，而且就一行：

sudo aptitude purge ~ilinux-image-.*\&#40;\!`uname -r`\&#41;

但是我却不是很喜欢，因为这这个没有把linux-headers-xxx删除掉。
于是自己写了个繁的，需要的可以自己保存，以便不时之需。

#!/bin/sh
# 清理ubuntu的老内核
# by bones7456
# http://li2z.cn
CURRENT=&#34;`uname -r &#124; awk -F&#34;-&#34; '{print $1&#34;-&#34;$2}'`&#34;
HEADERS=&#34;&#34;
IMAGES=&#34;&#34;
for HEADER in `dpkg --get-selections &#124; grep ^linux-headers &#124; \
grep -vE &#34;(generic&#124;386&#124;virtual)&#34; &#124; awk '{gsub(/linux-headers-/,&#34;&#34;,$1);print $1}'`
do
    if &#91;&#91; &#34;$CURRENT&#34; &#60; &#34;$HEADER&#34; &#93;&#93;
    then
        echo &#34;正在运行的内核不是最新的。 $CURRENT &#60; [...]]]></description>
			<content:encoded><![CDATA[<p>ubuntu用久了，升级了几次内核以后，就免不了需要清理一下老的内核，毕竟一套内核就有170多M的空间呢。但是每次都打一堆字来清理也烦了。虽然<a href="http://wiki.ubuntu.org.cn/index.php?title=UbuntuSkills">Ubuntu 命令技巧</a>（这里再罗嗦几句：如果还有ubuntuer没看过这个，强烈建议看一遍。）里有<a href="http://wiki.ubuntu.org.cn/index.php?title=UbuntuSkills&#038;variant=zh-cn#.E5.88.A0.E9.99.A4.E6.97.A7.E5.86.85.E6.A0.B8">删除旧内核</a>的命令，而且就一行：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> purge ~ilinux-image-.<span style="color: #000000; font-weight: bold;">*</span>\<span style="color: #7a0874; font-weight: bold;">&#40;</span>\<span style="color: #000000; font-weight: bold;">!`</span><span style="color: #c20cb9; font-weight: bold;">uname</span> -r<span style="color: #000000; font-weight: bold;">`</span>\<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>但是我却不是很喜欢，因为这这个没有把linux-headers-xxx删除掉。<br />
于是自己写了个繁的，需要的可以自己保存，以便不时之需。</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
<span style="color: #666666; font-style: italic;"># 清理ubuntu的老内核</span>
<span style="color: #666666; font-style: italic;"># by bones7456</span>
<span style="color: #666666; font-style: italic;"># http://li2z.cn</span>
<span style="color: #007800;">CURRENT</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`uname -r | awk -F&quot;-&quot; '{print $1&quot;-&quot;$2}'`</span>&quot;</span>
<span style="color: #007800;">HEADERS</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #007800;">IMAGES</span>=<span style="color: #ff0000;">&quot;&quot;</span>
<span style="color: #000000; font-weight: bold;">for</span> HEADER <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">dpkg</span> <span style="color: #660033;">--get-selections</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> ^linux-headers <span style="color: #000000; font-weight: bold;">|</span> \
<span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-vE</span> <span style="color: #ff0000;">&quot;(generic|386|virtual)&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">awk</span> <span style="color: #ff0000;">'{gsub(/linux-headers-/,&quot;&quot;,$1);print $1}'</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CURRENT</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$HEADER</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;正在运行的内核不是最新的。 <span style="color: #007800;">$CURRENT</span> &lt; <span style="color: #007800;">$HEADER</span>&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Running kernel is not the newest. <span style="color: #007800;">$CURRENT</span> &lt; <span style="color: #007800;">$HEADER</span>&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
    <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CURRENT</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;<span style="color: #007800;">$HEADER</span>&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
            <span style="color: #007800;">HEADERS</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${HEADERS}</span> linux-headers-<span style="color: #007800;">${HEADER}</span>&quot;</span>
            <span style="color: #007800;">IMAGE</span>=<span style="color: #ff0000;">&quot;<span style="color: #780078;">`dpkg --get-selections | grep ^linux-image | \
                grep &quot;${HEADER}&quot; | awk '{print $1}'`</span>&quot;</span>
            <span style="color: #007800;">IMAGES</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${IMAGES}</span> <span style="color: #007800;">$IMAGE</span>&quot;</span>
        <span style="color: #7a0874; font-weight: bold;">&#125;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> x<span style="color: #ff0000;">&quot;<span style="color: #007800;">$HEADERS</span>&quot;</span> == x<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;没有要清理的老内核.&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;No old kernel need to clean.&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #007800;">CMD</span>=<span style="color: #ff0000;">&quot;sudo apt-get purge <span style="color: #007800;">$HEADERS</span> <span style="color: #007800;">$IMAGES</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CMD</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> == <span style="color: #ff0000;">&quot;-e&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$CMD</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;请确定以上命令是否正确，然后输入 $0 -e 来执行以上命令。&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Be sure this command is right, then type $0 -e to execute.&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://li2z.cn/2010/02/28/clean_ubuntu_kernel/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>我也玩了下WIN7</title>
		<link>http://li2z.cn/2010/02/26/win7/</link>
		<comments>http://li2z.cn/2010/02/26/win7/#comments</comments>
		<pubDate>Fri, 26 Feb 2010 06:18:50 +0000</pubDate>
		<dc:creator>bones7456</dc:creator>
				<category><![CDATA[流水帐]]></category>

		<guid isPermaLink="false">http://li2z.cn/?p=1386</guid>
		<description><![CDATA[曾经，我也有一个XP，虽然平时很少用到，但是在偶尔想玩玩游戏、或者要用到网银的时候，还是要发挥一下作用的，而且曾经的深度精简版也不是很占空间，于是，这个NTFS分区，就一直静静地留在了我的硬盘里了。
直到去年末，回老家办婚礼摆酒的时候，家里人来人往地比较多，有时候有的亲戚朋友要用下电脑，我不可能开个gentoo给人家啊，于是就打开这个XP，没过几天，再去看的时候，发现XP已经中毒很深了。。。要知道我这XP可是没有任何杀软的啊。唉，脆弱的win啊~
于是，这段时间也陆陆续续想了不少办法来拯救这个可恶的XP：曾经在linux下给它杀毒，杀出一堆来，能登录了却慢得出奇，常常还有不可预计的问题；曾经想用虚拟机里XP的文件来覆盖系统文件，要么不管用，要么启动的时候直接蓝屏，搞得我一点办法都没有；甚至也想过重装，但是发现我的光驱已经不能读盘了，无法从光盘引导；也试过硬盘安装，DOS也进去了，执行XP安装程序的时候，却总是说没有什么临时文件的空间。。。
搞得我只能把这个分区的所有文件都删了，后来，花花说硬盘安装WIN7比较方便，抱着试试看的心态，去下了个本以为永远不会去装的win7镜像，开始折腾。
下载到的文件名为 m2.wim ，要用一个叫 ImageX 的玩意打开或者挂载，于是在虚拟机里挂载以后，把文件都提取出来了，最终都放到原来那个NTFS分区的根目录里，一共只有5个目录和一个文件：Boot、Program Files、ProgramData、Users、Windows和bootmgr，很显然，bootmgr就是用于引导的文件，但是原来XP里的引导文件叫做NTLDR啊，grub也只会引导这个文件，所以把bootmgr又复制了一份叫NTLDR，然后直接重启，grub里选择原来XP的条目，一回车，还真进去了。。。
首次进入系统，会自动安装一堆驱动，我这个神舟本除了显卡驱动没认出来，分辨率只上到1440×1050外，其他硬件基本都能自己装好驱动，装好后重启一次，再下个显卡驱动，默认就是下面这个样子了，哈哈：

还蛮舒服的哈，大小也比较合理，wim文件是 350M ，解压后是800多M，装好以后包括一些软件在1.5G以内吧。
虽然偶尔也会有如图的“内存不能为read”的经典又深奥的错误，但是谁在乎呢？
看来，以后真要告别XP喽~
]]></description>
			<content:encoded><![CDATA[<p>曾经，我也有一个XP，虽然平时很少用到，但是在偶尔想玩玩游戏、或者要用到<a href="http://li2z.cn/2009/12/13/netbank/">网银</a>的时候，还是要发挥一下作用的，而且曾经的深度精简版也不是很占空间，于是，这个NTFS分区，就一直静静地留在了我的硬盘里了。<br />
直到去年末，回老家办婚礼摆酒的时候，家里人来人往地比较多，有时候有的亲戚朋友要用下电脑，我不可能开个gentoo给人家啊，于是就打开这个XP，没过几天，再去看的时候，发现XP已经中毒很深了。。。要知道我这XP可是没有任何杀软的啊。唉，脆弱的win啊~<br />
于是，这段时间也陆陆续续想了不少办法来拯救这个可恶的XP：曾经在linux下给它杀毒，杀出一堆来，能登录了却慢得出奇，常常还有不可预计的问题；曾经想用虚拟机里XP的文件来覆盖系统文件，要么不管用，要么启动的时候直接蓝屏，搞得我一点办法都没有；甚至也想过重装，但是发现我的光驱已经不能读盘了，无法从光盘引导；也试过硬盘安装，DOS也进去了，执行XP安装程序的时候，却总是说没有什么临时文件的空间。。。<br />
搞得我只能把这个分区的所有文件都删了，后来，花花说硬盘安装WIN7比较方便，抱着试试看的心态，去下了个本以为永远不会去装的win7镜像，开始折腾。<br />
下载到的文件名为 m2.wim ，要用一个叫 ImageX 的玩意打开或者挂载，于是在虚拟机里挂载以后，把文件都提取出来了，最终都放到原来那个NTFS分区的根目录里，一共只有5个目录和一个文件：Boot、Program Files、ProgramData、Users、Windows和bootmgr，很显然，bootmgr就是用于引导的文件，但是原来XP里的引导文件叫做NTLDR啊，grub也只会引导这个文件，所以把bootmgr又复制了一份叫NTLDR，然后直接重启，grub里选择原来XP的条目，一回车，还真进去了。。。<br />
首次进入系统，会自动安装一堆驱动，我这个<a href="http://li2z.cn/2008/03/04/hasee/">神舟本</a>除了显卡驱动没认出来，分辨率只上到1440×1050外，其他硬件基本都能自己装好驱动，装好后重启一次，再下个显卡驱动，默认就是下面这个样子了，哈哈：<br />
<a href="http://li2z.cn/wp-content/uploads/2010/02/win7.png"><img src="http://li2z.cn/wp-content/uploads/2010/02/win7-150x150.png" alt="" title="win7" width="150" height="150" class="alignnone size-thumbnail wp-image-1387" /></a><br />
还蛮舒服的哈，大小也比较合理，wim文件是 350M ，解压后是800多M，装好以后包括一些软件在1.5G以内吧。<br />
虽然偶尔也会有如图的“内存不能为read”的经典又深奥的错误，但是谁在乎呢？<br />
看来，以后真要告别XP喽~</p>
]]></content:encoded>
			<wfw:commentRss>http://li2z.cn/2010/02/26/win7/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>让ubuntu也来帮gentoo编译</title>
		<link>http://li2z.cn/2010/02/23/distccd/</link>
		<comments>http://li2z.cn/2010/02/23/distccd/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 07:29:43 +0000</pubDate>
		<dc:creator>bones7456</dc:creator>
				<category><![CDATA[gentoo]]></category>

		<guid isPermaLink="false">http://li2z.cn/?p=1377</guid>
		<description><![CDATA[最近，貌似关于gentoo的新闻越来越多了。刚又听说，chrome OS的宿主系统已经从ubuntu转向gentoo了，其实，我对这个倒是一点都不感到意外，gentoo对于这种特定的应用，可定制性显然比ubuntu强很多，让我来选的话也会选gentoo的。只是觉得一向低调的gentoo被google这么一搞，也许以后都没有办法再低调了，哈哈。
好像有点扯远了，说到gentoo，大家肯定会想到无休止的编译，也确实，gentoo的编译是比较费时间的，尤其是在性能不怎么强悍的机器上，比如跑着chrome的上网本里。如果你另外有几台强悍些的台式机或者服务器的话，其实可以把编译的工作分担一部分给强悍的机器。这时候就要用到distcc了。
distcc是一个通过网络进行分布式编译的工具，它包含两部分，一部分是服务端程序 distccd，一部分是客户端程序 distcc。大致的原理就是，distcc连接一个或多个distccd，有编译任务的时候，distcc依次并行地把C或C++文件分发给各distccd，distccd调用它们本地的编译器编译出 .o 文件以后，再发回给distcc，另外，configure和link等工作还是由客户端自己来完成。
这样一来，对各服务端的系统也就有了一个额外的要求：必须保证服务端和客户端的gcc版本是一致的，否则出来的.o肯定link不了啊，呵呵。
如果你的客户端和服务端都装的是gentoo，采用的一样的架构和keywords，那其实这个要求还是很好满足的：两边都升到最新即可，这样配置方法可以参考官方文档。
但是如果你想用装着ubuntu、fedora、RHEL等发行版的服务端的话，就有点困难了，gentoo如果开了~x86的话，gcc的版本很容易就比这些发行版高出一大截了。
本文就是要解决这个问题的：
解决的思路，就是利用chroot，在各发行版里构建一套没有内核的gentoo系统（因为有kernel也用不着嘛），然后把里面的编译环境都升级到最新，再在里面安装运行distccd。
条件是你需要有server的root权限。
方法其实也不难，大致如下：

#建立gentoo的根目录，这里最好有&#62;1.5G的硬盘空间，不然会不够用
mkdir gentoo
cd gentoo
#可以从 http://www.gentoo.org/main/en/mirrors.xml 这里选择速度快的mirror。
#下载你需要的架构的stage3
wget http://gentoo.cs.nctu.edu.tw/gentoo/releases/x86/current-stage3/stage3-i686-20100126.tar.bz2
#下载最新的portage树，其实不下也是可以的，不过后面emerge --sync的时候会慢些。
wget http://gentoo.cs.nctu.edu.tw/gentoo/snapshots/portage-latest.tar.bz2
#释放文件
tar xvf stage3-i686-20100126.tar.bz2 -C .
tar xvf portage-latest.tar.bz2 -C usr/
#清理现场
rm stage3-i686-20100126.tar.bz2 portage-latest.tar.bz2

然后，为了方便起见，在当前目录写一个gogentoo的脚本，内容如下，加上可执行权限：

#!/bin/bash
&#160;
&#91;&#91; $UID == 0 &#93;&#93; &#124;&#124; &#123; echo &#34;Must be root to go gentoo.&#34;; exit 0; &#125;
&#160;
cp /etc/resolv.conf etc/
mount -t proc proc proc/
mount -o bind /dev dev/
chroot . /bin/bash

然后执行 sudo ./gogentoo 就进入gentoo环境了。进去以后执行：

env-update
source /etc/profile
&#160;
#添加 [...]]]></description>
			<content:encoded><![CDATA[<p>最近，貌似关于gentoo的新闻越来越多了。刚又听说，<a href="http://imtx.cn/archives/1429.html">chrome OS的宿主系统已经从ubuntu转向gentoo</a>了，其实，我对这个倒是一点都不感到意外，gentoo对于这种特定的应用，可定制性显然比ubuntu强很多，让我来选的话也会选gentoo的。只是觉得一向低调的gentoo被google这么一搞，也许以后都没有办法再低调了，哈哈。<br />
好像有点扯远了，说到gentoo，大家肯定会想到无休止的编译，也确实，gentoo的编译是比较费时间的，尤其是在性能不怎么强悍的机器上，比如跑着chrome的上网本里。如果你另外有几台强悍些的台式机或者服务器的话，其实可以把编译的工作分担一部分给强悍的机器。这时候就要用到distcc了。<br />
distcc是一个通过网络进行分布式编译的工具，它包含两部分，一部分是服务端程序 distccd，一部分是客户端程序 distcc。大致的原理就是，distcc连接一个或多个distccd，有编译任务的时候，distcc依次并行地把C或C++文件分发给各distccd，distccd调用它们本地的编译器编译出 .o 文件以后，再发回给distcc，另外，configure和link等工作还是由客户端自己来完成。<br />
这样一来，对各服务端的系统也就有了一个额外的要求：必须保证服务端和客户端的gcc版本是一致的，否则出来的.o肯定link不了啊，呵呵。<br />
如果你的客户端和服务端都装的是gentoo，采用的一样的架构和keywords，那其实这个要求还是很好满足的：两边都升到最新即可，这样配置方法可以参考<a href="http://www.gentoo.org/doc/en/distcc.xml">官方文档</a>。<br />
但是如果你想用装着ubuntu、fedora、RHEL等发行版的服务端的话，就有点困难了，gentoo如果开了~x86的话，gcc的版本很容易就比这些发行版高出一大截了。<br />
本文就是要解决这个问题的：</p>
<p><strong>解决的思路</strong>，就是利用chroot，在各发行版里构建一套没有内核的gentoo系统（因为有kernel也用不着嘛），然后把里面的编译环境都升级到最新，再在里面安装运行distccd。<br />
<strong>条件</strong>是你需要有server的root权限。<br />
<strong>方法</strong>其实也不难，大致如下：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#建立gentoo的根目录，这里最好有&gt;1.5G的硬盘空间，不然会不够用</span>
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> gentoo
<span style="color: #7a0874; font-weight: bold;">cd</span> gentoo
<span style="color: #666666; font-style: italic;">#可以从 http://www.gentoo.org/main/en/mirrors.xml 这里选择速度快的mirror。</span>
<span style="color: #666666; font-style: italic;">#下载你需要的架构的stage3</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>gentoo.cs.nctu.edu.tw<span style="color: #000000; font-weight: bold;">/</span>gentoo<span style="color: #000000; font-weight: bold;">/</span>releases<span style="color: #000000; font-weight: bold;">/</span>x86<span style="color: #000000; font-weight: bold;">/</span>current-stage3<span style="color: #000000; font-weight: bold;">/</span>stage3-i686-20100126.tar.bz2
<span style="color: #666666; font-style: italic;">#下载最新的portage树，其实不下也是可以的，不过后面emerge --sync的时候会慢些。</span>
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>gentoo.cs.nctu.edu.tw<span style="color: #000000; font-weight: bold;">/</span>gentoo<span style="color: #000000; font-weight: bold;">/</span>snapshots<span style="color: #000000; font-weight: bold;">/</span>portage-latest.tar.bz2
<span style="color: #666666; font-style: italic;">#释放文件</span>
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvf stage3-i686-20100126.tar.bz2 <span style="color: #660033;">-C</span> .
<span style="color: #c20cb9; font-weight: bold;">tar</span> xvf portage-latest.tar.bz2 <span style="color: #660033;">-C</span> usr<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #666666; font-style: italic;">#清理现场</span>
<span style="color: #c20cb9; font-weight: bold;">rm</span> stage3-i686-20100126.tar.bz2 portage-latest.tar.bz2</pre></div></div>

<p>然后，为了方便起见，在当前目录写一个gogentoo的脚本，内容如下，加上可执行权限：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$UID</span> == <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #000000; font-weight: bold;">||</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span> <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Must be root to go gentoo.&quot;</span>; <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">0</span>; <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>resolv.conf etc<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-t</span> proc proc proc<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> <span style="color: #7a0874; font-weight: bold;">bind</span> <span style="color: #000000; font-weight: bold;">/</span>dev dev<span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #c20cb9; font-weight: bold;">chroot</span> . <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></pre></div></div>

<p>然后执行 sudo ./gogentoo 就进入gentoo环境了。进去以后执行：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">env-update
<span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>profile
&nbsp;
<span style="color: #666666; font-style: italic;">#添加 ~x86 的keywords，请按需修改成你自己的。</span>
<span style="color: #c20cb9; font-weight: bold;">nano</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>make.conf
<span style="color: #666666; font-style: italic;">#更新系统</span>
emerge <span style="color: #660033;">--sync</span>
emerge <span style="color: #660033;">-avuDN</span> world
<span style="color: #666666; font-style: italic;">#完成以后，一般还需要gcc-config到最新的gcc版本。然后清理系统</span>
emerge <span style="color: #660033;">--depclean</span> <span style="color: #660033;">-av</span>
<span style="color: #666666; font-style: italic;">#最后安装distcc</span>
emerge distcc</pre></div></div>

<p>到了这里，服务端的软件环境就算准备完毕了，你可以对比下两边的</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">gcc</span> <span style="color: #660033;">--version</span></pre></div></div>

<p>的输出，看看是否完全一致。<br />
不过，如果你在chroot环境下，直接执行 /etc/init.d/distccd start 来启动服务的话，多半是会遇到错误的，会提示什么udev有问题，我也没深究。不过既然不让启动服务的话，我手工启动总好了吧，于是执行：</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">distccd <span style="color: #660033;">--port</span> <span style="color: #000000;">3632</span> <span style="color: #660033;">--log-file</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>distccd <span style="color: #660033;">--log-level</span> critical <span style="color: #660033;">--allow</span> client的IP <span style="color: #660033;">-N</span> <span style="color: #000000;">15</span></pre></div></div>

<p>这样启动的distccd也照样能工作，哈哈。<br />
以上步骤在 i686-pc-linux-gnu 的gentoo client 和 ubuntu 9.10 的server上试验通过。理论上这样做好的gentoo，应该是可以从ubuntu打包出来，到其他发行版直接用的，这样就很方便做出一个灰常强大的编译集群了，哈哈，改天试试看。</p>
<p>接下来就是配置你的client来使用这个server了，这个就和普通的没区别了，这里也先不讨论了，如有必要，另外再写一篇就好，呵呵。</p>
]]></content:encoded>
			<wfw:commentRss>http://li2z.cn/2010/02/23/distccd/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>
