<?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>apt-blog.net   无证程序员的PT桑 &#187; Ubuntu</title> <atom:link href="http://apt-blog.net/tag/ubuntu/feed" rel="self" type="application/rss+xml" /><link>http://apt-blog.net</link> <description>潜逃中。</description> <lastBuildDate>Sat, 26 Nov 2011 07:45:40 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>Nginx + PHP (via php-fpm) on Ubuntu 环境最佳实践</title><link>http://apt-blog.net/best-practise-nginx-php-via-php-fpm-on-ubuntu</link> <comments>http://apt-blog.net/best-practise-nginx-php-via-php-fpm-on-ubuntu#comments</comments> <pubDate>Thu, 21 Jul 2011 11:01:31 +0000</pubDate> <dc:creator>BOYPT</dc:creator> <category><![CDATA[Unix/Linux]]></category> <category><![CDATA[nginx]]></category> <category><![CDATA[php]]></category> <category><![CDATA[Ubuntu]]></category> <guid
isPermaLink="false">http://apt-blog.net/nginx-php-via-php-fpm-on-ubuntu-lucid-%e7%8e%af%e5%a2%83%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5</guid> <description><![CDATA[Nginx团队维护的PPA源带有PHP 5.3.x的子源，更新迅速，现在在Ubuntu部署Nginx+PHP环境真是太容易了（虽然LAMP更容易，一句apt-get install lamp-server^搞定，别漏了最后的上尖号）。像以前那样跑cgi-fcgi简直弱爆了。 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 apt-get install python-software-properties add-apt-repository ppa:nginx/stable add-apt-repository ppa:nginx/php5 &#160; #Ubuntu 10.10 以后可不需添加以上源 &#160; apt-get update apt-get install nginx apt-get install php5-cgi php5-mysql php5-fpm php5-curl php5-mcrypt &#160; #或者你需要更齐全的php包： #aptitude install php5-cgi php5-mysql php5-fpm php5-curl php5-gd php5-idn php-pear php5-imagick [...]]]></description> <content:encoded><![CDATA[<p>Nginx团队维护的PPA源带有PHP 5.3.x的子源，更新迅速，现在在Ubuntu部署Nginx+PHP环境真是太容易了（虽然LAMP更容易，一句<code>apt-get install lamp-server^</code>搞定，别漏了最后的上尖号）。像<a
href="http://apt-blog.net/setup_nginx">以前那样</a>跑cgi-fcgi简直弱爆了。</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> python-software-properties
add-apt-repository ppa:nginx<span style="color: #000000; font-weight: bold;">/</span>stable
add-apt-repository ppa:nginx<span style="color: #000000; font-weight: bold;">/</span>php5
&nbsp;
<span style="color: #666666; font-style: italic;">#Ubuntu 10.10 以后可不需添加以上源</span>
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> update
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> nginx
<span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> php5-cgi php5-mysql php5-fpm php5-curl php5-mcrypt
&nbsp;
<span style="color: #666666; font-style: italic;">#或者你需要更齐全的php包：</span>
<span style="color: #666666; font-style: italic;">#aptitude install php5-cgi php5-mysql php5-fpm php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl</span>
&nbsp;
service nginx start
service php5-fpm start</pre></td></tr></table></div><h2>FPM Tunning</h2><p>php5-fpm默认参数启动的服务器还是比较耗资源的，如果环境不充裕（如512内存以下的VPS），可以做下配置。</p><p>这个包的fpm的默认配置文件是<code>/etc/php5/fpm/main.conf</code>，但对子进程的配置是在其包含的<code>/etc/php5/fpm/pool.d/</code>目录内，里面有个<code>www.conf</code>，可以对以下的参数做以下修改：</p><div
class="wp_syntax"><div
class="code"><pre class="text" style="font-family:monospace;">pm = dynamic              ;动态管理php-fpm的子进程
pm.max_children = 5       ;最多的时候开不超过5个
pm.start_servers = 2      ;启动服务时候开2个
pm.min_spare_servers = 2  ;空闲时候最少留2个
pm.max_spare_servers = 5  ;最多留5个
pm.max_requests = 300     ;每个子进程最多处理300个请求就退出换新的子进程。</pre></div></div><p>按需调整这些参数可以达到最佳动态分配资源的效果。</p> ]]></content:encoded> <wfw:commentRss>http://apt-blog.net/best-practise-nginx-php-via-php-fpm-on-ubuntu/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Debian/Ubuntu - Xen折腾秘笈</title><link>http://apt-blog.net/cheat-notes-about-using-xen-under-debian-ubuntu</link> <comments>http://apt-blog.net/cheat-notes-about-using-xen-under-debian-ubuntu#comments</comments> <pubDate>Mon, 23 Aug 2010 10:40:47 +0000</pubDate> <dc:creator>BOYPT</dc:creator> <category><![CDATA[Unix/Linux]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[virtual]]></category> <category><![CDATA[xen]]></category> <category><![CDATA[xen-tools]]></category> <guid
isPermaLink="false">http://apt-blog.net/?p=864</guid> <description><![CDATA[作为秘籍，本文包含折腾Xen所必须了解，但是在一般能找到的教程里面都没提及的资料。这里不包含一些必须的步骤等，所以很可能你需要先浏览这些资料，并让浏览器同时开着这些页面随时查阅： DebianWiki Xen DebianWiki DebianInstaller/Xen XenWiki HowTos Ubuntu Doc/Xen Ubuntu 9.04上的XEN虚拟服务器（一） 安装XEN （二） 安装虚拟机 在 Debian 上安装和配置 Xen 一：Xen工具及其关系 《在 Debian 上安装和配置 Xen》一文把在Debian上安装Xen简化成一道命令： On Debian Lenny 5.0 : apt-get install xen-hypervisor-3.2-1-amd64 xen-linux-system-2.6.26-2-xen-amd64 xen-utils-3.2-1 xenstore-utils xenwatch xen-shell xen-tools On Debian Squeeze 6.0 apt-get install xen-linux-system xen-hypervisor xen-utils xen-tools xen-hypervisor主要只有一个文件:/boot/xen-3.2-1-amd64.gz，就是宿主内核； xen-linux-system则是打了Xen补丁的Linux内核，这个内核脱离hypervisor是无法启动的，只适用于虚拟机；dom0对hypervisor来说也是虚拟机之一，domU也可以直接用这个内核启动。 xen-utils则是运行在Dom0上的程序，比如xend、xm，作用是跟hypervisor通讯，是主要由Python编写的一系列程序。 xen-tools是如xen-create-image的一系列工具，作为xm工具的前端，用以管理安装虚拟机；这是一套perl脚本，也有很灵活扩展性。 xen-shell是一个交互式的shell，常见用于VPS服务商提供给用户的操作界面，用户根据几个封装好的命令控制虚拟机如重启等工作。(Debian 6.0 下没有了。) xenstore-utils、 [...]]]></description> <content:encoded><![CDATA[<p>作为秘籍，本文包含折腾Xen所必须了解，但是在一般能找到的教程里面都没提及的资料。这里不包含一些必须的步骤等，所以很可能你需要先浏览这些资料，并让浏览器同时开着这些页面随时查阅：</p><ul><li><a
href="http://wiki.debian.org/Xen">DebianWiki Xen</a></li><li><a
href="http://wiki.debian.org/DebianInstaller/Xen">DebianWiki DebianInstaller/Xen</a></li><li><a
href="http://wiki.xensource.com/xenwiki/HowTos">XenWiki HowTos</a></li><li><a
href="https://help.ubuntu.com/community/Xen">Ubuntu Doc/Xen</a></li><li>Ubuntu 9.04上的XEN虚拟服务器<a
href="http://wells.osall.com/blog/index.php?m=content&amp;p=1434">（一） 安装XEN</a> <a
href="http://wells.osall.com/blog/index.php?m=content&amp;p=1436">（二） 安装虚拟机</a></li><li><a
href="http://www.vpsee.com/2010/03/install-xen-on-debian/">在 Debian 上安装和配置 Xen</a></li></ul><h2>一：Xen工具及其关系</h2><p>《<a
href="http://www.vpsee.com/2010/03/install-xen-on-debian/">在 Debian 上安装和配置 Xen</a>》一文把在Debian上安装Xen简化成一道命令：</p><p>On Debian Lenny 5.0 :</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> xen-hypervisor-<span style="color: #000000;">3.2</span>-<span style="color: #000000;">1</span>-amd64
xen-linux-system-2.6.26-<span style="color: #000000;">2</span>-xen-amd64 xen-utils-<span style="color: #000000;">3.2</span>-<span style="color: #000000;">1</span>
xenstore-utils xenwatch xen-shell xen-tools</pre></div></div></p><p>On Debian Squeeze 6.0</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> xen-linux-system xen-hypervisor xen-utils xen-tools</pre></div></div></p><ul><li><code>xen-hypervisor</code>主要只有一个文件:<code>/boot/xen-3.2-1-amd64.gz</code>，就是宿主内核；</li><li><code>xen-linux-system</code>则是打了Xen补丁的Linux内核，这个内核脱离hypervisor是无法启动的，只适用于虚拟机；dom0对hypervisor来说也是虚拟机之一，domU也可以直接用这个内核启动。</li><li><code>xen-utils</code>则是运行在Dom0上的程序，比如xend、xm，作用是跟hypervisor通讯，是主要由Python编写的一系列程序。</li><li><code>xen-tools</code>是如<code>xen-create-image</code>的一系列工具，作为xm工具的前端，用以管理安装虚拟机；这是一套perl脚本，也有很灵活扩展性。</li><li><code>xen-shell</code>是一个交互式的shell，常见用于VPS服务商提供给用户的操作界面，用户根据几个封装好的命令控制虚拟机如重启等工作。(Debian 6.0 下没有了。)</li><li><code>xenstore-utils</code>、 <code>xenwatch</code>分别是虚拟机间数据共享和虚拟机监控的工具，不是必要组建，可不安装。</li></ul><h2>二: Dom0的启动</h2><ol><li><p>grub2跟xen dom0目前关系不怎么所以如果你用grub2启动遇到挂掉xen启动不起来之类的，换回grub-legacy吧。</p></li><li><p>装完xen-hypervisor后可以打开<code>/boot/grub/menu.lst</code>看看，第一个选项应该是<code>Xen 3.2-1-amd64</code>之类的，看他的启动参数，是先加载Xen内核/xen-3.2-1-amd64.gz，再按模块挂在Linux内核；如果没有出现，需要运行<code>update-grub</code>。有这个后就可以放心重启了。</p></li><li><p><code>/boot/grub/menu.lst</code>文件里面有这么一行配置：</p></li></ol><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
</pre></td><td
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">## Xen hypervisor options to use with the default Xen boot option</span>
<span style="color: #666666; font-style: italic;"># xenhopt=</span></pre></td></tr></table></div><p>是预留来传hypervisor参数的，比如要限制dom0的内存使用，可以写成：</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># xenhopt=dom0_mem=256M</span></pre></td></tr></table></div><p>修改后记得运行 <code>update-grub</code>才生效。</p><p>关于Dom0内存的占用可能导致虚拟机不稳定可参看：<a
href="http://www.jolokianetworks.com/70Knowledge/Virtualization/My_Xen_is_Crashing!/Dom0_mem_allocation_and_domU_network_issues">Dom0 mem allocation and domU network issues</a>。</p><h2>三：虚拟机的网络</h2><p>无论是简单的桥接，安全的NAT子网，内部私有网，单双向网，利用内核的特性都可以做到： <a
href="http://wiki.kartbuilding.net/index.php/Xen_Networking">Xen Networking</a></p><h2>四：虚拟机的安装</h2><h3>关于管理工具</h3><p>有两套工具可以用来创建Xen虚拟机：<a
href="http://www.xen-tools.org/software/xen-tools/">xen-tools</a>, <a
href="http://libvirt.org/index.html">libvirt-bin</a>，从它们各自的主页很清晰看到它们的定位不同，前者主要用于本地管理Xen，由Debian支持，后者用于管理各种虚拟方案（xen,openvz,kvm,qeum,vbox,vmware....），由Redhat支持。虽然都支持跟兼容，但实际上前者有利于安装前者的系统，后者有利于安装后者的系统。这里只研究前者。</p><h3>关于 xen-create-image</h3><p>xen-tools是相当简单实用的一套脚本，教程里面一般提到使用的<code>xen-create-image</code>。</p><p>xen-tools有一个全局配置文件<code>/etc/xen-tools/xen-tools.conf</code>，里面写的参数会最终被<code>xen-create-image</code>的命令行参数覆盖或补充。</p><h3>关于 --install-method</h3><p>xen-tools的作用主要是控制怎么安装一个发行版，因为xen虚拟机的特殊方式，一般都不会启动该发行版的安装程序，而是用发行版的基础包管理来进行安装，安装参数<code>--install-method</code>负责这个过程，比如Debian/Ubuntu就要用<code>debootstrap</code>方法安装，CentOS/Fedora用<code>rinse</code>或<code>rpmstrap</code>，另外还有<code>copy</code>、<code>tar</code>方法。安装好一个模板系统后对那个镜像手动挂载，tar压缩后来用部署其他虚拟机，是个好方法。</p><h3>关于 --dist</h3><p><code>--dist</code>让你指定一个发行版的名字，你会发现并不是所有发行版都能被支持的，实际支持的可以看看<code>/usr/lib/xen-tools</code>的内容，里面各个对应发行版的目录内都包含了一系列的脚本，如预先安装什么包，需要设置某个配置文件，比如说<code>libc6-xen</code>，不过在<a
href="http://xen-tools.org/lists/xen-tools-discuss/Apr07/0265.html">64位机环境下这个是不需要的</a>，脚本会自动判断。</p><h3>关于安装新版本系统</h3><p>因为版本太旧，在Debian Lenny里面的xen-tools跟debootstrap不能直接支持比如Ubuntu Lucid(10.4)之类的较新的发行版的安装，倒是有比较曲折的方法<a
href="http://blog.webangel.ie/2010/04/ubuntu-upgrade-to-9-1010-04-for-xen-domu/">Ubuntu upgrade to 9.10/10.04 for Xen DomU</a> 。但其实有更好的方法：下载新版的<a
href="http://packages.debian.org/squeeze/xen-tools">Xen-tools</a>跟<a
href="http://packages.debian.org/squeeze/debootstrap">debootstrap</a>的deb回来装上。因为这些只是一些脚本，不会跟系统其他包有冲突。装完后就可以直接安装新版系统了。(dpkg安装新版xen-tool时候提示缺一个依赖，按名字装上即可)</p><h3>关于 --mirror</h3><p>安装教程里面一般都让你指定一个对应发行版的源，考虑到网速因素，这样安装一个虚拟机是很累的，虽然xen-create-image有个<code>--cache</code>可以在dom0上缓存deb包。其实如果你有相应发行版的iso文件，完全可以拿iso来做安装源：</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
</pre></td><td
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>isodir
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> loop <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>the_iso_file.iso <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>isodir
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>isodir
python <span style="color: #660033;">-m</span> SimpleHTTPServer</pre></td></tr></table></div><p>现在这个机器就在8000端口上运行着一个HTTP源了，直接在mirror参数里面指定该地址即可，这样的安装过程很快。缺点是可能安装脚本有一些包在iso中没有提供而出错，建议加上<code>--verbose</code>参数查看整个安装过程。</p><p>安装过程的日至会被放在<code>/var/log/xen-tools/&lt;NAME&gt;.log</code>，如果安装过程出现什么问题可以直接看这个对应的文件。使用本地ISO做源虽然一般没什么问题，但如果缺了什么包之类的会在日志中提示。</p><h3>关于 --role</h3><p><code>--role=udev</code>这个参数建议创建新虚拟机时候加上。<code>--role</code>参数会让创建脚本在<code>/etc/xen-tools/role.d/</code>目录下寻找相应名字的脚本运行，udev就是其中一个，作用是给虚拟机装上<code>udev</code>包。udev是提供动态<code>/dev</code>目录的机制，是提供内核对硬件识别的事件桥梁，对一般的xen虚拟机来说影响不算太大，如果不安装最显然的是会找不到<code>/dev/shm</code>挂载点（启动过程有一个warnning），但一般来说还是推荐安装。</p><p><code>/etc/xen-tools/role.d/</code>里面默认包含了以下一些有用的脚本，使用时可以逗号分隔，如<code>--role=udev,minimal,cfengine</code>：</p><ul><li><code>builder</code> 自动安装build-essential等编译链包，部署distcc集群有用。</li><li><code>cfengine</code> CFengine是一个服务器自动化控制服务，对部署大量服务器很有用。会拷贝dom0上的配置。</li><li><code>editor</code> 自动根据dom0里面的sed脚本来配置domU内的配置文件，具体可以打开<code>/etc/xen-tools/role.d/editor</code>看看说明。</li><li><code>passwd</code> 自动修改domU的密码。默认--passwd参数是会出现passwd的交互修改root密码的过程，用这个role脚本就可以实现自动应答。要使用<code>--role-args=mYpassWd</code>传入相应密码。</li><li><code>minimal</code> 精简化domU系统。安装一些screen、vim等实用工具，卸除manpages等对虚拟机意义不大的包。</li><li><code>udev</code> 如前述，安装<code>udev</code>包。</li><li><code>xdm</code> 安装X、xdm、icewm等GUI包。</li><li><code>gdm</code> 同上，登陆器换成gdm。</li></ul><p>另外这些脚本默认都是针对Debian系系统设计的，Redhat系的应该用不了。</p><h3>关于 --pygrub</h3><p>最后有个<code>--pygrub</code>参数，关系到domU的引导过程。xen的半虚拟并没有从引导区的虚拟过程，而是直接读取内核文件运行。默认情况下是直接用dom0的内核的，如果domU的发行版跟版本跟dom0一致，这样处理倒是很方便，但是一旦不一致就容易出现找不到root分区等各种引导问题。如果安装的domU的系统跟dom0不一致的（包括amd64/i386这样的架构不同），就加上<code>--pygrub</code>参数，这会让domU安装上它自己的内核，以及生成一个<code>/boot/grub/menu.lst</code>文件，引导虚拟机时会根据这个文件模拟grub出现一个引导菜单，提出其自己的内核文件来启动虚拟机。</p><p>pygrub其实是xend的一个python工具，在<code>/usr/lib/xen-3.2-1/bin/pygrub</code>，可以直接这样运行来测试pygrub是否正常读取到内核：</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
</pre></td><td
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>xen-<span style="color: #000000;">3.2</span>-<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>pygrub <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/</span>lenny3<span style="color: #000000; font-weight: bold;">/</span>disk.img</pre></td></tr></table></div><p>会出现菜单，选择后会退出，返回一段临时文件数据，内核文件的临时位置。</p><p>目前在Debian Squeeze内的Xen 4.0的pygrub有个小小的低级错误，运行后会报模块导入错误，其实只要编辑<code>/usr/lib/xen-4.0/bin/pygrub</code>文件，把里面修改path的一行提前即可：</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
</pre></td><td
class="code"><pre class="python" style="font-family:monospace;"><span style="color: #dc143c;">sys</span>.<span style="color: black;">path</span>.<span style="color: black;">insert</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span>, <span style="color: #dc143c;">sys</span>.<span style="color: black;">path</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span> + <span style="color: #483d8b;">'/../lib/python'</span><span style="color: black;">&#41;</span> <span style="color: #808080; font-style: italic;">#这行原在30行左右，提前到这里</span>
<span style="color: #ff7700;font-weight:bold;">import</span> xen.<span style="color: black;">lowlevel</span>.<span style="color: black;">xc</span>  <span style="color: #808080; font-style: italic;">#原本这里出错</span></pre></td></tr></table></div><h3>典型的几种创建方法</h3><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
</pre></td><td
class="code"><pre class="bash" style="font-family:monospace;">xen-create-image <span style="color: #660033;">--hostname</span>=my-lenny <span style="color: #660033;">--dist</span>=lenny <span style="color: #660033;">--mirror</span>=http:<span style="color: #000000; font-weight: bold;">//</span>mirrors.163.com<span style="color: #000000; font-weight: bold;">/</span>debian <span style="color: #660033;">--role</span>=udev <span style="color: #660033;">--force</span> <span style="color: #660033;">--verbose</span>
&nbsp;
xen-create-image <span style="color: #660033;">--hostname</span>=my-ubuntu-vm <span style="color: #660033;">--dist</span>=lucid <span style="color: #660033;">--mirror</span>=http:<span style="color: #000000; font-weight: bold;">//</span>mirrors.163.com<span style="color: #000000; font-weight: bold;">/</span>ubuntu <span style="color: #660033;">--role</span>=udev <span style="color: #660033;">--pygrub</span> <span style="color: #660033;">--force</span> <span style="color: #660033;">--verbose</span>
&nbsp;
xen-create-image <span style="color: #660033;">--hostname</span>=my-xen-vm <span style="color: #660033;">--dist</span>=squeeze <span style="color: #660033;">--install-method</span>=<span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">--install-source</span>=<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>system_tared.tar.gz <span style="color: #660033;">--pygrub</span> <span style="color: #660033;">--force</span> <span style="color: #660033;">--verbose</span></pre></td></tr></table></div><h2>第五章：虚拟机的运行</h2><h3>关于虚拟机配置文件</h3><p>完成创建虚拟机后，默认情况下在<code>/home/xen/domains/&lt;NAME&gt;</code>下生成虚拟机的磁盘文件，在<code>/etc/xen/&lt;NAME&gt;.cfg</code>生成相应虚拟机的配置文件。关于虚拟机配置的修改，只需直接打开这个cfg文件修改即可(如内存大小，CPU多少，使用VNC等)。配置文件其实是一个Python脚本，也就是说可以对虚拟机的参数进行创建时的动态调节。</p><p>配置文件的选项完整说明可以运行<code>xm create --help_config</code>查看。</p><p>启动虚拟机以Xen的术语来说是创建一个实例：<code>xm create -c /etc/xen/&lt;NAME&gt;.cfg</code>，-c参数可以马上进入虚拟机的console，使用pygrub的虚拟机只能通过这个方法看到grub菜单。</p><h3>关于虚拟机启动过程</h3><p>本文成文时，使用Debian Lenny默认安装系统部署的domU似乎都有一个启动bug，即创建后使用<code>xm console &lt;NAME&gt;</code>仅能看到虚拟机启动的log信息，但是不出现shell，也无法登录，无法响应，只能按<code>ctrl-]</code>返回dom0。如果按上述安装了新版的<a
href="http://packages.debian.org/squeeze/xen-tools">Xen-tools</a>跟<a
href="http://packages.debian.org/squeeze/debootstrap">debootstrap</a>再创建的虚拟机就没有这个问题了。</p><p>用了旧版工具但要修复这个问题也不算太麻烦：</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td
class="code"><pre class="bash" style="font-family:monospace;">xm shutdown <span style="color: #000000; font-weight: bold;">&lt;</span>NAME<span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #666666; font-style: italic;">#确保关闭，运行xm list确保虚拟机已经没有运行</span>
<span style="color: #c20cb9; font-weight: bold;">mount</span> <span style="color: #660033;">-o</span> loop <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>xen<span style="color: #000000; font-weight: bold;">/</span>domains<span style="color: #000000; font-weight: bold;">/&lt;</span>NAME<span style="color: #000000; font-weight: bold;">&gt;/</span>disk.img <span style="color: #000000; font-weight: bold;">/</span>mnt
<span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>inittab <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>inittab.bak
<span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #ff0000;">'s/tty1/hvc0/'</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>inittab.bak <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>mnt<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>inittab
<span style="color: #c20cb9; font-weight: bold;">umount</span> <span style="color: #000000; font-weight: bold;">/</span>mnt</pre></td></tr></table></div><p>就是替换<code>/mnt/etc/inittab</code>文件里面，把虚拟终端的交互设备从tty1改成hvc0。在新版的xen-tools里面，这个替换已经由安装脚本完成了。hvc0是Xen虚拟机的类终端设备，只有让虚拟终端的输出输入跟hvc0链接，才能通过xen的console方法登录虚拟机。</p><p>如果使用vnc连接虚拟机，又会发现vnc里面无法登录虚拟机，vnc是framebuffer驱动的图形，默认连接tty1设备，可以按上述方法打开虚拟机的<code>/mnt/etc/inittab</code>文件，在getty那一段，写成这样：</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
</pre></td><td
class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000;">0</span>:<span style="color: #000000;">2345</span>:respawn:<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>getty <span style="color: #000000;">38400</span> hvc0
<span style="color: #000000;">1</span>:<span style="color: #000000;">2345</span>:respawn:<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>getty <span style="color: #000000;">38400</span> tty1</pre></td></tr></table></div><p>如果你安装的是Ubuntu，Ubuntu默认没有使用inittab来配置终端，而是使用了新的机制，使用目录<code>/etc/init/</code>里面的文件来控制，可以发现里面有tty1.conf之类的文件，可以<code>cp /etc/init/tty1.conf /etc/init/hvc0.conf</code>，然后打开<code>/etc/init/hvc0.conf</code>，把tty1那一段改成hvc0，保存即可。</p><h3>关于使用VNC查看虚拟机</h3><p>关于VNC的设置在<code>/etc/xen/xend-config.sxp</code>和各个虚拟机的配置文件里面都有选项，关系是前者是全局配置。</p><p>要打开一个虚拟机的VNC输出，只需在其配置文件内添加（望文生义即可）：</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
</pre></td><td
class="code"><pre class="python" style="font-family:monospace;">vfb = <span style="color: black;">&#91;</span> <span style="color: #483d8b;">'type=vnc'</span> <span style="color: black;">&#93;</span>
<span style="color: #808080; font-style: italic;">#复杂点的：</span>
vfb = <span style="color: black;">&#91;</span> <span style="color: #483d8b;">'type=vnc,vncdisplay=10,vncpasswd=s3cr3t'</span> <span style="color: black;">&#93;</span></pre></td></tr></table></div><p>vncdisplay的值加上5900，得到的就是最终vnc服务所监听的端口。</p><p>更复杂的配置选项看<code>xm create --help_config</code>。</p><h3>关于虚拟机的自动启动</h3><p>让虚拟机跟随dom0启动的方法有很几种，比如在<code>/etc/xen/auto/</code>目录里面放虚拟机配置文件的链接。但似乎更好的做法是在每个配置文件里面写上：</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
</pre></td><td
class="code"><pre class="python" style="font-family:monospace;">on_xend_start = <span style="color: #483d8b;">'start'</span>
on_xend_stop = <span style="color: #483d8b;">'suspend'</span></pre></td></tr></table></div><p>这样的好处是当dom0关机，Xen会先让虚拟机进入挂起状态（当然也可以改成shutdown直接关机），下次重启后虚拟机直接恢复。</p><h2>第六章：其他问题</h2><h3>关于虚拟机的磁盘方式</h3><p>使用xen-create-image工具创建的虚拟机，默认都是使用loop文件设备来映射，这样对io比较敏感的服务来说会有些影响。<a
href="http://wiki.xensource.com/xenwiki/blktap">Xen3.3后引入了使用blktap驱动映射的磁盘设备</a>，据称性能会有提高，不过根据试验好像跟pygrub配搭不怎么稳定（在xen-4.0下）。</p><p>觉得最靠谱的方式是使用lvm，xen-create-image工具也是支持直接创建lvm逻辑卷来安装的，这样即没有性能问题，也没有稳定问题。</p><h3>全虚拟半虚拟与CPU支持VM指令集的关系</h3><p>扫了一圈Google到的Xen资料，很多都让你检查<code>/proc/cpuinfo</code>里面有没有支持VM标记。其实CPU是否支持VM指令集，对xen来说只是能不能跑windows的问题，对于Xen的特色——半虚拟来说没什么影响，而且这才是xen最有价值的地方。</p><h2>相关资料</h2><ul><li><a
href="http://wiki.kartbuilding.net/index.php/Details,_Installation,_%26_Set-up_of_Debian_based_Linux_Servers">Details, Installation, &amp; Set-up of Debian based Linux Servers</a></li><li><a
href="http://mediakey.dk/~cc/howto-install-windows-xp-vista-on-xen/">Howto Install Windows XP / Vista on Xen</a></li></ul> ]]></content:encoded> <wfw:commentRss>http://apt-blog.net/cheat-notes-about-using-xen-under-debian-ubuntu/feed</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>配置GDM 2.28+登录画面背景、触摸板点击、屏幕背光等……</title><link>http://apt-blog.net/confiuring_gdm_2-28_and_above</link> <comments>http://apt-blog.net/confiuring_gdm_2-28_and_above#comments</comments> <pubDate>Fri, 30 Jul 2010 09:45:59 +0000</pubDate> <dc:creator>BOYPT</dc:creator> <category><![CDATA[Unix/Linux]]></category> <category><![CDATA[gdm]]></category> <category><![CDATA[gnome]]></category> <category><![CDATA[Ubuntu]]></category> <guid
isPermaLink="false">http://apt-blog.net/confiuring_gdm_2-28_and_above</guid> <description><![CDATA[1 2 3 4 5 6 #!/usr/bin/env xdg-open &#160; [Desktop Entry] Type=Application Exec=gnome-control-center Name=gnome_con 把上面的内容保存为/usr/share/gdm/autostart/LoginWindow/gnome_con.desktop，注销登出，在GDM画面时自然出现了gnome-control-center的配置窗口，在外观（apprerance）里面可以配置GMD的壁纸、图标主题，电源管理（Power Managerment）可以设置本本的屏幕背光、触摸板鼠标等等等等，跟一般Gnome配置无异。 完成后重新登录，删除上述保存的文件，即可。Ubuntu 10.04, Fedora 12等一大堆跟进了Gnome 2.28以上的发行版都可以这么配置。 关于GDM还有一些较高级的配置可见 Simple Greeter的开发文档 ，需要配置gconf内的选项，可按上述方法，仅把Exec一项改为Exec=gconf-editor；也可使用su -c，用gconftool-2工具设置文档里面提到的键值具体可参看 ArchLinux Wiki Gnome 2.28 Changes 。]]></description> <content:encoded><![CDATA[<div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td
class="code"><pre class="shell" style="font-family:monospace;">#!/usr/bin/env xdg-open
&nbsp;
[Desktop Entry]
Type=Application
Exec=gnome-control-center
Name=gnome_con</pre></td></tr></table></div><p>把上面的内容保存为<code>/usr/share/gdm/autostart/LoginWindow/gnome_con.desktop</code>，注销登出，在GDM画面时自然出现了gnome-control-center的配置窗口，在外观（apprerance）里面可以配置GMD的壁纸、图标主题，电源管理（Power Managerment）可以设置本本的屏幕背光、触摸板鼠标等等等等，跟一般Gnome配置无异。</p><p>完成后重新登录，删除上述保存的文件，即可。Ubuntu 10.04, Fedora 12等一大堆跟进了Gnome 2.28以上的发行版都可以这么配置。</p><p>关于GDM还有一些较高级的配置可见<a
href="http://library.gnome.org/admin/gdm/2.30/configuration.html.en#greeterconfiguration"> Simple Greeter的开发文档 </a>，需要配置gconf内的选项，可按上述方法，仅把<code>Exec</code>一项改为<code>Exec=gconf-editor</code>；也可使用su -c，用<code>gconftool-2</code>工具设置文档里面提到的键值具体可参看<a
href="http://wiki.archlinux.org/index.php/Gnome_2.28_Changes#Method_2_2"> ArchLinux Wiki Gnome 2.28 Changes </a>。</p> ]]></content:encoded> <wfw:commentRss>http://apt-blog.net/confiuring_gdm_2-28_and_above/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Ubuntu 下使用蓝牙/USB连接黑莓8700上网</title><link>http://apt-blog.net/blackberry_as_bluetooth_and_usb_modem_for_ubuntu</link> <comments>http://apt-blog.net/blackberry_as_bluetooth_and_usb_modem_for_ubuntu#comments</comments> <pubDate>Thu, 17 Dec 2009 16:29:37 +0000</pubDate> <dc:creator>PT</dc:creator> <category><![CDATA[Unix/Linux]]></category> <category><![CDATA[Blackberry]]></category> <category><![CDATA[EDGE]]></category> <category><![CDATA[GPRS]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[蓝牙]]></category> <category><![CDATA[黑莓]]></category> <guid
isPermaLink="false">http://apt-blog.net/blackberry_as_bluetooth_and_usb_modem_for_ubuntu</guid> <description><![CDATA[黑莓8700支持EDGE网络，用来做GPRS Modem是相当理想的，标准的mini usb接口，蓝牙2.0，完全足够EDGE的网络速度； 本来以为用蓝牙连接会很简单，在blueman里面连接即可，可是实际上，不行： Failed: Modem Manager did not support the connection 之前用blueman连接Nokia的机，是没问题的，看来黑莓的Modem协议有点不同……Google了一下，找到了不少BB在Linux下的资料：How use BlackBerry device with Linux【介绍了Linux对黑莓的配置、同步、安装软件、Modem、Java开发】how to teather blackberry and linux via bluetooth【连BB蓝牙的完整过程，试验不成功】Berry4all 通过USB连接BB Modem的专用程序 测试Berry4all终于能够连接上BB的GPRS，观察Berry4all其实也是建立了串口通信后，使用pppd的协议来建立数据链接的，要连接cmnet，还得修改其conf下的att-chat，即其中的“拨号”协议； blueman虽然不能建立Modem链接，但是还是能够建立起/dev/rfcomm0，即通过蓝牙的串口链接；使用蓝牙教程，基本上都是使用hcitool等工具来配置的，使用起来真的好不方便，而blueman不是刚好帮忙搞定了蓝牙的配对连接等麻烦事情么…… 于是把Berry4all的conf目录的att跟att-chat文件复制到/etc/ppp/peers，参照别的教程的配置，修改att，在开始115200那行前，加入nodetach跟/dev/rfcomm0两行，最后的connect调用chat文件的路径改成connect "/usr/sbin/chat -f /etc/ppp/peers/att-chat"，att-chat里面修改一行：OK 'AT+CGDCONT=1,"IP","cmnet"' ，最后运行sudo pppd call att，终于用蓝牙连上了GPRS； 其实使用ppp连接modem的方法是最传统的，也是高度可定制（如连接后配置路由表、IP、DNS），不管是用Cable、USB、蓝牙还是红外，都可以这样完成，Of Linux, GPRS Phones, Serial Cable, Irda, Bluetooth and USB文章里面列举了好多这些例子；我修改了其中的三个脚本：gprs, gprs-connect-chat, gprs-disconnect-chat替代了上面Berry4all的att脚本，因为这脚本里面的注释非常详细，以防以后需要的调整； 这是我打包了修改好后（适用于移动CMNET上网的）gprs脚本，使用blueman连接了rfcomm0后，运行sudo pppd call gprs，就能连接上GPRS，ifconfig查看出现一个ppp0，可以直接上网了； 如果不使用blueman，完全使用bluez的工具的话，可以参照Blackberry [...]]]></description> <content:encoded><![CDATA[<p>黑莓8700支持EDGE网络，用来做GPRS Modem是相当理想的，标准的mini usb接口，蓝牙2.0，完全足够EDGE的网络速度；</p><p>本来以为用蓝牙连接会很简单，在blueman里面连接即可，可是实际上，不行：</p><blockquote><p><img
style="max-width: 800px; width: 332px; height: 195px;" src="http://apt-blog.net/wp-content/uploads/2009/12/blueman_fail.png" /></p><p>Failed: Modem Manager did not support the connection</p></blockquote><p>之前用blueman连接Nokia的机，是没问题的，看来黑莓的Modem协议有点不同……Google了一下，找到了不少BB在Linux下的资料：<br
/><a
target="_blank" href="http://www.progweb.com/modules/blackberry/index-en.html">How use BlackBerry device with Linux</a>【介绍了Linux对黑莓的配置、同步、安装软件、Modem、Java开发】<br
/><a
target="_blank" href="http://naraku.net/2008/08/15/how-to-teather-blackberry-and-linux-via-bluetooth/">how to teather blackberry and linux via bluetooth</a>【连BB蓝牙的完整过程，试验不成功】<br
/><a
target="_blank" href="http://www.berry4all.com/">Berry4all</a> 通过USB连接BB Modem的专用程序</p><p>测试<a
target="_blank" href="http://www.berry4all.com/">Berry4all</a>终于能够连接上BB的GPRS，观察<a
target="_blank" href="http://www.berry4all.com/">Berry4all</a>其实也是建立了串口通信后，使用pppd的协议来建立数据链接的，要连接cmnet，还得修改其conf下的att-chat，即其中的“拨号”协议；</p><p>blueman虽然不能建立Modem链接，但是还是能够建立起/dev/rfcomm0，即通过蓝牙的串口链接；使用蓝牙教程，基本上都是使用hcitool等工具来配置的，使用起来真的好不方便，而blueman不是刚好帮忙搞定了蓝牙的配对连接等麻烦事情么……</p><p>于是把<a
target="_blank" href="http://www.berry4all.com/">Berry4all</a>的conf目录的att跟att-chat文件复制到/etc/ppp/peers，参照别的教程的配置，修改att，在开始115200那行前，加入nodetach跟/dev/rfcomm0两行，最后的connect调用chat文件的路径改成connect "/usr/sbin/chat -f /etc/ppp/peers/att-chat"，att-chat里面修改一行：OK 'AT+CGDCONT=1,"IP","cmnet"' ，最后运行sudo pppd call att，终于用蓝牙连上了GPRS；</p><p>其实使用ppp连接modem的方法是最传统的，也是高度可定制（如连接后配置路由表、IP、DNS），不管是用Cable、USB、蓝牙还是红外，都可以这样完成，<a
href="http://www.iki.fi/mikko.rapeli/linux_gprs.html" target="_top">Of Linux, GPRS Phones, Serial Cable, Irda, Bluetooth and USB</a>文章里面列举了好多这些例子；我修改了其中的三个脚本：gprs, gprs-connect-chat, gprs-disconnect-chat替代了上面<a
target="_blank" href="http://www.berry4all.com/">Berry4all</a>的att脚本，因为这脚本里面的注释非常详细，以防以后需要的调整；</p><p><a
target="_blank" href="http://ptcoding.googlecode.com/files/grps.zip">这是我打包了修改好后</a>（适用于移动CMNET上网的）gprs脚本，使用blueman连接了rfcomm0后，运行sudo pppd call gprs，就能连接上GPRS，ifconfig查看出现一个ppp0，可以直接上网了；</p><blockquote><p><img
style="max-width: 800px; width: 446px; height: 295px;" src="http://apt-blog.net/wp-content/uploads/2009/12/bb_connected.png" /></p></blockquote><p>如果不使用blueman，完全使用bluez的工具的话，可以参照<a
href="http://pegelinux.wordpress.com/2008/06/11/blackberry-curve-8310-as-bluetooth-modem-on-ubuntu-hardy/" rel="bookmark" title="Permanent Link: Blackberry Curve 8310 as Bluetooth Modem on Ubuntu&nbsp;Hardy">Blackberry Curve 8310 as Bluetooth Modem on Ubuntu&nbsp;Hardy</a>，我没测试，不过按理说是可行的。</p><p>之所以这么折腾，其实可以说blueman的一个bug吧，似乎BB的Modem没啥特别，按通用的Modem都能连接到；有时间看看blueman的代码看能不能弄好……</p> ]]></content:encoded> <wfw:commentRss>http://apt-blog.net/blackberry_as_bluetooth_and_usb_modem_for_ubuntu/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Acer Aspire 4736ZG 本本上安家Linux的小问题</title><link>http://apt-blog.net/setup_linux_on_notebook_acer_aspire_4736zg</link> <comments>http://apt-blog.net/setup_linux_on_notebook_acer_aspire_4736zg#comments</comments> <pubDate>Sun, 27 Sep 2009 05:25:06 +0000</pubDate> <dc:creator>BOYPT</dc:creator> <category><![CDATA[Unix/Linux]]></category> <category><![CDATA[4736]]></category> <category><![CDATA[Acer]]></category> <category><![CDATA[Arch]]></category> <category><![CDATA[Atheros]]></category> <category><![CDATA[Headphone]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[内核模块]]></category> <category><![CDATA[耳机]]></category> <category><![CDATA[驱动]]></category> <guid
isPermaLink="false">http://apt-blog.net/?p=643</guid> <description><![CDATA[早天在新蛋上入手了Acer Aspire 4736ZG本本一台，T4200、1G、NV105M、250G，带蓝牙摄像头等，3600，还送了一台水星无线路由。低端本本为了降低成本，很多都是不装Windows的，这款也是，本来以为原装系统都是Linux，应该对Linux兼容不错的啦，那天到提货点验本本时候，运行一看，傻了，那个什么Linpus，2.6.15的内核，没带X，lshw没有，lspci没有，hwinfo更没有，总之就没什么东西好看的，除了黑漆漆的画面告诉我屏幕没坏点，就匆匆打上包回来了。 第一件事就是用Arch 09.08的Live CD启动重新分区，顺便装好core，但是启动后又傻了，连不上有线网卡……这款机器的网卡是Atheros AR8132的千兆卡，不知道是太新还是太罕见。几经折腾后发现规律：完全关机重开后，Arch就能认到网卡，ipconfig -a能看到eth0，但是ifconfig eth0 up了之后，是这个样子的： eth0 Link encap:Ethernet HWaddr 00:26:18:80:C5:AB UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:4294967293 errors:4294967278 dropped:4294967290 overruns:4294967293 frame:4294967281 TX packets:4294967293 errors:4294967284 dropped:0 overruns:4294967293 carrier:4294967291 collisions:4294967281 txqueuelen:1000 RX bytes:4294967293 (4095.9 Mb) TX bytes:4294967293 (4095.9 Mb) Interrupt:28 大堆奇怪的数字，这时候不管dhcp还是手动指定IP，都没法正常工作的，如果这时重启，好，完全认不了网卡了，又要完全关机再开一次。 这个问题在Arch论坛上面也有人碰到，他的是华硕eeePC 1005HA，也是上个月的帖子。［详细情况帖子里面比较完备，但是，未解决］ 于是我就转战Ubuntu。Ubuntu 9.04的Live CD版本也是没能驱动好这块网卡的，但是这里找到解决方法，总之就是到Atheros官网下载网卡的驱动，编译，挂载驱动模块，幸好Ubuntu的Live CD跟初始系统都带了GCC和Make utils，编译安装过程倒没什么波折，很快就折腾好连上网了。呃，怎么这么简单？于是试试在台式机的Arch上面编译了这个atl1c.ko，哇，一开始就一屏幕的错误……后来发现这个是这个驱动跟内核兼容问题，Ubuntu好像专门有补丁搞定的，Ubuntu 9.04把内核升级到2.6.28.15-generic网卡就完全正常了，也顺便下载了9.10的Live CD，直接iso启动，发现虽然是31内核，但是网卡工作也正常……好吧……看来要么等kernel彻底搞定这块网卡的驱动，不然只能自己找Ubuntu的patch来编译才能跑Arch了…… Ubuntu很是省心，挂上受限驱动什么3D特效全都出来了，跑了下glxgears，大概2600fps，比台式机的集显好一点吧……7025只有1300左右的fps；更新了一下系统，用Ubuntu [...]]]></description> <content:encoded><![CDATA[<p>早天在新蛋上入手了Acer Aspire 4736ZG本本一台，T4200、1G、NV105M、250G，带蓝牙摄像头等，3600，还送了一台水星无线路由。低端本本为了降低成本，很多都是不装Windows的，这款也是，本来以为原装系统都是Linux，应该对Linux兼容不错的啦，那天到提货点验本本时候，运行一看，傻了，那个什么Linpus，2.6.15的内核，没带X，lshw没有，lspci没有，hwinfo更没有，总之就没什么东西好看的，除了黑漆漆的画面告诉我屏幕没坏点，就匆匆打上包回来了。</p><p>第一件事就是用Arch 09.08的Live CD启动重新分区，顺便装好core，但是启动后又傻了，连不上有线网卡……这款机器的网卡是Atheros AR8132的千兆卡，不知道是太新还是太罕见。几经折腾后发现规律：完全关机重开后，Arch就能认到网卡，ipconfig -a能看到eth0，但是ifconfig eth0 up了之后，是这个样子的：</p><blockquote><pre>eth0      Link encap:Ethernet  HWaddr 00:26:18:80:C5:AB
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4294967293 errors:4294967278 dropped:4294967290 overruns:4294967293 frame:4294967281
          TX packets:4294967293 errors:4294967284 dropped:0 overruns:4294967293 carrier:4294967291
          collisions:4294967281 txqueuelen:1000
          RX bytes:4294967293 (4095.9 Mb)  TX bytes:4294967293 (4095.9 Mb)
          Interrupt:28</pre></blockquote><p>大堆奇怪的数字，这时候不管dhcp还是手动指定IP，都没法正常工作的，如果这时重启，好，完全认不了网卡了，又要完全关机再开一次。</p><p><a
