linux模块创建proc,[Linux 运维]/proc/modules 以及内核模块工具

[Linux 运维] /proc/modules 以及内核模块工具

1. 基本情况

这个文件列出了所有load进入内核的模块列表。里面的内容会随着系统使用和配置的变化而变化。这里面的很多信息可以通过lsmod 命令获取

# cat /proc/modules

ipv6 334932 54 - Live 0xffffffffa00dd000

xenfs 5705 1 - Live 0xffffffffa00d8000

dm_mod 95622 0 - Live 0xffffffffa00b5000

xen_netfront 18994 0 - Live 0xffffffffa00a4000

i2c_piix4 11776 0 - Live 0xffffffffa009e000

i2c_core 29964 1 i2c_piix4, Live 0xffffffffa0090000

ext3 240580 1 - Live 0xffffffffa003f000

jbd 80950 1 ext3, Live 0xffffffffa0022000

mbcache 8193 1 ext3, Live 0xffffffffa001b000

xen_blkfront 15329 2 - Live 0xffffffffa0013000

pata_acpi 3701 0 - Live 0xffffffffa000f000

ata_generic 3837 0 - Live 0xffffffffa000b000

ata_piix 24409 0 - Live 0xffffffffa0000000

第一列: 模块的名字

第二列: 模块的内存大小,单位是bytes

第三列: 被load的次数,0以为着没有被load过

第四列: 是否依赖第三方moudle,列出这些module

第五列: 模块的状态,有Live, Loading, Unloading三种状态

第六列: 模块当前的内核内存偏移位置。这些信息,debug的时候会非常有用。例如一些诊断工具 oprofile。

2. 相关工具

(1) lsmod

lsmod的输出,是基于/proc/modules

Module Size Used by

ipv6 334932 54

xenfs 5705 1

dm_mod 95622 0

xen_netfront 18994 0

i2c_piix4 11776 0

i2c_core 29964 1 i2c_piix4

ext3 240580 1

jbd 80950 1 ext3

mbcache 8193 1 ext3

xen_blkfront 15329 2

pata_acpi 3701 0

ata_generic 3837 0

ata_piix 24409 0

(2)insmod

向内核中插入一个模块

(3)rmmod

删除内核中的一个模块

(4)modprobe

增加和删除内核中的模块(modprobe - program to add and remove modules from the Linux Kernel),现在比较多的用这个。

(5)modinfo

看内核模块的信息:

# modinfo xen_netfront

filename: /lib/modules/2.6.32-504.el6.x86_64/kernel/drivers/net/xen-netfront.ko

alias: xennet

alias: xen:vif

license: GPL

description: Xen virtual network device frontend

srcversion: 5C6FC78BC365D9AF8135201

depends:

vermagic: 2.6.32-504.el6.x86_64 SMP mod_unload modversions

(6)depmod

分析可加载模块的依赖性,生成modules.dep文件和映射文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值