﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-flyonok-文章分类-linux</title><link>http://www.cppblog.com/flyonok/category/6248.html</link><description /><language>zh-cn</language><lastBuildDate>Sun, 03 Apr 2011 05:56:54 GMT</lastBuildDate><pubDate>Sun, 03 Apr 2011 05:56:54 GMT</pubDate><ttl>60</ttl><item><title>关于linux 802.1d (bridge) 和 802.1q(vlan) 实现的再思考</title><link>http://www.cppblog.com/flyonok/articles/142600.html</link><dc:creator>flyonok</dc:creator><author>flyonok</author><pubDate>Wed, 23 Mar 2011 10:04:00 GMT</pubDate><guid>http://www.cppblog.com/flyonok/articles/142600.html</guid><wfw:comment>http://www.cppblog.com/flyonok/comments/142600.html</wfw:comment><comments>http://www.cppblog.com/flyonok/articles/142600.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flyonok/comments/commentRss/142600.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flyonok/services/trackbacks/142600.html</trackback:ping><description><![CDATA[<span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Simsun; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span><span style="LINE-HEIGHT: 20px; FONT-FAMILY: Verdana, 'Lucida Grande', Verdana, Helvetica, sans-serif; COLOR: rgb(85,85,85); FONT-SIZE: 13px" class=Apple-style-span>linux bridge实现了ieee 802.1d协议，这个实现，应该是不能支持VLAN的功能。也就是说，这个实现，只能承载一个广播域，而不能承载多个广播域。当然，可以创建多个bridge device，每个bridge都对应不同的vlan，在bridge内部，包通过fdb表来转发，但是这个fdb表里面并没有vlan的信息。如果要在多个bridge device之间通信，比必须在bridge device上创建vlan interface，然后配置路由，这样可以实现不同bridge之间的转发。<br>linux vlan实现了ieee 802.1q协议。802.1q本来应该是一个二层协议，但是linux的实现需要创建vlan interface,而且可以在vlan interface上配置ip地址。所以，这个interface可以放到路由表里面。一般来说，在这个interface上收到的包，会带这个interface配置的vlan id，而从这个interface发出去的包，会打上这个interface的vlan id.<br>举一个例子。一个盒子有6个物理interface, eth0,eth1,eth2,eth3,eth4,eth5,eth6.<br>bridge0 { eth0, eth1, eth2 }, vlan id 是2<br>bridge1 { eth3, eth4, eth5 }, vlan id 是3<br>eth0,eth1,eth2,eth3,eth4,eth5都在混杂模式，并且没有ip地址，它们是bridge的port.<br>创建vlan interface, bridge0.2, bridge1.3。在bridge0.2和bridge1.3上配置ip地址。vlan 2的机器，把bridge0.2的地址设置为缺省网关；vlan 3的机器，把bridge1.3设置为缺省网关。当有包要从vlan 2发往vlan 3是，它将送到bridge0.2，然后，通过路由，找到bridge1.3，然后由bridge1.3发出去。这个过程中，packet里面的vlan id会发生改变。<br>这个例子里面，要求从bridge port上收到的包都必须是打tag的，在bridge里面，并不能识别和处理tag，只有到三层的vlan interface才能识别并处理这些tag.<br>在bridge是还会运行STP协议来消除回环，进而实现了link一级的HA。STP，RSTP都是没有vlan的概念，而后来的PVST,PVST+，以及MSTP等，都能识别vlan，并且能消除一个vlan里面的回环。<br>关于Bridge，可以参考：<a style="FONT-STYLE: normal; COLOR: rgb(70,122,167); TEXT-DECORATION: none" href="http://www.linuxfoundation.org/en/Net:Bridge">http://www.linuxfoundation.org/en/Net:Bridge</a><br>关于Vlan,可以参考：<a style="FONT-STYLE: normal; COLOR: rgb(70,122,167); TEXT-DECORATION: none" href="http://www.candelatech.com/~greear/vlan.html">http://www.candelatech.com/~greear/vlan.html</a><br>关于STP，可以参考：<a style="FONT-STYLE: normal; COLOR: rgb(70,122,167); TEXT-DECORATION: none" href="http://en.wikipedia.org/wiki/Spanning_tree_protocol">http://en.wikipedia.org/wiki/Spanning_tree_protocol</a></span></span>
<img src ="http://www.cppblog.com/flyonok/aggbug/142600.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flyonok/" target="_blank">flyonok</a> 2011-03-23 18:04 <a href="http://www.cppblog.com/flyonok/articles/142600.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>debian相关管理命令</title><link>http://www.cppblog.com/flyonok/articles/142488.html</link><dc:creator>flyonok</dc:creator><author>flyonok</author><pubDate>Tue, 22 Mar 2011 08:34:00 GMT</pubDate><guid>http://www.cppblog.com/flyonok/articles/142488.html</guid><wfw:comment>http://www.cppblog.com/flyonok/comments/142488.html</wfw:comment><comments>http://www.cppblog.com/flyonok/articles/142488.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flyonok/comments/commentRss/142488.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flyonok/services/trackbacks/142488.html</trackback:ping><description><![CDATA[<span style="WIDOWS: 2; TEXT-TRANSFORM: none; TEXT-INDENT: 0px; BORDER-COLLAPSE: separate; FONT: medium Simsun; WHITE-SPACE: normal; ORPHANS: 2; LETTER-SPACING: normal; COLOR: rgb(0,0,0); WORD-SPACING: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px" class=Apple-style-span>1、aptitude：&#8220;+&#8221;选择安装，&#8220;g&#8221;安装， "ctrl" + t:转到菜单<br>2、用光盘安装软件 apt-cdrom add,apt-get install gcc</span>
<img src ="http://www.cppblog.com/flyonok/aggbug/142488.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flyonok/" target="_blank">flyonok</a> 2011-03-22 16:34 <a href="http://www.cppblog.com/flyonok/articles/142488.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>linux -- signal process</title><link>http://www.cppblog.com/flyonok/articles/53250.html</link><dc:creator>flyonok</dc:creator><author>flyonok</author><pubDate>Sat, 14 Jun 2008 08:09:00 GMT</pubDate><guid>http://www.cppblog.com/flyonok/articles/53250.html</guid><wfw:comment>http://www.cppblog.com/flyonok/comments/53250.html</wfw:comment><comments>http://www.cppblog.com/flyonok/articles/53250.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flyonok/comments/commentRss/53250.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flyonok/services/trackbacks/53250.html</trackback:ping><description><![CDATA[原帖发表在IBM的developerworks网站上，是一个系列的文章，作者郑彦兴，通过讲解和例子演示了Linux中几种IPC的使用方式，我觉得很好，在这里做一个保留，能看完的话Linux IPC的基础是没有问题的了。<br><br>一）Linux环境进程间通信（一）管道及有名管道<br><a  href="http://www.ibm.com/developerworks/cn/linux/l-ipc/part1/">http://www.ibm.com/developerworks/cn/linux/l-ipc/part1/</a><br><br>二）Linux环境进程间通信（二）: 信号<br>上：<a  href="http://www.ibm.com/developerworks/cn/linux/l-ipc/part2/index1.html">http://www.ibm.com/developerworks/cn/linux/l-ipc/part2/index1.html</a><br>下：<a  href="http://www.ibm.com/developerworks/cn/linux/l-ipc/part2/index2.html">http://www.ibm.com/developerworks/cn/linux/l-ipc/part2/index2.html</a><br><br>三）Linux环境进程间通信（三）消息队列<br><a  href="http://www.ibm.com/developerworks/cn/linux/l-ipc/part3/">http://www.ibm.com/developerworks/cn/linux/l-ipc/part3/</a><br><br>四）Linux环境进程间通信（四）信号灯<br><a  href="http://www.ibm.com/developerworks/cn/linux/l-ipc/part4/">http://www.ibm.com/developerworks/cn/linux/l-ipc/part4/</a><br><br>五）Linux环境进程间通信（五）: 共享内存<br>上：<a  href="http://www.ibm.com/developerworks/cn/linux/l-ipc/part5/index1.html">http://www.ibm.com/developerworks/cn/linux/l-ipc/part5/index1.html</a><br>下：<a  href="http://www.ibm.com/developerworks/cn/linux/l-ipc/part5/index2.html">http://www.ibm.com/developerworks/cn/linux/l-ipc/part5/index2.html</a><img src ="http://www.cppblog.com/flyonok/aggbug/53250.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flyonok/" target="_blank">flyonok</a> 2008-06-14 16:09 <a href="http://www.cppblog.com/flyonok/articles/53250.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>UNIX和Linux中的信号</title><link>http://www.cppblog.com/flyonok/articles/48764.html</link><dc:creator>flyonok</dc:creator><author>flyonok</author><pubDate>Sun, 04 May 2008 04:42:00 GMT</pubDate><guid>http://www.cppblog.com/flyonok/articles/48764.html</guid><wfw:comment>http://www.cppblog.com/flyonok/comments/48764.html</wfw:comment><comments>http://www.cppblog.com/flyonok/articles/48764.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flyonok/comments/commentRss/48764.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flyonok/services/trackbacks/48764.html</trackback:ping><description><![CDATA[1 ~ 31的信号为传统UNIX支持的信号，是不可靠信号(非实时的)，编号为32 ~ 63的信号是后来扩充的，称做可靠信号(实时信号)。不可靠信号和可靠信号的区别在于前者不支持排队，可能会造成信号丢失，而后者不会。<br>&nbsp;<br>另外注意：<br>＊ 多个实时信号的响应顺序是有保证的。<br>＊ 如果一个进程同时有实时信号和标准信号在pending，则优先响应标准信号。<br>大家用的一般都是非时实信号，下边是信号列表.<br><br>1) SIGHUP<br>本信号在用户终端连接(正常或非正常)结束时发出, 通常是在终端的控制进程结束时, 通知同一session内的各个作业, 这时它们与控制终端不再关联。<br><br>登录Linux时，系统会分配给登录用户一个终端(Session)。在这个终端运行的所有程序，包括前台进程组和后台进程组，一般都属于这个 Session。当用户退出Linux登录时，前台进程组和后台有对终端输出的进程将会收到SIGHUP信号。这个信号的默认操作为终止进程，因此前台进程组和后台有终端输出的进程就会中止。不过可以捕获这个信号，比如wget能捕获SIGHUP信号，并忽略它，这样就算退出了Linux登录，wget也能继续下载。<br><br><font><font><font class="f14" id="zoom"><font color="#000000">此外，对于与终端脱离关系的守护进程，这个信号用于通知它重新读取配置文件。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">2) SIGINT<span style="display: none;">EU5Linux联盟</span><br>程序终止(interrupt)信号, 在用户键入INTR字符(通常是Ctrl-C)时发出，用于通知前台进程组终止进程。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">3) SIGQUIT<span style="display: none;">EU5Linux联盟</span><br>和SIGINT类似, 但由QUIT字符(通常是Ctrl-\)来控制. 进程在因收到SIGQUIT退出时会产生core文件, 在这个意义上类似于一个程序错误信号。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">4) SIGILL<span style="display: none;">EU5Linux联盟</span><br>执行了非法指令. 通常是因为可执行文件本身出现错误, 或者试图执行数据段. 堆栈溢出时也有可能产生这个信号。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">5) SIGTRAP<span style="display: none;">EU5Linux联盟</span><br>由断点指令或其它trap指令产生. 由debugger使用。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">6) SIGABRT<span style="display: none;">EU5Linux联盟</span><br>调用abort函数生成的信号。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">7) SIGBUS<span style="display: none;">EU5Linux联盟</span><br>非法地址, 包括内存地址对齐(alignment)出错。比如访问一个四个字长的整数, 但其地址不是4的倍数。它与SIGSEGV的区别在于后者是由于对合法存储地址的非法访问触发的(如访问不属于自己存储空间或只读存储空间)。</font></font></font></font><br><font><font><font class="f14" id="zoom"><font color="#000000"><br>8）</font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">SIGFPE<span style="display: none;">EU5Linux联盟</span><br>在发生致命的算术运算错误时发出. 不仅包括浮点运算错误, 还包括溢出及除数为0等其它所有的算术的错误。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">9) SIGKILL<span style="display: none;">EU5Linux联盟</span><br>用来立即结束程序的运行. 本信号不能被阻塞、处理和忽略。如果管理员发现某个进程终止不了，可尝试发送这个信号。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">10) SIGUSR1<span style="display: none;">EU5Linux联盟</span><br>留给用户使用<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">11) SIGSEGV<span style="display: none;">EU5Linux联盟</span><br>试图访问未分配给自己的内存, 或试图往没有写权限的内存地址写数据.<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">12) SIGUSR2<span style="display: none;">EU5Linux联盟</span><br>留给用户使用<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">13) SIGPIPE<span style="display: none;">EU5Linux联盟</span><br>管道破裂。这个信号通常在进程间通信产生，比如采用FIFO(管道)通信的两个进程，读管道没打开或者意外终止就往管道写，写进程会收到SIGPIPE信号。此外用Socket通信的两个进程，写进程在写Socket的时候，读进程已经终止。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">14) SIGALRM<span style="display: none;">EU5Linux联盟</span><br>时钟定时信号, 计算的是实际的时间或时钟时间. alarm函数使用该信号.<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">15) SIGTERM<span style="display: none;">EU5Linux联盟</span><br>程序结束(terminate)信号, 与SIGKILL不同的是该信号可以被阻塞和处理。通常用来要求程序自己正常退出，shell命令kill缺省产生这个信号。如果进程终止不了，我们才会尝试SIGKILL。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">17) SIGCHLD<span style="display: none;">EU5Linux联盟</span><br>子进程结束时, 父进程会收到这个信号。<br><br>17) SIGCHLD<br>子进程结束时, 父进程会收到这个信号。<br><br>如果父进程没有处理这个信号，也没有等待(wait)子进程，子进程虽然终止，但是还会在内核进程表中占有表项，这时的子进程称为僵尸进程。这种情况我们应该避免(父进程或者忽略SIGCHILD信号，或者捕捉它，或者wait它派生的子进程，或者父进程先终止，这时子进程的终止自动由init进程来接管)。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">18）SIGCONT<span style="display: none;">EU5Linux联盟</span><br>让一个停止(stopped)的进程继续执行. 本信号不能被阻塞. 可以用一个handler来让程序在由stopped状态变为继续执行时完成特定的工作. 例如, 重新显示提示符<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">19) SIGSTOP<span style="display: none;">EU5Linux联盟</span><br>停止(stopped)进程的执行. 注意它和terminate以及interrupt的区别:该进程还未结束, 只是暂停执行. 本信号不能被阻塞, 处理或忽略.<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">20) SIGTSTP<span style="display: none;">EU5Linux联盟</span><br>停止进程的运行, 但该信号可以被处理和忽略. 用户键入SUSP字符时(通常是Ctrl-Z)发出这个信号。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">21) SIGTTIN<span style="display: none;">EU5Linux联盟</span><br>当后台作业要从用户终端读数据时, 该作业中的所有进程会收到SIGTTIN信号. 缺省时这些进程会停止执行.<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">22) SIGTTOU<span style="display: none;">EU5Linux联盟</span><br>类似于SIGTTIN, 但在写终端(或修改终端模式)时收到.<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">23) SIGURG<span style="display: none;">EU5Linux联盟</span><br>有"紧急"数据或out-of-band数据到达socket时产生.<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">24) SIGXCPU<span style="display: none;">EU5Linux联盟</span><br>超过CPU时间资源限制. 这个限制可以由getrlimit/setrlimit来读取/改变。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">25) SIGXFSZ<span style="display: none;">EU5Linux联盟</span><br>当进程企图扩大文件以至于超过文件大小资源限制。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">25) SIGXFSZ<span style="display: none;">EU5Linux联盟</span><br>当进程企图扩大文件以至于超过文件大小资源限制。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">27) SIGPROF<span style="display: none;">EU5Linux联盟</span><br>类似于SIGALRM/SIGVTALRM, 但包括该进程用的CPU时间以及系统调用的时间<br><br>28）</font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">SIGWINCH<span style="display: none;">EU5Linux联盟</span><br>窗口大小改变时发出.<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">29) SIGIO<span style="display: none;">EU5Linux联盟</span><br>文件描述符准备就绪, 可以开始进行输入/输出操作.<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">30) SIGPWR<span style="display: none;">EU5Linux联盟</span><br>Power failure<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">31) SIGSYS<span style="display: none;">EU5Linux联盟</span><br>非法的系统调用。<br><br></font></font></font></font><font><font><font class="f14" id="zoom"><font color="#000000">在以上列出的信号中，程序不可捕获、阻塞或忽略的信号有：SIGKILL,SIGSTOP<span style="display: none;">EU5Linux联盟</span><br>不能恢复至默认动作的信号有：SIGILL,SIGTRAP<span style="display: none;">EU5Linux联盟</span><br>默认会导致进程流产的信号有：SIGABRT,SIGBUS,SIGFPE,SIGILL,SIGIOT,SIGQUIT,SIGSEGV,<span style="display: none;">EU5Linux联盟</span><br>SIGTRAP,SIGXCPU,SIGXFSZ<span style="display: none;">EU5Linux联盟</span><br>默认会导致进程退出的信号有：SIGALRM,SIGHUP,SIGINT,SIGKILL,SIGPIPE,SIGPOLL,<span style="display: none;">EU5Linux联盟</span><br>SIGPROF,SIGSYS,SIGTERM,SIGUSR1,SIGUSR2,SIGVTALRM<span style="display: none;">EU5Linux联盟</span><br>默认会导致进程停止的信号有：SIGSTOP,SIGTSTP,SIGTTIN,SIGTTOU<span style="display: none;">EU5Linux联盟</span><br>默认进程忽略的信号有：SIGCHLD,SIGPWR,SIGURG,SIGWINCH<span style="display: none;">EU5Linux联盟</span><br><span style="display: none;">EU5Linux联盟</span><br>此外，SIGIO在SVR4是退出，在4.3BSD中是忽略；SIGCONT在进程挂起时是继续，否则是忽略，不能被阻塞。</font></font></font></font><br><img src ="http://www.cppblog.com/flyonok/aggbug/48764.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flyonok/" target="_blank">flyonok</a> 2008-05-04 12:42 <a href="http://www.cppblog.com/flyonok/articles/48764.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Useful Tips I Learned from Hacking Linux (Some in a Hard Way)</title><link>http://www.cppblog.com/flyonok/articles/44574.html</link><dc:creator>flyonok</dc:creator><author>flyonok</author><pubDate>Sat, 15 Mar 2008 09:34:00 GMT</pubDate><guid>http://www.cppblog.com/flyonok/articles/44574.html</guid><wfw:comment>http://www.cppblog.com/flyonok/comments/44574.html</wfw:comment><comments>http://www.cppblog.com/flyonok/articles/44574.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flyonok/comments/commentRss/44574.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flyonok/services/trackbacks/44574.html</trackback:ping><description><![CDATA[<ul>
    <li><strong>Debug kernel module with BUG() or BUG_ON()</strong>. In the code, put something
    like <font color="#ff8899">if (impossible cond) BUG(); </font>. This will
    cause kernel print trace and die, thus you have a chance to find early
    something bad happened.
    <p>
    After crash, from console, write down EIP's value, function name, and offset. For example:
    <font color="#ff8899">EIP [e09d76d0] find_min+0x60/0x240</font>. Of course
    you also want to write down stack trace.
    </p>
    <p>
    Now, use <font color="#ff8899">objdump -d -S module.ko</font> to disassemble
    your kernel module. Find the offending function (e.g., find_min), plus the
    offset (e.g., 0x60), then see which C code cause the problem.
    </p>
    <p>
    Another way: e.g., <font color="#ff8899">gdb module.ko</font>, use <font color="#ff8899">disassemble find_min</font>
    to show assembly, <font color="#ff8899">list *find_min+96</font> to see source line number, and
    <font color="#ff8899">dir kernel_include_dir</font> to add kernel header path to GDB's search path.
    </p>
    <p>
    Read more detailed process: <a  href="http://kerneltrap.org/node/3648">How To Locate An Oops</a>
    by Denis Vlasenko.
    </p>
    </li>
    <li><strong>SMP spin lock issues:</strong> Pretty much everything you need to know
    can be found in <em>Documentation/spinlocks.txt</em> included in the kernel source.
    <p>
    Typical use is spin_lock_irqsave() ...
    spin_unlock_irqrestore(). Local interrupt is disabled so that no local
    interruptions, spin locks ensure cross processor safety. However, the catch
    here is cache coherency and speculative execution of CPUs.
    </p>
    <p>
    Simply put, spin_lock() is barrier (using lock prefix), but spin_unlock()
    is not. On x86, write is ordered, but speculative read is possible and
    could cause problem in the case of spin_unlock() followed by spin_lock().
    </p>
    <p>
    See this <a  href="http://www.well.com/%7Ealeks/CompOsPlan9/0001.html">email</a>
    for some discussion.
    </p>
    <p>
    If a problem occurs, consider smp_mb(), smp_wmb(), and smp_rmb().
    </p>
    </li>
    <li>Print Chinese in Mozilla/Firefox &amp;
    <strong>Chinese support for Ghostview</strong>: modify file "CIDFnmap" (typically in
    /usr/share/ghostscript/7.07/lib) by adding a line like this:
    <font color="#ff8899">(CIDFnmap.mine) .runlibfileifexists</font>.
    Then create file CIDFnmap.mine in the same directory with these two lines:
    <font color="#ff8899">/SIMSUN (/usr/share/fonts/windows/simsun.ttc);</font> and
    <font color="#ff8899">/SIMHEI (/usr/share/fonts/windows/simhei.ttf);</font>.
    Assuming you've copied simsun.ttc and simhei.ttf to /usr/share/fonts/windows/.
    Now test your gv with this <a  href="http://www.cs.ucsb.edu/%7Ejzhou/linux/test.ps">file</a>.
    <p>
    </p>
    </li>
    <li><strong>Set 100Mbps card to work in 10Mbps mode</strong>: <font color="#ff8899">/sbin/ethtool -s eth0 speed 10 duplex full autoneg off</font>, or try <font color="#ff8899">/sbin/mii-tool -F 10baseT-FD eth0</font> if ethtool doesn't work.
    <p>
    </p>
    </li>
    <li><strong>Combine multiple PS or PDF files into one PDF file</strong>:<br>
    <font color="#ff8899">gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=output.pdf input1.pdf input2.pdf</font>. <br>
    <font color="#ff8899">gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOUTPUTFILE=output.pdf input1.ps input2.ps</font>
    <p>
    </p>
    </li>
    <li><strong>XCIM conflicts with Acrobat Reader 7.0 (crash before start) in FC3</strong>: Put thest two lines: <font color="#ff8899">export XMODIFIERS=@im=SCIM</font>, <font color="#ff8899">export GTK_IM_MODULE=xim</font> in your ~/.bashrc file.
    <p>
    </p>
    </li>
    <li><strong>XCIM input for Emacs, Ctrl+Space doesn't work</strong>: invoke emacs with "-nw" flag, however this only works for consoles.
    </li>
    <li><strong>lftp</strong> connects to SSL-enabled ftp server:  <font color="#ff8899">lftp ftps://username:password@server:port</font>. Note "<em>ftps</em>" not "<em>ftp</em>".
    </li>
    <li><strong>User Mode Linux (UML)</strong> is merged with the default kernel since 2.6.9.
    However, the vanilla kernel is simply impossible for me to build a working
    UML (at least for 2.6.9 &amp; 2.6.10, while 2.6.11-rc5 is OK). I found out that
    using the <a  href="http://www.user-mode-linux.org/%7Eblaisorblade/patches/guest/uml-2.6.9-bb4/">bb4</a>
    patch can give me a working UML, though the default config is still buggy.
    Here is the <a  href="http://www.cs.ucsb.edu/%7Ejzhou/linux/uml-2.6.9.config">2.6.9 config</a> I used.
    Some problems remain:
    <ul>
        <li>Networking with slirp seems broken.
        </li>
        <li>SMP is broken (2.6.11-rc5 SMP version can't run very far during boot).
        </li>
        <li>Enable SMP and kernel debug symbol will cause error during last step linking: kernel/profile.c:199 profile_pc undefined.
        </li>
    </ul>
    <p>
    Working <a  href="http://www.cs.ucsb.edu/%7Ejzhou/linux/uml-2.6.12-rc2.config">2.6.12-rc2 config</a>
    </p>
    <p>
    </p>
    </li>
    <li><strong>Network backup using netcat</strong>: at server <font color="#ff8899">nc -l -p 3000 | tar xvf -</font>, at client <font color="#ff8899">tar cvf - files_and_directories | nc server 3000</font>. 3000 is port number used. The idea is to tar everything, send to server, and extract the tar ball at server.
    <p>
    </p>
    </li>
    <li><strong>CUPS printer daemon saying "printer not ready" even there is no job running.</strong>:
    This rarely happened problem may be caused by configuration problems.
    Look at /etc/cups/printers.conf and see if "State Stopped" appears
    instead of the correct "State Idle". Make the the change and restart
    CUPS daemon.
    <p>
    </p>
    </li>
    <li><strong>iPod on Linux</strong>: Use <font color="#ff8899">dmesg</font> to find out the device name of iPod, e.g., mine is sda. <font color="#ff8899">eject /dev/sda</font>
    (if /dev/sda is no good, use /dev/sda2) can be issued as root to get
    rid of "Do not disconnect" on the iPod screen and returning to normal
    menu. You can mount sda2 as vfat file system to see structures on your
    iPod.
    <p>
    </p>
    </li>
    <li><strong>Grammar check for LaTex files</strong>: <a  href="http://latex2rtf.sourceforge.net/">latex2rtf</a>
    can convert Tex sources into RTF files, which can then be read by
    OpenOffice or M$ Office for grammar check. An alternative is to use
    latex2html, but I have problems with it.
    <p>
    </p>
    </li>
    <li><strong>Mount remote file systems via SSH (all users)</strong>: Use <a  href="http://fuse.sourceforge.net/sshfs.html">SSHFS</a>, simply run <font color="#ff8899">sshfs hostname: mountpoint</font>.  SSHFS depends on <a  href="http://fuse.sourceforge.net/">FUSE</a>, which is already included in the main stream Linux since 2.6.14. To unmount, run <font color="#ff8899">fusermount -u mountpoint</font>.
    <p>
    </p>
    </li>
    <li><strong>Latex Related Tips:</strong>
    <ul>
        <li><strong>Make a PDF document</strong>:
        1) LaTeX (+bibTeX) -&gt; dvips -&gt; ps2pdf. Use "hyperref" package for
        hyperlinks and remember to add the "breaklinks=true" option to break
        references that exceed one line, especially for List of Figures/Tables.
        2) pdfLaTeX (+bibTeX). Must convert all .eps-graphics into PDF format.
        Use "epstopdf". See this <a  href="http://dionysos.mpch-mainz.mpg.de/%7Ejoeckel/pdflatex/">page</a> for more details.
        </li>
        <li><strong>hyperref package causes long URLs not wrapping (breaking into multiple lines)</strong>:
        I had this problem for bibliography. My solution is to renew the \url command
        <font color="#ff8899">\renewcommand\url{\begingroup \Url}</font> of the url package,
        but hyper-links will be missing for URLs.
        </li>
        <li><strong>Balances columns on last page in twocolumn mode</strong>: use "<a  href="http://www.cs.ucsb.edu/%7Ejzhou/linux/flushend.sty">flushend</a>" package, i.e., <font color="#ff8899">\usepackage{flushend}</font>.
        </li>
        <li><a  href="http://mintaka.sdsu.edu/GF/bibliog/latex/floats.html">Controlling LaTeX Floats</a>
        </li>
    </ul>
    <p>
    </p>
    </li>
    <li><strong>.avi file editing with mencoder</strong>
    <ul>
        <li>Split: <font color="#ff8899">mencoder -ovc copy -oac copy -endpos 0:50:00 -o foo-part1.avi foo.avi</font> split ends at 50 minutes,<br>
        <font color="#ff8899">mencoder -ovc copy -oac copy -ss 0:50:00 -o foo-part2.avi foo.avi</font> split starts at 50 minutes.
        </li>
        <li>Transcode, see this <a  href="http://gentoo-wiki.com/HOWTO_Mencoder_Introduction_Guide">page</a>,
        e.g., <font color="#ff8899">mencoder foo.avi -o bar.avi -ovc lavc -oac lavc</font>
        </li>
    </ul>
    <p>
    </p>
    </li>
    <li><strong>Recovery deleted files or lost partitions</strong>: <a  href="http://www.cgsecurity.org/wiki/TestDisk">TestDisk</a> and <a  href="http://www.cgsecurity.org/wiki/PhotoRec">PhotoRec</a>.
    Both tools are free, work on Linux/Win/Mac, and are said to work for
    CDs, DVDs, and flash media. It seems both read raw sectors and try to
    recognize files, so recovery is quite complete if lost files are not
    overwritten by other data.
    <p>
    </p>
    </li>
    <li><strong>Display Chinese characters in terminals</strong>: Create ~/.i18n file with content:<br>
    <font color="#ff8899">LANG=zh_CN.GB2312</font><br>
    <font color="#ff8899">LANGUAGE=en_US.UTF-8</font><br>
    <font color="#ff8899">LC_CTYPE=zh_CN.GB2312</font><br>
    <font color="#ff8899">LC_TIME=en_US.UTF-8</font><br>
    <p>
    </p>
    </li>
    <li><a  href="http://prdownloads.sourceforge.net/souptonuts/How_to_Linux_and_Open_Source.txt?download">100</a> Linux tips by Mike Chirico.
    </li>