target="_blank" href="http://bbs.archlinux.org/viewtopic.php?pid=626481#p626481">这个问题在Arch论坛上面也有人碰到，他的是华硕eeePC 1005HA，也是上个月的帖子</a>。［详细情况帖子里面比较完备，但是，未解决］</p><p>于是我就转战Ubuntu。Ubuntu 9.04的Live CD版本也是没能驱动好这块网卡的，<a
target="_blank" href="http://www.lipengcheng.com/atheros_ar8131_driver_ubuntu.html">但是这里找到解决方法</a>，总之就是<a
target="_blank" href="http://partner.atheros.com/Drivers.aspx">到Atheros官网下载网卡的驱动</a>，编译，挂载驱动模块，幸好Ubuntu的Live CD跟初始系统都带了GCC和Make utils，编译安装过程倒没什么波折，很快就折腾好连上网了。呃，怎么这么简单？于是试试在台式机的Arch上面编译了这个atl1c.ko，哇，一开始就一屏幕的错误……后来发现这个是这个驱动跟内核兼容问题，<a
target="_blank" href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/415358">Ubuntu好像专门有补丁搞定的</a>，Ubuntu 9.04把内核升级到2.6.28.15-generic网卡就完全正常了，也顺便下载了9.10的Live CD，直接iso启动，发现虽然是31内核，但是网卡工作也正常……好吧……看来要么等kernel彻底搞定这块网卡的驱动，不然只能自己找Ubuntu的patch来编译才能跑Arch了……</p><p>Ubuntu很是省心，挂上受限驱动什么3D特效全都出来了，跑了下glxgears，大概2600fps，比台式机的集显好一点吧……7025只有1300左右的fps；更新了一下系统，用Ubuntu Tweak添加了一堆三方源后拉好一大堆软件，基本可用了，另外的问题是，声卡的耳机输出没声音！</p><p>update: 其实是我插错洞了，黑色的是耳机输出，自动断开外放喇叭，我之前插的是绿色，本来是给后置音源用的。</p><p><del
datetime="2010-06-22T06:59:11+00:00">本本的耳机问题好像从来都是老大难的，因为音频接口的硬件随意性很大，Linux驱动的很难做到通用；本本里面的是ALC888 HD声卡，装了最新的<a
target="_blank" href="http://www.alsa-project.org/main/index.php/Download">alsa-driver 1.0.21</a>，情况依旧，喇叭有声音，但是耳机就是没反应，也没那个选项有效；后来查看了一些帖子才知道，虽然是同一款驱动，但是有不同的挂载模式的参数，通常就是用来指定这类变化很大的接口等，有些帖子给出一大堆参数列表，说，在/etc/modprbe.d/alsa-base.conf里面更换不同的参数，然后重启测试……天啊，起码上百条的参数，要重启到哪个年月阿……稍微看了下，所谓的挂载参数就是传给modprobe的参数嘛，比如modprobe snd_hda_intel model=ooxx，只需要用不同的参数重新挂载snd_hda_intel，完全没必要重启阿……<a
target="_blank" href="http://www.linlap.com/wiki/audio+tester">在Linlap找到一个AudioTester脚本，专门用来测试不同的模块挂载参数的</a>，但是在Ubuntu下用也挺麻烦，正常模式下不让删除snd_hda_intel模块，只好启动到recover mode，手动挂载后运行这个脚本；终于测试到"lenovo-sky"这个参数能让耳机出声，证明还不是残废……但是进入alsamixer里面看，使用这个参数之后，只有寥寥几个选项，连录音都不见了……而且耳机跟喇叭是同时发声的，不能关闭喇叭……</p><p>后来想到，这个参数列表应该不是固定的，新的alsa里面应该会有新的参数，不知道有没有专用Acer的参数呢？因为看到原来的列表里面有acer跟acer-aspire，虽然两个没合适这款机器；grep了一下alsa-driver的源代码目录，发现sound/pci/hda/patch_realtek.c里面有一大堆acer xxxx，试了acer-aspire-4730g跟acer-aspire-4730g，设置成4ch/6ch模式后，终于能通过设置Surround让耳机出声，通过Front调整外放喇叭的声音！</del></p> ]]></content:encoded> <wfw:commentRss>http://apt-blog.net/setup_linux_on_notebook_acer_aspire_4736zg/feed</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>玩转libnotify</title><link>http://apt-blog.net/playing_libnotify</link> <comments>http://apt-blog.net/playing_libnotify#comments</comments> <pubDate>Fri, 22 May 2009 14:56:55 +0000</pubDate> <dc:creator>PT</dc:creator> <category><![CDATA[Unix/Linux]]></category> <category><![CDATA[libnotify]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[通知机制]]></category> <guid
isPermaLink="false">http://apt-blog.net/archives/386.html</guid> <description><![CDATA[Ubuntu 9.04一个特性就是新的通知机制Notify OSD，让人一眼看上去很酷的样子，其实只是基于libnotify的调用，别看又DBUS又OSD那么复杂，其实一点都不神秘，跟PT来： 1 2 3 4 5 6 7 8 #!/usr/bin/python #coding:utf-8 &#160; import pynotify &#160; pynotify.init &#40;&#34;PT-Title&#34;&#41; n = pynotify.Notification &#40;&#34;PT的贺电&#34;, &#34;PT再次发来贺电&#34;&#41; n.show &#40;&#41; 没看错，就是这么几句Python，保存成文件运行试试： 哈哈，很简单吧！ 如果你安装了libnotify-bin包，shell里面会有notify-send这个工具： notify-send &#34;PT的贺电&#34; &#34;PT发来贺电&#34; 差不多的效果，我就不抓图了，自己试试！ 当然除了python，libnotify还能在很多种语言的库实现，我用aptitude search libnotify搜索了一下，很明显有libinotify-ruby，libnotify-dev，libnotifymm-dev分别是ruby、C、C++方式的绑定，不过，python的pynotify是Ubuntu 9.04里面默认安装的呢…… 详细的开发还是看看Ubuntu的Notification Development Guidelines吧，注意在后部分有很多example的噢！！！]]></description> <content:encoded><![CDATA[<p>Ubuntu 9.04一个特性就是新的通知机制Notify OSD，让人一眼看上去很酷的样子，其实只是基于libnotify的调用，别看又DBUS又OSD那么复杂，其实一点都不神秘，跟PT来：</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td
class="code"><pre class="python" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
<span style="color: #808080; font-style: italic;">#coding:utf-8</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> pynotify
&nbsp;
pynotify.<span style="color: black;">init</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;PT-Title&quot;</span><span style="color: black;">&#41;</span>
n = pynotify.<span style="color: black;">Notification</span> <span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;PT的贺电&quot;</span>, <span style="color: #483d8b;">&quot;PT再次发来贺电&quot;</span><span style="color: black;">&#41;</span>
n.<span style="color: black;">show</span> <span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></pre></td></tr></table></div><p>没看错，就是这么几句Python，保存成文件运行试试：<br
/> <img
src="http://apt-blog.net/wp-content/uploads/2009/05/notify.png" /></p><p>哈哈，很简单吧！</p><p>如果你安装了libnotify-bin包，shell里面会有notify-send这个工具：</p><div
class="wp_syntax"><div
class="code"><pre class="bash" style="font-family:monospace;">notify-send <span style="color: #ff0000;">&quot;PT的贺电&quot;</span> <span style="color: #ff0000;">&quot;PT发来贺电&quot;</span></pre></div></div><p>差不多的效果，我就不抓图了，自己试试！</p><p>当然除了python，libnotify还能在很多种语言的库实现，我用aptitude search libnotify搜索了一下，很明显有libinotify-ruby，libnotify-dev，libnotifymm-dev分别是ruby、C、C++方式的绑定，不过，python的pynotify是Ubuntu 9.04里面默认安装的呢……</p><p><span
style="font-weight: bold;">详细的开发还是看看Ubuntu的<a
href="https://wiki.ubuntu.com/NotificationDevelopmentGuidelines" target="_blank">Notification Development Guidelines</a>吧，注意在后部分有很多example的噢！！！</span></p> ]]></content:encoded> <wfw:commentRss>http://apt-blog.net/playing_libnotify/feed</wfw:commentRss> <slash:comments>9</slash:comments> </item> <item><title>无损转换ext3到ext4，with Ubuntu Jaunty 9.04</title><link>http://apt-blog.net/converting_from_ext3_to_ext4_with_ubuntu_9-04</link> <comments>http://apt-blog.net/converting_from_ext3_to_ext4_with_ubuntu_9-04#comments</comments> <pubDate>Wed, 29 Apr 2009 12:03:57 +0000</pubDate> <dc:creator>PT</dc:creator> <category><![CDATA[Unix/Linux]]></category> <category><![CDATA[ext3]]></category> <category><![CDATA[ext4]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[文件系统]]></category> <guid
isPermaLink="false">http://apt-blog.net/archives/353.html</guid> <description><![CDATA[Ubuntu Jaunty 9.04开始正式支持ext4文件系统，关于ext4，其优点应该早有听闻，对任何用户而言都具有难以拒绝的诱惑：对一般用户而言，有更好的磁盘性能，快速的预分配、删除，更可靠的日志，更迅速的磁盘检查（不会像ext3可能花几分钟来check，ext4经常是瞬间完成的）……更专业的描述可以看看IBM文库的这篇《Migrating to ext4》。 从Ubuntu 8.10升级到9.04，一定程度上是看上其对ext4的支持，不过如果为此重新格式化分区重装系统，对于使用积累较多的系统来说代价太高了点（PT现在用的系统是去年的8.04，后来升级8.10，再到现在的9.04……），不过根据《Migrating to ext4》的说法，从ext3到ext4的无损转换是可能的，而且并不耗时间，就如Kernel Wiki里面的Ext4 Howto提到转换所用的命令，其实也很简单： tune2fs -O extents,uninit_bg,dir_index /dev/DEVe2fsck -fD /dev/DEV 查了下tune2fs的man页，uninit_bg是支持快速check的特性，dir_index则是创建二叉树散列的目录查找，至于extents在man页没提到，Kernel Wiki里面说是ext4专有的特性，完成后用e2fsck check一次，这样就完成ext4的转换了，整个过程的耗时并不多。 不过这样转换出来的分区有点不完美的地方是，原本存放在分区内的文件结构还是ext3的结构，由ext4的机制透明兼容，以后存放的文件才是ext4的格式。本来影响不大的，不过相信会影响众多完美主义者的精神状态，所以很多人宁愿把文件全复制出来，格式化了分区再复回去。 IBM的文章内提到，因为ext4支持了在线的碎片整理，对于转换的ext4，使用e4defrag整理一遍，就是纯种的ext4了，不过到目前为止，e4defrag并未完全可用。不过相信不久的将来，转换到纯种ext4完全可以一气呵成的。 最近有谣言说/boot不能是ext4，不然grub引导不了。事实上Ubuntu 9.04已经完全支持ext4，不然此前怎么会有ext4系统的9.04 21秒引导系统的新闻？不过对于升级过来的9.04，安装在/boot/grub里面的程序还是旧版的，没有自动升级，因此可能出现引导问题，相信这也是谣言的出处，所以升级过来的同学要注意了。可以使用grub-install来重新安装一次grub的文件，就如《Upgrade Ubuntu 8.10 to Ubuntu 9.04 and ext3 to ext4 in 10 Minutes》那样。不过grub-install有点要注意，grub-install复制的文件是以/为起始位置的（特别是使用了--root-directory=DIR参数的），如果boot单独分区，同时在livecd里面单独挂载了出来，很可能新复制过去的文件会多了一层boot目录，变成新旧版的引导文件共存以致没法引导grub……(我也感觉我说得一塌糊涂了……总之boot独立分区的同学使用grub-install注意它究竟安装到什么地方去了，看看相应文件的修改时间)。 对于从ext3升级到ext4的系统，还有重要的一点就是fstab，完成上述的操作后，先运行blkid查看分区的新UUID，用编辑器打开/etc/fstab，替换转换了的分区的UUID，当然还有挂载类型改成ext4。]]></description> <content:encoded><![CDATA[<p>Ubuntu Jaunty 9.04开始正式支持ext4文件系统，关于ext4，其优点应该早有听闻，对任何用户而言都具有难以拒绝的诱惑：对一般用户而言，有更好的磁盘性能，快速的预分配、删除，更可靠的日志，更迅速的磁盘检查（不会像ext3可能花几分钟来check，ext4经常是瞬间完成的）……更专业的描述可以看看IBM文库的这篇<a
href="http://www.ibm.com/developerworks/linux/library/l-ext4/" target="_blank">《Migrating to ext4》</a>。</p><p>从Ubuntu 8.10升级到9.04，一定程度上是看上其对ext4的支持，不过如果为此重新格式化分区重装系统，对于使用积累较多的系统来说代价太高了点（PT现在用的系统是去年的8.04，后来升级8.10，再到现在的9.04……），不过根据<a
href="http://www.ibm.com/developerworks/linux/library/l-ext4/" target="_blank">《Migrating to ext4》</a>的说法，从ext3到ext4的无损转换是可能的，而且并不耗时间，就如Kernel Wiki里面的Ext4 Howto提到<a
href="http://ext4.wiki.kernel.org/index.php/Ext4_Howto#Converting_an_ext3_filesystem_to_ext4" target="_blank">转换所用的命令</a>，其实也很简单：<br
/><blockquote><code
style="white-space: nowrap; color: rgb(73, 89, 136); background-color: white;">tune2fs -O extents,uninit_bg,dir_index /dev/DEV<br
/>e2fsck -fD /dev/DEV</code></p></blockquote><p>查了下tune2fs的man页，uninit_bg是支持快速check的特性，dir_index则是创建二叉树散列的目录查找，至于extents在man页没提到，Kernel Wiki里面说是ext4专有的特性，完成后用e2fsck check一次，这样就完成ext4的转换了，整个过程的耗时并不多。</p><p>不过这样转换出来的分区有点不完美的地方是，原本存放在分区内的文件结构还是ext3的结构，由ext4的机制透明兼容，以后存放的文件才是ext4的格式。本来影响不大的，不过相信会影响众多完美主义者的精神状态，所以很多人宁愿把文件全复制出来，格式化了分区再复回去。</p><p>IBM的文章内提到，因为ext4支持了在线的碎片整理，对于转换的ext4，使用e4defrag整理一遍，就是纯种的ext4了，不过到目前为止，e4defrag并未完全可用。不过相信不久的将来，转换到纯种ext4完全可以一气呵成的。</p><p>最近有谣言说/boot不能是ext4，不然grub引导不了。事实上Ubuntu 9.04已经完全支持ext4，不然此前怎么会有ext4系统的9.04 21秒引导系统的新闻？不过对于升级过来的9.04，安装在/boot/grub里面的程序还是旧版的，没有自动升级，因此可能出现引导问题，相信这也是谣言的出处，所以升级过来的同学要注意了。可以<span
style="font-weight: bold; text-decoration: underline;">使用grub-install来重新安装一次grub的文件</span>，就如<a
href="http://blog.taragana.com/index.php/archive/upgrade-ubuntu-810-to-ubuntu-904-and-ext3-to-ext4/" target="_blank">《Upgrade Ubuntu 8.10 to Ubuntu 9.04 and ext3 to ext4 in 10 Minutes》</a>那样。不过grub-install有点要注意，grub-install复制的文件是以/为起始位置的（特别是使用了--root-directory=DIR参数的），如果boot单独分区，同时在livecd里面单独挂载了出来，很可能新复制过去的文件会多了一层boot目录，变成新旧版的引导文件共存以致没法引导grub……(<span
style="font-weight: bold; text-decoration: underline;">我也感觉我说得一塌糊涂了……总之boot独立分区的同学使用grub-install注意它究竟安装到什么地方去了，看看相应文件的修改时间</span>)。</p><p>对于从ext3升级到ext4的系统，还有重要的一点就是fstab，完成上述的操作后，先运行blkid查看分区的新UUID，用编辑器打开/etc/fstab，替换转换了的分区的UUID，当然还有挂载类型改成ext4。</p> ]]></content:encoded> <wfw:commentRss>http://apt-blog.net/converting_from_ext3_to_ext4_with_ubuntu_9-04/feed</wfw:commentRss> <slash:comments>5</slash:comments> </item> <item><title>通过Wine使用Sogou浏览器的教育网加速代理</title><link>http://apt-blog.net/using_sogou_proxy_with_wine</link> <comments>http://apt-blog.net/using_sogou_proxy_with_wine#comments</comments> <pubDate>Tue, 14 Apr 2009 05:59:06 +0000</pubDate> <dc:creator>PT</dc:creator> <category><![CDATA[Unix/Linux]]></category> <category><![CDATA[Sogou]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[Wine]]></category> <category><![CDATA[代理]]></category> <category><![CDATA[加速代理]]></category> <category><![CDATA[搜狗]]></category> <category><![CDATA[教育网]]></category> <category><![CDATA[浏览器]]></category> <guid
isPermaLink="false">http://apt-blog.net/?p=268</guid> <description><![CDATA[此前用wireshark嗅探研究过Sogou浏览器的代理功能，没什么头绪，有访客留言说用Process Explorer瞧瞧Sogou的进程，今天有空看了下，果然，有一个子进程是用-proxy参数启动的，打开了本地的8081和8082端口在监听，用其他浏览器连8081，发现就是普通的透明代理，而8082则是一个自动配置代理的PAC（Javascript）。 虽然现在我的Ubuntu下已经有了一堆翻墙用的代理软件（没边、门、eTunnel……），但经常速度不甚理想，而且学校校园网的电信出口经常被挤爆，而教育网出口是空的，所以使用Sogou提供的免费教育网代理是个不错的解决办法。 把Sogou弄到Ubuntu下的Wine环境没有任何难度，把Sogou的安装文件夹全部复制到~/.wine/drive_c/sogou下，运行的很正常： pentie@pentie-desktop:~$ wine "C:\sogou\SogouExplorer.exe" -proxy fixme:win:EnumDisplayDevicesW ((null),0,0x32f3c4,0x00000000), stub! fixme:wtsapi:WTSRegisterSessionNotification Stub 0x1002a 0x00000000 fixme:mountmgr:harddisk_ioctl unsupported ioctl 74080 fixme:mountmgr:harddisk_ioctl unsupported ioctl 2d1400 fixme:mountmgr:harddisk_ioctl unsupported ioctl 2d0c10 PID:8 PORT:8081 CPORT:8082 PAC:http://127.0.0.1:8082/proxy.pac?t=626 RET:SUCCESS 在配置Firefox的FoxyProxy，可以像平常那样添加127.0.0.1:8081作为代理，但既然提供了PAC，不妨试试：在Automatic proxy configuration URL内添入“http://127.0.0.1:8082/”，按Test，说找到PAC，解析成功！确定后右下角也出现FoxyProxy的提示。此时在Firefox中打开的网页都是通过Sogou的免费代理了！不过发觉现在的代理速度没此前那么快了。 Ubuntu中有一个工具可以配置全局代理，gnome-network-preferences，运行它可以轻松的让apt-get、telnet之类的程序通过代理来连接外网。 再一次提醒的是，Sogou浏览器代理是“透明代理”，它会转发你的真实IP，没有任何匿名功能，因为他们的服务器也在国内（北京），因此也不会有翻墙功能。 参考了别人的网志：http://dan.febird.net/2008/12/firefox.html 已知缺陷：在流量和连接数比较大时（比如刷开Google Reader），wine出来的SogouExplorer进程占用大量CPU资源，可能是某链接库匹配问题，以致这个方法的实用性不是很高。]]></description> <content:encoded><![CDATA[<p>此前用wireshark嗅探<a
href="http://apt-blog.net/archives/92.html" target="_blank">研究过Sogou浏览器的代理功能</a>，没什么头绪，有访客留言说用Process Explorer瞧瞧Sogou的进程，今天有空看了下，果然，有一个子进程是用-proxy参数启动的，打开了本地的8081和8082端口在监听，用其他浏览器连8081，发现就是普通的<strong>透明</strong>代理，而8082则是一个自动配置代理的PAC（Javascript）。</p><p>虽然现在我的Ubuntu下已经有了一堆翻墙用的代理软件（没边、门、eTunnel……），但经常速度不甚理想，而且学校校园网的电信出口经常被挤爆，而教育网出口是空的，所以使用Sogou提供的免费教育网代理是个不错的解决办法。</p><p>把Sogou弄到Ubuntu下的Wine环境没有任何难度，把Sogou的安装文件夹全部复制到~/.wine/drive_c/sogou下，运行的很正常：</p><p
style="text-align: justify; padding-left: 30px;">pentie@pentie-desktop:~$ wine "C:\sogou\SogouExplorer.exe" -proxy<br
/> fixme:win:EnumDisplayDevicesW ((null),0,0x32f3c4,0x00000000), stub!<br
/> fixme:wtsapi:WTSRegisterSessionNotification Stub 0x1002a 0x00000000<br
/> fixme:mountmgr:harddisk_ioctl unsupported ioctl 74080<br
/> fixme:mountmgr:harddisk_ioctl unsupported ioctl 2d1400<br
/> fixme:mountmgr:harddisk_ioctl unsupported ioctl 2d0c10<br
/> PID:8<br
/> PORT:8081<br
/> CPORT:8082<br
/> PAC:http://127.0.0.1:8082/proxy.pac?t=626<br
/> RET:SUCCESS</p><p>在配置Firefox的FoxyProxy，可以像平常那样添加127.0.0.1:8081作为代理，但既然提供了PAC，不妨试试：在Automatic proxy configuration URL内添入“http://127.0.0.1:8082/”，按Test，说找到PAC，解析成功！确定后右下角也出现FoxyProxy的提示。此时在Firefox中打开的网页都是通过Sogou的免费代理了！不过发觉现在的代理速度没此前那么快了。</p><p>Ubuntu中有一个工具可以配置全局代理，gnome-network-preferences，运行它可以轻松的让apt-get、telnet之类的程序通过代理来连接外网。</p><p>再一次提醒的是，Sogou浏览器代理是“透明代理”，它会转发你的真实IP，<strong>没有任何匿名功能</strong>，因为他们的服务器也在国内（北京），因此也不会有翻墙功能。</p><p>参考了别人的网志：<a
href="http://dan.febird.net/2008/12/firefox.html" target="_blank">http://dan.febird.net/2008/12/firefox.html</a><strong></strong></p><p><strong>已知缺陷：在流量和连接数比较大时（比如刷开Google Reader），wine出来的SogouExplorer进程占用大量CPU资源，可能是某链接库匹配问题，以致这个方法的实用性不是很高。</strong></p> ]]></content:encoded> <wfw:commentRss>http://apt-blog.net/using_sogou_proxy_with_wine/feed</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>初尝Linux下的AVR单片机开发</title><link>http://apt-blog.net/developing_avr_under_linux</link> <comments>http://apt-blog.net/developing_avr_under_linux#comments</comments> <pubDate>Thu, 02 Apr 2009 08:49:36 +0000</pubDate> <dc:creator>PT</dc:creator> <category><![CDATA[Unix/Linux]]></category> <category><![CDATA[单片机]]></category> <category><![CDATA[AVR]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Ubuntu]]></category> <guid
isPermaLink="false">http://apt-blog.net/archives/220.html</guid> <description><![CDATA[此前接触过AVR单片机，发现无论是书店里面的教材，还是网上一大堆的中文资料，无一例外都是说windows下使用WinAVR、ICCAVR之类的，Linux方面的简直只字不提，难道这就是传说中的中国国情？外国情况可很不一样，玩单片机的Geek一般都很哈Linux，做单片机开发的软件一应俱全，当然还是开源的。 昨天从淘宝重新买了条USB的下载线，回来一看是USBasp的设计，附送的光盘当然也是win下的驱动和说明了，忽略。 插上下载器，lsusb，认倒是认出来了，叫做VOIT，那怎么用呢？上网一搜，原来USBasp是德国人的设计http://www.fischl.de/usbasp/，GPL的，其中提到AVRDUDE支持USBasp，当然也有源码下载。不过我用的是Ubuntu，发挥超级牛力的时候到了：sudo apt-get install avrdude，恩，几秒钟搞定，让他们去编译吧！ Linux下做单片机开发当然首选GCC，就如这些英文教程说的，下载源码？No，No，APT has Super Cow Powers，继续sudo apt-get install gcc-avr binutils-avr avr-libc 几分钟装完，很好，估计那些下载源码回来编译的同学要去喝两个小时茶才能用了。 万事俱全，先写个单片机的HelloWorld，借用micahcarrick的源码： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 #define F_CPU 1000000UL /* 1 MHz CPU clock */ &#160; #include &#60;util/delay.h&#62; #include &#60;avr/io.h&#62; [...]]]></description> <content:encoded><![CDATA[<p>此前接触过AVR单片机，发现无论是书店里面的教材，还是网上一大堆的中文资料，无一例外都是说windows下使用WinAVR、ICCAVR之类的，Linux方面的简直只字不提，难道这就是传说中的中国国情？外国情况可很不一样，玩单片机的Geek一般都很哈Linux，做单片机开发的软件一应俱全，当然还是开源的。</p><p>昨天从淘宝重新买了条USB的下载线，回来一看是USBasp的设计，附送的光盘当然也是win下的驱动和说明了，忽略。</p><p>插上下载器，lsusb，认倒是认出来了，叫做VOIT，那怎么用呢？上网一搜，原来USBasp是德国人的设计<a
target="_blank" href="http://www.fischl.de/usbasp/">http://www.fischl.de/usbasp/</a>，GPL的，其中提到AVRDUDE支持USBasp，当然也有源码下载。不过我用的是Ubuntu，发挥超级牛力的时候到了：sudo apt-get install avrdude，恩，几秒钟搞定，让他们去编译吧！</p><p>Linux下做单片机开发当然首选GCC，就如这些<a
target="_blank" href="http://paul.graysonfamily.org/thoughts/avrlinux/">英文教程</a>说的，下载源码？No，No，APT has Super Cow Powers，继续sudo apt-get install gcc-avr binutils-avr avr-libc</p><p>几分钟装完，很好，估计那些下载源码回来编译的同学要去喝两个小时茶才能用了。</p><p>万事俱全，先写个单片机的HelloWorld，借用micahcarrick的源码：</p><div
class="wp_syntax"><table><tr><td
class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
</pre></td><td
class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#define F_CPU 1000000UL  /* 1 MHz CPU clock */</span>
&nbsp;
<span style="color: #339933;">#include &lt;util/delay.h&gt;</span>
<span style="color: #339933;">#include &lt;avr/io.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span>
main <span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
        DDRC <span style="color: #339933;">=</span> _BV <span style="color: #009900;">&#40;</span>PC0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>               <span style="color: #808080; font-style: italic;">/* PC0 is digital output */</span>
