| qiwei's profiledreamdailyPhotosBlogLists | Help |
|
|
July 06 nfs --network file system 由于白云的主机空间不足,同时存放着一些备份数据,想把这些备份数据转 讲得比较详细。在新主机linux上设置好/etc/exports,然后启动nfs服务; 提示说权限不够!刚开始以为是客户端的问题,跑到CU去咨询,后来别人回帖说, 重新看了nfs howto,发现在设置服务时,默认的是no_root_quash: June 15 GNU profiler有空学习一下~ IBM DW上有个教程:使用 GNU profiler 来提高代码运行速度 http://www-128.ibm.com/developerworks/cn/linux/l-gnuprof.html?ca=drs- linux下的运行时内核管理linux的内核是单内核的;传统上单内核相对于微内核来说,扩展性差一些。 但是Linux下通过可动态加载和下载的内核模块来弥补了这个缺陷,达到了 完美! 首先,我们当然想看一下,现在linux系统里运行了哪些内核模块。没有内核, 敲入lsmod,就可以查看到了。输出如下: Module Size Used by loop 18761 0 ipt_REJECT 10433 1 ipt_state 5825 6 ip_conntrack 45701 1 ipt_state 第一列是模块的名称,第二列是模块的大小,第三列代表模块的使用计数, 如果有其他模块在使用这个模块,那么在后边会跟上其他模块的名称! (通过strace lsmod,我们可以发现lsmod其实就是去读取/proc/modules文件 的内容进行显示的) 现在我们知道了,原来系统里有这么多的模块在内核里,那么这些每个内核模块 都是干什么用的? 这些模块所对应的文件在哪里呢?OK,这个问题我们通过 modinfo命令就可以来解决! #modinfo ext3 filename: /lib/modules/2.6.9-1.667smp/kernel/fs/ext3/ext3.ko author: Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others description: Second Extended Filesystem with journaling extensions license: GPL vermagic: 2.6.9-1.667smp SMP 686 REGPARM 4KSTACKS gcc-3.4 depends: jbd 这样我们就知道了ext3这个内核模块的信息,包括对应的实际名称,作者和其他 的一些信息。 既然我们知道了模块的信息,你一定会问:那我怎么往内核里插入我自己的模块 呢?It is very easy!! 在linux下插入模块,有2种方法,你可以通过insmod或者 modprobe来解决; insmod 命令后面必须跟模块文件名的路径,譬如: #insmod /lib/modules/2.6.9-1.667smp/kernel/fs/ext3/ext3.ko 不过一般推荐使用modprobe。在模块之间,可能存在着一些依赖关系,譬如从 上面modinfo ext3的输入我们得知:ext3模块依赖于jbd模块·。如果你往内核 里插入jbd模块,而直接通过insmod来插入ext3模块,那么是无法执行成功的。 而modprobe则不需要自己来处理这些依赖关系。下面来看个例子: #modinfo vfat filename: /lib/modules/2.6.9-1.667smp/kernel/fs/vfat/vfat.ko license: GPL description: VFAT filesystem support author: Gordon Chaffee vermagic: 2.6.9-1.667smp SMP 686 REGPARM 4KSTACKS gcc-3.4 depends: fat vfat 模块依赖于fat模块! 然后我们删除系统里的 fat模块和vfat模块(后面会讲解) #rmmod vfat #rmmod fat #lsmod | grep fat 来确认目前系统里已经没有fat和vfat模块! 我们尝试着用insmod来插入vfat模块 # insmod /lib/modules/2.6.9-1.667smp/kernel/fs/vfat/vfat.ko insmod: error inserting '/lib/modules/2.6.9-1.667smp/kernel/fs/vfat/vfat.ko': -1 Unknown symbol in module 看到insmod无法插入vfat内核模块; #modprobe -v vfat insmod /lib/modules/2.6.9-1.667smp/kernel/fs/fat/fat.ko insmod /lib/modules/2.6.9-1.667smp/kernel/fs/vfat/vfat.ko 我们通过modproble就可以看到,插入vfat模块时,先插入vfat模块依赖的 fat模块,然后再插入vfat模快! 看到这里,你当然会问:modprobe怎么知道各个模块的依赖关系呢? 呵呵,奥秘在modules.conf文件里! 从 man modules.conf里摘一段, 大家看完之后就明白了: The modules.dep as generated by module-init-tools depmod, lists the dependencies for every module in the directories under /lib/modules/version, where modules.dep is. For example, if /lib/modules/2.5.53/kernel/a.ko depended on b.ko and c.ko in the same directory, and c.ko depended on b.ko as well, the file might look like: # This is a comment. /lib/modules/2.5.53/kernel/a.ko: /lib/modules/2.5.53/kernel/c.ko /lib/modules/2.5.53/kernel/b.ko /lib/modules/2.5.53/kernel/b.ko: /lib/modules/2.5.53/kernel/c.ko: /lib/modules/2.5.53/kernel/b.ko This file is used by modprobe to know the order to load modules (they are loaded right to left, and removed left to right). 在Load的时候,从右向左插入每个模块,卸载的时候从左向右下载每个模块! 而modules.conf文件是由/sbin/depmod 命令来产生的。 我们一直在讲如何插入模块,那么该如何卸载模块呢?总不能只能插入,不能 卸载吧?不会的~Linux下提供了rmmod命令来帮助我们卸载不需要的内核模块。 #rmmod modname 不过,如果模块的使用计数不是0,那么rmmod会提示出错! #lsmod | grep fat vfat 16961 0 fat 44897 1 vfat 当前fat 模块的使用计数1! 如果我们使用rmmod来删除fat, #rmmod fat ERROR: Module fat is in use by vfat 系统提示:fat模块由vfat模块在使用,我们必须先删除vfat模块,然后再删除 fat模块! #rmmod vfat #rmmod fat #lsmod | grep fat Over了!如果有兴趣的,可以学习一下内核模块的编程~ June 09 lupa开源资讯
|
|
|