</ul>
<h3>Free Online Linux Books</h3>
<ul>
    <li><a  href="http://www.faqs.org/docs/artu/">The Art of Unix Programming</a>, HTML, Addison-Wesley.
    </li>
    <li><a  href="http://lwn.net/Articles/127556/">Linux Device Drivers, Third Edition</a>, PDF, O'Reilly.
    </li>
    <li><a  href="http://sources.redhat.com/autobook/autobook/autobook_toc.html">GNU autoconf, automake, and libtool</a>, HTML, Pearson Education.
    </li>
    <li><a  href="http://www.csn.ul.ie/%7Emel/projects/vm/guide/html/understand/">Understanding Linux Virtual Memory Manager</a>, Prentice Hall.
    </li>
    <li><a  href="http://www.oreilly.com/catalog/docbook/chapter/book/docbook.html">DocBook: The Definitive Guide</a>, HTML, O'Reilly.
    </li>
</ul>
<h3>My Favoriate FREE Linux Tools</h3>
<ul>
    <li>Terminals
    <ul>
        <li>konsole - KDE Terminal
        </li>
        <li>screen - console tool
        </li>
    </ul>
    </li>
    <li>X Window Manager
    <ul>
        <li>KDE - favoriate, more themes/icons/color/etc. can be found <a  href="http://kdelook.org/">here</a>
        </li>
        <li>Gnome
        </li>
        <li><a  href="http://www.scim-im.org/">XCIM</a> - Chinese X input.
        </li>
    </ul>
    </li>
    <li>Document Editor/Reader:
    <ul>
        <li><a  href="http://www.vim.org/">vim</a> - classic and great!
        </li>
        <li>emacs
        </li>
        <li><a  href="http://www.adobe.com/support/downloads/product.jsp?product=10&amp;platform=unix">Acrobat Reader</a> - for PDF file
        </li>
        <li>xCHM - viewer for M$ .chm file
        </li>
    </ul>
    </li>
    <li>Media:
    <ul>
        <li><a  href="http://www.mplayerhq.hu/homepage/">mplayer</a> - Player for everything! DivX avi, mov, asf, wmv, etc.
        Included "mencoder" can do transcoding.
        </li>
        <li><a  href="http://linuxfans.org/nuke/modules.php?name=Site_Downloads&amp;op=geninfo&amp;did=4073">SopCast GUI</a> - Network TV (using mplayer as backend)
        </li>
        <li>xmms - mp3 player, APE plugin can be found <a  href="http://sourceforge.net/projects/mac-port/">here</a>
        </li>
        <li>RealPlayer - real media
        </li>
        <li>transcode - avi file editing, includes avifix, avisplit, avimerge, avisync
        </li>
        <li>GQView - image viewer
        </li>
        <li>GIMP - image editor like Photoshop
        </li>
        <li><a  href="http://mkgallery.sourceforge.net/">mkgallery</a>,
        <a  href="http://bbgallery.sourceforge.net/">bbgallery</a>
        - Photo gallery creation, using ImageMagick
        </li>
        <li>CD Burning:
        <ul>
            <li>xcdroast, k3b - great GUI
            </li>
            <li>cdrecord - command line tool
            </li>
            <li>cdrdao - burn bin/cue file
            </li>
            <li><a  href="http://hes.iki.fi/bchunk/">bchunk</a> - convert .bin/.cue files to .iso and .cdr tracks
            </li>
        </ul>
        </li>
    </ul>
    </li>
    <li>Office:
    <ul>
        <li>latex - professional documentation package
        <ul>
            <li><a  href="http://www.ctan.org/tex-archive/language/chinese/CJK/4_5.2/">CJK</a> - Chinese Latex support
            </li>
        </ul>
        </li>
        <li>GhostScript and GhostView
        </li>
        <li><a  href="http://www.research.att.com/sw/tools/graphviz/refs.html">Graphviz</a> - graph creations
        </li>
        <li><a  href="http://www.lri.fr/%7Efilliatr/bibtex2html/">bibtex2html</a> - transform bibliography to html
        </li>
        <li>Evolution - Email/Calendar/AddressBook groupware
        </li>
        <li>OpenOffice - document processing, spreadsheet, and presentation
        </li>
        <li><a  href="http://stardict.sourceforge.net/index.php">StarDict</a>, <a  href="http://sdcv.sourceforge.net/">sdcv</a> - dictionary
        </li>
    </ul>
    </li>
    <li>Development:
    <ul>
        <li><a  href="http://valgrind.org/">ValGrind</a> - very handy memory debugger, profiler; a MUST for serious C/C++ programs.
        </li>
        <li><a  href="http://kgdb.linsyssoft.com/index.html">KGDB</a> - Linux kernel debugger
        </li>
        <li><a  href="http://oprofile.sourceforge.net/news/">OProfile</a>, statistical profiler for both the kernel and user programs.
        </li>
        <li>cvs - version control [<a  href="http://cvsbook.red-bean.com/cvsbook.html">doc.</a>]
        </li>
        <li>Programming Languages: c, c++, tcl/tk, perl, java, shell, sed, awk
        </li>
        <li><a  href="http://www.gnu.org/software/flex/">flex</a> - GNU lexical analyzer
        </li>
        <li><a  href="http://www.gnu.org/software/bison/bison.html">bison</a> - GNU Yacc-like parser generator
        </li>
        <li>gcc - GNU c/c++ compiler
        </li>
        <li>gdb - GNU debugger
        </li>
        <li>make, GNU <a  href="http://www.gnu.org/manual/automake-1.7.2/html_mono/automake.html">automake</a>,
        GNU <a  href="http://www.gnu.org/manual/autoconf-2.57/html_mono/autoconf.html">autoconf</a>, libtool
        </li>
        <li><a  href="http://www.mysql.com/">MySQL</a> - database
        </li>
        <li>libnet - packet injection library
        </li>
        <li>libpcap - packet capture library
        <!--
        <li><a href="http://www.borland.com/jbuilder/">JBuilder</a> - Java IDE
        -->
        </li>
    </ul>
    </li>
    <li>Security:
    <ul>
        <li>lsof - command, list open files
        </li>
        <li>truss - command, trace system calls of a program
        </li>
        <li>top - command, resource usage
        </li>
        <li>vmstat - command, virtual memory usage
        </li>
        <li>w - command, current user
        </li>
        <li><a  href="http://www.insecure.org/nmap/">nmap</a> - best scanning tool
        </li>
        <li><a  href="http://www.openwall.com/john/">John the Ripper</a> - password cracker
        </li>
        <li><a  href="http://www.tcpdump.org/">tcpdump</a> - network sniffer
        </li>
        <li>snort - network intrusion detection system
        </li>
        <li><a  href="http://www.circlemud.org/%7Ejelson/software/tcpflow/">tcpflow</a> - reconstruct end-to-end TCP traffic
        </li>
        <li>iptable - firewall
        </li>
        <li><a  href="http://www.tripwire.com/">tripwire</a> - system integrity check
        </li>
        <li>Encryption, Data Signing
        <ul>
            <li>GnuPG
            </li>
            <li>pgp
            </li>
        </ul>
        </li>
    </ul>
    </li>
    <li>Networking:
    <ul>
        <li>pine - console based e-mail client
        </li>
        <li><a  href="http://www.apache.org/">Apache</a> web server
        <ul>
            <li><a  href="http://www.php.net/">PHP</a> - php support
            </li>
            <li><a  href="http://dominia.org/djao/limitipconn.html">mod_limitipconn</a> - limit the simultaneous connections from a certain IP
            </li>
            <li><a  href="http://www.menalto.com/projects/gallery/index.php">gallery</a> - on-line photo gallery
            </li>
        </ul>
        </li>
        <li><a  href="http://www.samba.org/">Samba</a> - File server
        </li>
        <li>Proxy Servers:
        <ul>
            <li>Squid
            </li>
            <li>Socks5
            </li>
        </ul>
        </li>
        <li>Web Browsers:
        <ul>
            <li>Firefox (supersedes Mozilla) and <a  href="http://texturizer.net/firefox/extensions/">extensions</a>:
            <a  href="https://addons.mozilla.org/firefox/10/">Adblock</a>,
            <a  href="https://addons.mozilla.org/firefox/722/">NoScript</a>,
            <a  href="https://addons.mozilla.org/firefox/158/">Tabbrowser Preferences</a>,
            <a  href="https://addons.mozilla.org/firefox/383/">Auto Copy</a>,
            <a  href="https://addons.mozilla.org/addon.php?id=2464">FoxyProxy</a> - advanced proxy management
            </li>
            <li><a  href="http://www.konqueror.org/">konqueror</a> - KDE web browser, fast
            </li>
            <li><a  href="http://www.opera.com/">Opera</a> - fast
            </li>
        </ul>
        </li>
        <li><a  href="http://qterm.sourceforge.net/">QTerm</a> - BBS Client in Linux
        </li>
        <li>wget - web/FTP download client
        </li>
        <li>ncftp, lftp - command line FTP client
        </li>
        <li>VNC - remote desktop
        </li>
        <li><a  href="http://www.stunnel.org/">stunnel</a> - SSL tunnel for TCP connections
        </li>
        <li>Gnutella clients:
        <ul>
            <li><a  href="http://gtk-gnutella.sourceforge.net/">gtk-gnutella</a>
            </li>
            <li>LimeWire
            </li>
        </ul>
        </li>
        <li>gaim - integrates IMs such as ICQ, MSN, Yahoo!
        </li>
        <li><a  href="http://www.rdesktop.org/">rdesktop</a> - Windows terminal service client
        </li>
        <li>SSH Client/Server:
        <ul>
            <li>OpenSSH
            </li>
            <li>SSH - from www.ssh.com
            </li>
        </ul>
        </li>
        <li>UCD-SNMP - snmp utility
        </li>
    </ul>
    </li>
    <li>File Utility:
    <ul>
        <li>tar - archive files
        </li>
        <li><a  href="http://www.rarsoft.com/">rar</a> - for rar archive
        </li>
        <li>zip/unzip - for .zip file
        </li>
        <li>bzip2/bunzip2 - for .bz2 file
        </li>
        <li>gzip/gunzip - for .gz file
        </li>
        <li>md5sum - generate md5 hash
        </li>
        <li>sha1sum - generate SHA-1 hash
        </li>
        <li><a  href="http://www.fodder.org/cksfv/">cksfv</a> - CRC checking, linux couterpart for WinSFV
        </li>
        <li><a  href="http://www.kyz.uklinux.net/cabextract.php3">cabextract</a> - extract M$ .cab file
        </li>
    </ul>
    </li>