&nbsp;
        <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>                       <span style="color: #808080; font-style: italic;">/* loop forever */</span>
        <span style="color: #009900;">&#123;</span>
                <span style="color: #808080; font-style: italic;">/* set PC0 on PORTC (digital high) and delay for 500mS */</span>
                PORTC <span style="color: #339933;">&amp;=</span> ~_BV<span style="color: #009900;">&#40;</span>PC0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                _delay_ms<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #808080; font-style: italic;">/*  PC0 on PORTC (digital 0) and delay for 500mS */</span>
                PORTC <span style="color: #339933;">|=</span> _BV<span style="color: #009900;">&#40;</span>PC0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                _delay_ms<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">500</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div><p>....保存为toggle_led.c</p><p>命令时间：</p><blockquote><pre>avr-gcc -mmcu=atmega48 -Wall -Os -o toggle_led.o toggle_led.c</pre></blockquote><p>是不是似曾相识？平时用gcc就这么用的，这里除了把gcc改成avr-gcc，没多大区别。-mmcu定义了目标CPU的类型，我用的是atmega48；-Os是优化选项，减少程序的大小。这就是传说中的交叉编译。</p><p>接着把目标代码翻译成可以烧录到芯片上的hex文件：</p><blockquote><pre>avr-objcopy -j .text -j .data -O ihex toggle_led.o toggle_led.hex</pre></blockquote><p>avr-objcopy的-j参数限定转换的程序段，-O设定hex的输出格式，ihex即Intel Hex file</p><p>[Update: 本例子中，-j .data这个选项没作用，因为.data区根本没有数据；.data是存放初始化数组、字符串等数据的段，如果程序用到了，记得加上]</p><p>搞定，开烧：</p><blockquote><pre>sudo avrdude -p m48 -c usbasp -e -U flash:w:toggle_led.hex</pre></blockquote><p>因为直接读写USB接口，所以不给权限的话会提示找不到编程器，当然配置USB权限最好，这里暂时用sudo。avrdude的-p指定目标CPU，-c指定下载器，如果不知道所用的下载器是什么型号，敲avrdude -c会列出所有支持的下载器型号及其描述。-e即烧录前清空，-U参数指定刷写类型以及刷写文件。</p><p>[Update：可参考virtualbox使用usb的配置，把当前用户加入usbfs组，就可以直接使用avrdude了]</p><p>回车后下载器的指示灯闪了下，跟着单片机上的小灯开始闪烁，Hi, Hello World.</p><p>当然问题不是完全没有，我用avrdude下载完后默认的校验老是无法通过，说读取错误，只好加个-V来跳过校验。可能跟个别机器有关。</p><p>当然实际开发很少这样敲一大堆命令来编译程序，一般都用Make搞定。</p><p>对比起Win下满是GUI的程序，我第一次接触WinAVR都搞了半天，如何如何配置一个Project，哇那个属性窗口真让人眼花缭乱，使用gcc来开发，则可以循序渐进，未了解到的参数就不用，简洁，明了，但不失其功能强大。</p><p> 资源：</p><ul><li>USBasp主页：<a
target="_blank" href="http://www.fischl.de/usbasp/">http://www.fischl.de/usbasp/</a></li><li>AVR-GCC Programming Guide：<a
target="_blank" href="http://electrons.psychogenic.com/modules/arms/art/3/AVRGCCProgrammingGuide.php#asmwithtavrasm">http://electrons.psychogenic.com/modules/arms/art/3/AVRGCCProgrammingGuide.php</a></li><li>Linux Atmel AVR Tutorial：<a
target="_blank" href="http://paul.graysonfamily.org/thoughts/avrlinux/">http://paul.graysonfamily.org/thoughts/avrlinux/</a></li><li>Micah Carrick -- AVR（非常推荐，但是需要翻墙） ： <a
href="http://www.micahcarrick.com/category/avr-microcontrollers" target="_blank">http://www.micahcarrick.com/category/avr-microcontrollers</a></li><li>AVR Libc User ManualLib Reference： <a
href="http://www.nongnu.org/avr-libc/user-manual/index.html" target="_blank">http://www.nongnu.org/avr-libc/user-manual/index.html</a></p></li></ul> ]]></content:encoded> <wfw:commentRss>http://apt-blog.net/developing_avr_under_linux/feed</wfw:commentRss> <slash:comments>6</slash:comments> </item> <item><title>让Ubuntu更新内核时自动编译官方版Nvidia驱动模块</title><link>http://apt-blog.net/making_ubuntu_renew_the_nvidia_module_after_kernel_upgrade</link> <comments>http://apt-blog.net/making_ubuntu_renew_the_nvidia_module_after_kernel_upgrade#comments</comments> <pubDate>Tue, 31 Mar 2009 05:59:06 +0000</pubDate> <dc:creator>PT</dc:creator> <category><![CDATA[Unix/Linux]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Nvidia]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[官方驱动]]></category> <category><![CDATA[驱动]]></category> <guid
isPermaLink="false">http://apt-blog.net/?p=181</guid> <description><![CDATA[目前Ubuntu 8.10中提供的最新Nvidia显卡驱动依然是180.11，除了不支持一些新的显卡，缺乏一些功能，在有些平台上也不稳定，容易Crash。很多人都用上Nvidia官网版的驱程，可是每当系统更新内核的时候，不得不回到console重新安装一次Nvidia，虽然不是很复杂，但长久如此，也挺麻烦的。 UbuntuForums上面一个Howto介绍了解决方法，下面简述之： 本方法不适合使用EnvyNG安装的驱动。 确保你全手动安装过Nvidia驱动并确定你所用的版本正常工作。 把NV的驱动安装文件复制到/usr/src，同时建立一链接。 sudo mv NVIDIA-Linux-x86-180.37-pkg1.run /usr/src sudo ln -s /usr/src/NVIDIA-Linux-x86-180.37-pkg1.run /usr/src/nvidia-driver 我安装的是180.37版本，注意不同版本的文件名不同。链接的作用是以后如果换一个新版的驱动进来，修改该链接即可，不用修改下面的脚本。 保存下面的代码为文件update-nvidia #!/bin/bash # # Set this to the exact path of the nvidia driver you plan to use # It is recommended to use a symlink here so that this script doesn't # have to be modified when you [...]]]></description> <content:encoded><![CDATA[<p>目前Ubuntu 8.10中提供的最新Nvidia显卡驱动依然是180.11，除了不支持一些新的显卡，缺乏一些功能，在有些平台上也不稳定，容易Crash。很多人都用上Nvidia官网版的驱程，可是每当系统更新内核的时候，不得不回到console重新安装一次Nvidia，虽然不是很复杂，但长久如此，也挺麻烦的。</p><p><a
href="http://ubuntuforums.org/showthread.php?t=835573" target="_blank">UbuntuForums上面一个Howto介绍了解决方法</a>，下面简述之：</p><ul><li>本方法不适合使用EnvyNG安装的驱动。</li><li>确保你全手动安装过Nvidia驱动并确定你所用的版本正常工作。</li></ul><p></p><ol><li>把NV的驱动安装文件复制到/usr/src，同时建立一链接。<br
/><blockquote><p>sudo mv NVIDIA-Linux-x86-180.37-pkg1.run /usr/src<br
/> sudo ln -s /usr/src/NVIDIA-Linux-x86-180.37-pkg1.run /usr/src/nvidia-driver</p></blockquote><p>我安装的是180.37版本，注意不同版本的文件名不同。链接的作用是以后如果换一个新版的驱动进来，修改该链接即可，不用修改下面的脚本。</li><li>保存下面的代码为文件update-nvidia<p><pre class="code" style="border: 1px inset ; margin: 0px; padding: 6px; overflow: auto; width: 480px;">#!/bin/bash
#
# Set this to the exact path of the nvidia driver you plan to use
# It is recommended to use a symlink here so that this script doesn't
# have to be modified when you change driver versions.
DRIVER=/usr/src/nvidia-driver
# Build new driver if it doesn't exist
if [ -e /lib/modules/$1/kernel/drivers/video/nvidia.ko ] ; then
    echo "NVIDIA driver already exists for this kernel." &gt;&#038;2