</ul>
<h3>Other Resources</h3>
<ul>
    <li><a  href="http://www.howtoforge.com/mod_cband_apache2_bandwidth_quota_throttling">Manage Apache Download Speed And Traffic Limits With mod_cband</a>
    </li>
    <li><a  href="http://reallylinux.com/docs/linuxmuscle.shtml">Fundamentals of Massive Linux Scaling</a>
    </li>
    <li><a  href="http://www-128.ibm.com/developerworks/linux/library/l-cluster2/?ca=dgr-lnxwClusterP2">High performance Linux clustering, Part 2: Build a working cluster</a>
    </li>
    <li><a  href="http://lxr.linux.no/source/">Cross-Referencing Linux</a>
    </li>
    <li><a  href="http://www.cs.utexas.edu/users/ygz/378-03S/">Linux Kernel Programming</a>, lecture notes of Prof. Yongguang Zhang.
    </li>
    <li><a  href="http://fabrice.bellard.free.fr/qemu/">QEMU</a>, generic processor emulator.
    </li>
    <li><a  href="http://bochs.sourceforge.net/">Bochs</a>, IA-32 (x86) PC emulator.
    </li>
    <li><a  href="http://www.linuxdevcenter.com/pub/a/linux/2006/01/26/xen.html">Linux Virtualization with Xen</a>
    </li>
    <li><a  href="http://www-128.ibm.com/developerworks/linux/library/l-datavistools/?ca=dgr-lnxw02VisualToolsForLinux">Data visualization tools for Linux</a>
    </li>