else
    echo "Building NVIDIA driver for kernel $1" &gt;&#038;2
    sh $DRIVER -K -k $1 -s -n 2&gt;1 &gt; /dev/null
    if [ -e /lib/modules/$1/kernel/drivers/video/nvidia.ko ] ; then
        echo "   SUCCESS: Driver installed for kernel $1" &gt;&#038;2
    else
        echo "   FAILURE: See /var/log/nvidia-installer.log" &gt;&#038;2
    fi
fi
exit 0</pre></p></li><li>把该脚本复制到/etc/kernel/postinst.d<br
/><blockquote><p> sudo mkdir -p /etc/kernel/postinst.d<br
/> sudo install update-nvidia /etc/kernel/postinst.d</p></blockquote><p>install命令作用跟cp差不多，只是自动修改文件的权限为rwxr-xr-x</li><li>OK，完成了。如果想测试一下是否已经成功，试试装个旧内核<br
/><blockquote><p>sudo apt-get install linux-image-2.6.27-10-generic</p></blockquote><p>稍候应该会看到最后会有一下停顿，然后看到SUCCESS: Driver installed for kernel ...<br
/> 再把这个包puege掉即可：</p><blockquote><p>sudo apt-get purge linux-image-2.6.27-10-generic</p></blockquote></li></ol> ]]></content:encoded> <wfw:commentRss>http://apt-blog.net/making_ubuntu_renew_the_nvidia_module_after_kernel_upgrade/feed</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