</ul><img src ="http://www.cppblog.com/flyonok/aggbug/44574.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flyonok/" target="_blank">flyonok</a> 2008-03-15 17:34 <a href="http://www.cppblog.com/flyonok/articles/44574.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Linux DISPLAY环境变量</title><link>http://www.cppblog.com/flyonok/articles/44073.html</link><dc:creator>flyonok</dc:creator><author>flyonok</author><pubDate>Mon, 10 Mar 2008 04:39:00 GMT</pubDate><guid>http://www.cppblog.com/flyonok/articles/44073.html</guid><wfw:comment>http://www.cppblog.com/flyonok/comments/44073.html</wfw:comment><comments>http://www.cppblog.com/flyonok/articles/44073.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flyonok/comments/commentRss/44073.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flyonok/services/trackbacks/44073.html</trackback:ping><description><![CDATA[在Linux/Unix类操作系统上, DISPLAY用来设置将图形显示到何处. 直接登陆图形界面或者登陆命令行界面后使用startx启动图形,
DISPLAY环境变量将自动设置为:0:0, 此时可以打开终端, 输出图形程序的名称(比如xclock)来启动程序, 图形将显示在本地窗口上,
在终端上输入printenv查看当前环境变量, 输出结果中有如下内容: <br><br>DISPLAY=:0.0 <br><br>使用xdpyinfo可以查看到当前显示的更详细的信息. <br><br>DISPLAY
环境变量格式如下host:NumA.NumB, host指Xserver所在的主机主机名或者ip地址, 图形将显示在这一机器上,
可以是启动了图形界面的Linux/Unix机器, 也可以是安装了Exceed,
X-Deep/32等Windows平台运行的Xserver的Windows机器. 如果Host为空, 则表示Xserver运行于本机,
并且图形程序(Xclient)使用unix socket方式连接到Xserver, 而不是TCP方式. 使用TCP方式连接时,
NumA为连接的端口减去6000的值, 如果NumA为0, 则表示连接到6000端口; 使用unix
socket方式连接时则表示连接的unix socket的路径, 如果为0, 则表示连接到/tmp/.X11-unix/X0 .
NumB则几乎总是0. <br><br>如果使用su username或者su - username切换到别的用户, 并且使用命令<br><br>export DISPLAY=:0.0<br><br>设置DISPLAY环境变量, 运行图形程序(如xclock)时会收到如下错误: <br><br>Xlib: connection to ":0.0" refused by server<br>Xlib: No protocol specified<br><br>Error: Can't open display: :0.0<br><br>这是因为Xserver默认情况下不允许别的用户的图形程序的图形显示在当前屏幕上. 如果需要别的用户的图形显示在当前屏幕上, 则应以当前登陆的用户, 也就是切换身份前的用户执行如下命令<br><br>xhost +<br><br>这个命令将允许别的用户启动的图形程序将图形显示在当前屏幕上. <br><br>在2台Linux机器之间, 如果设置服务器端配置文件/etc/ssh/sshd_config中包含<br><br>X11Forwarding no <br><br>客户端配置文件/etc/ssh/ssh_config包含<br><br>ForwardX11 yes <br><br>则从客户端ssh到服务器端后会自动设置DISPLAY环境变量, 允许在服务器端执行的图形程序将图形显示在客户端上. 在服务器上查看环境变量显示如下(这个结果不同的时候并不相同)<br><br>DISPLAY=localhost:10.0 <br><br>在客户机上用netstat -lnp可以看到有程序监听了6010端口<br><br>tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 4827/1 <br><br>如
果希望允许远程机器上的图形程序将图形显示在本地机器的Xserver上, 除了要设置远端机器的DISPLAY环境变量以外,
还需要设置本地机器的Xserver监听相应的TCP端口. 而现在的Linux系统出于安全的考虑, 默认情况下不再监听TCP端口.
可通过修改/etc/X11/xinit/xserverrc文件, 将<br><br>exec /usr/bin/X11/X -dpi 100 -nolisten tcp <br><br>修改为<br><br>exec /usr/bin/X11/X -dpi 100<br><br>允许在直接使用startx启动图形时启动对TCP端口的监听. <br><br>修改/etc/kde3/kdm/kdmrc, 将<br><br>ServerArgsLocal=-nolisten tcp <br><br>修改为<br><br>ServerArgsLocal= <br><br>允许kdm作为显示管理器时, 启动会话时监听相应的TCP端口. <br><br>修改/etc/gdm/gdm.conf, 在[Security]一节增加<br><br>DisallowTCP=false <br><br>或
者在登陆窗口选择"Options" -&gt; "Configure Login Manager..."的Security页面,
取消"Deny TCP connections to Xserver", 允许gdm作为显示管理器时, 启动会话时监听相应的TCP端口.<img src ="http://www.cppblog.com/flyonok/aggbug/44073.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flyonok/" target="_blank">flyonok</a> 2008-03-10 12:39 <a href="http://www.cppblog.com/flyonok/articles/44073.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>lvm(逻辑卷管理器)的介绍和常用功能流程实验</title><link>http://www.cppblog.com/flyonok/articles/43854.html</link><dc:creator>flyonok</dc:creator><author>flyonok</author><pubDate>Thu, 06 Mar 2008 13:46:00 GMT</pubDate><guid>http://www.cppblog.com/flyonok/articles/43854.html</guid><wfw:comment>http://www.cppblog.com/flyonok/comments/43854.html</wfw:comment><comments>http://www.cppblog.com/flyonok/articles/43854.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flyonok/comments/commentRss/43854.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flyonok/services/trackbacks/43854.html</trackback:ping><description><![CDATA[<span class="a14c" id="zoom">vm(逻辑卷管理器)的介绍和常用功能流程实验<br><br>daweicheng<br><br>1) 前言<br>2) lvm组成和概念<br>3) 如何使用lvm,创建逻辑卷的流程和实例<br>4) 如何动态放大/缩小一个逻辑卷/逻辑卷组<br>5) 如何删除逻辑卷/逻辑卷组<br>6) lvm相关命令<br><br><br><br>1) 前言<br><br>一直想写一个简单的lvm方面的文章,可以作个背忘,主要以流程和实例为主，希望文章能起到抛砖引玉的<br><br>作用.<br><br>LVM=(Logical Volume Mamager)逻辑卷管理器,LVM最先是用在IBM AIX系统上,它的最大作用是可以动态分<br><br>配磁盘分区,并且可以让多个分区或者物理硬盘作为一个逻辑卷(相当于一个逻辑硬盘).这种机制可以让磁<br><br>盘分区容量划分变得很灵活.<br><br>我们先举个简单例子.比如我们有一个硬盘/dev/hda,分了3个主分区:hda1,hda2,hda3,后面磁盘空间没有<br><br>划分,分别对应的挂载点是/boot,/,/home,如果我们的/home空间不够了,怎么办?传统的方法是在未划分的<br><br>空间中分割一个分区,挂载到/home下,并且把hda3的内容复制到这个新分区上.或者把这个新分区挂载到另<br><br>外的挂载点上,然后在/home下创建链接,链接到这个新挂载点.<br><br>这两种方法都不大好,第一种方法浪费了hda3,并且如果后面的分区容量小于hda3怎么办?第二种方法不大<br><br>浪费容量,但是每次要额外创建链接,比较麻烦.那么,如果用lvm呢?lvm的好处在于,可以动态放大一个逻辑<br><br>卷(相当于一个逻辑分区),也就是说,hda3如果是一个逻辑分区,比如/dev/rootvg/lv3,那么lv3可以被动态<br><br>放大.这样就解决了动态容量调整的问题.当然,前提是系统已设定好lvm支持,并且需要动态缩放的挂载点<br><br>对应的设备是逻辑卷.<br><br>在这里，我所有例子都是基于RHEL 4/CentOS 4.x和LVM2的。<br><br>2) lvm组成和概念<br><br>这里参考了IBM 林彥明(Alex Lin)的&gt;)<br><br>PV(Physical Volume) 物理卷。可以是单独磁盘，也可以是硬盘分区<br>VG(Volume Group) 卷组。是PV的组合，可以看成单独的逻辑磁盘<br>LV(Logical Volume) 逻辑分区。相当于物理分区的/dev/hdaX<br>PE(Physical Extent) 物理范围。VG单元，类似于RAID的条带大小。<br>当多个PV组成一个VG时，LVM会在所有PV上做类似格式化的动作，<br>将每个PV切成一块块的空间，这一块块的空间就称为PE, 通常是4MB。<br>LE(Logical Extent) 逻辑范围。LV的组成单位。大小为PE的倍数(通常为1:1)<br><br>那么，最常用的3个名词和意义列表如下：<br>名词 意义 操作系统对应设备<br>PV 物理卷 /dev/hdaX<br>VG 卷组 /dev/ (通常是个目录)<br>LV 逻辑卷 /dev//<br><br>如果我们要使用lvm，顺序是pv-&gt;vg-&gt;lv。<br>就是说，我们先创建一个物理卷(对应一个物理硬盘分区或者一个物理硬盘)，然后把这些分区/硬盘加入<br><br>一个卷组中(相当于一个逻辑上的大硬盘)，然后我们在这个大硬盘上划分分区lv(逻辑上的分区，就是逻<br><br>辑卷)<br>这样，我们把lv逻辑卷格式化以后，就可以像使用一个传统分区那样，把它挂载到一个挂载点上，需要的<br><br>时候，这个逻辑卷可以被动态缩放。<br><br>我们可以用一个长方蛋糕来说明这个对应关系。物理硬盘相当于一个长方蛋糕，我们把它切割成许多快，<br><br>每个小块相当于一个pv，然后我们把其中的某些pv重新放在一起，抹上奶油，那么这么些个pv的组合就是<br><br>一个新的蛋糕，也就是vg。最后，我们切割这个新蛋糕vg，切出来的小蛋糕就叫做lv。<br><br>有一点需要注意，就是/boot区不可以是lvm，因为引导程序lilo/grub并不能识别lvm，就像/boot同样不<br><br>可以是软raid设备一样。<br><br>3) 如何使用lvm,创建逻辑卷的流程和实例<br><br>好了，我们来创建一个lv。<br><br>比如说，在一个物理硬盘/dev/hda上，我们需要将/dev/hda5,/dev/hda6作为pv<br><br>1 fdisk划分hda5,hda6，并且将这两个分区的标志(键入t改)改为(0x)8e<br>然后用partprobe通知OS磁盘分区的变化<br>2 pvcreate /dev/hda5 /dev/hda6(-s xxM可设定PE大小)<br>创建pv hda5,hda6<br>3 vgcreate rootvg /dev/hda5 /dev/hda6<br>将hda5,hda6加入逻辑卷组rootvg中<br>4 lvcreate -L 100M -n lv1 rootvg<br>从我们的rootvg中，创建一个100M的逻辑卷lv1<br>5 mkfs.ext3 /dev/rootvg/lv1<br>格式化我们的lv1，文件系统用ext3<br>6 mkdir /mnt/lvm;mount /dev/rootvg/lv1 /mnt/lvm<br>将lv1挂载到/mnt/lvm下<br><br>好了，这样一个创建lv的例子完成<br><br>4) 如何动态放大/缩小一个逻辑卷/逻辑卷组<br><br>我们如何放大lv?比如上面的lv1?流程：<br><br>1 lvextend -L+200M /dev/rootvg/lv1<br>将lv1增加200M<br>2 ext2online /dev/rootvg/lv1<br>让lv1容量更改立即生效<br><br>减小lv，网上很多文章介绍的是ReiserFS，这里我们是ext3文件系统，如果我们需要减少50M：<br><br>1 umount /mnt/lvm<br>这里，需要先卸载分区<br>2 mke2fs -n /dev/rootvg/lv1<br>计算lv1的block数<br>这里一定要加-n参数，这是计算lv1的block数，而不是格式化分区，注意。<br>并且注意，从MB-&gt;KB这些的计算，都是乘1024，不是1000，这是个细节问题<br>3 计算减少50M后的block数。从mke2fs -n /dev/rootvg/lv1，我们可以得出2个需要的信息：<br>Block size和blocks，这两个数的乘积就是分区大小A(单位字节)，<br>我们把需要减小的容量50M换算成字节B，然后A-B的结果除以Block size,就是剩余的block数<br>4 resize2fs -f /dev/rootvg/lv1 剩余的block数<br>调整文件系统大小<br>5 lvreduce -L-50M /dev/rootvg/lv1<br>调整lv分区大小，减小50M<br>6 重新mount，df察看一下容量的减小<br><br>动态加大VG：<br>这里我们新增一个PV并加入VG<br><br>1 fdisk增加一个(0x)8e标志的分区/dev/hda7<br>2 vgextend rootvg /dev/hda7<br><br>好了，vg增大了<br><br>缩小逻辑卷组VG：<br><br>1 搬移PV中的资料(只限于同一VG中)<br>#pvmove [-n ] []<br>如<br>#pvmove /dev/hda5 /dev/hda6<br>将VG中pv hda5的内容搬移到hda6中<br>pvmove /dev/hda5(也可以这样，lvm决定hda2的内容被复制到哪里)<br>2 vgreduce rootvg /dev/hda5<br>把vg hda5移除<br><br>5) 如何删除逻辑卷/逻辑卷组<br><br>删除VG流程：<br><br>1 umount /挂接点<br>2 lvremove /dev/rootvg/lv1<br>移除逻辑卷，这里是lv1<br>3 vgchange -a n rootvg(关闭rootvg)<br>4 vgremove rootvg<br>移除rootvg<br><br>6) lvm相关命令<br><br>这个表格，你可以在RHCE_Study_Guide.pdf上找到<br><br>Physical Volume Volume Group Logical Volume<br>scan pvscan vgscan lvscan<br>create pvcreate vgcreate lvcreate<br>display pvdispaly vgdisplay lvdisplay<br>remove pvremove vgremove lvremove
<div style="display: none;"><a  href="http://www.linuxeden.com/">文章来源:www.linuxeden.com-Linux伊甸园</a></div>
<br>
本站文章仅代表作者观点,本站仅传递信息,并不表示赞同或反对.转载本站点内容时请注明来自<a  href="http://www.linuxeden.com/">www.linuxeden.com</a>-Linux伊甸园。如不注明，<a  href="http://www.linuxeden.com/">www.linuxeden.com</a>将根据《互联网著作权行政保护办法》追究其相应法律责任。</span><img src ="http://www.cppblog.com/flyonok/aggbug/43854.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flyonok/" target="_blank">flyonok</a> 2008-03-06 21:46 <a href="http://www.cppblog.com/flyonok/articles/43854.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>