insmod: error inserting 'hello.ko': -1 Invalid module format

使用命令ismod helloworld.ko 加载编译成功的模块helloworld.ko时出现错误  insmod: error inserting 'helloworld.ko': -1 Invalid module format

一般出错信息被记录在文件/var/log/messages中
# cat /var/log/messages |tail 

通过命令看一下模块的相关信息

[root@hailiang tmp]# modinfo helloworld.ko
filename:       helloworld.ko
alias:          a simplest module
description:    A simple helloworld module
author:         zhanghailiang
depends:       
vermagic:       2.6.27.5-117.fc10.i686 SMP mod_unload modversions 686 4KSTACKS  

 内核无法加载模块的原因是因为记载版本号的字符串和当前正在运行的内核模块的不一样,这个版本印戳作为一个静态的字符串存在于内核模块中

就是当前运行的内核与模块的内核不一致,将makefile的路径修改成当前模块的build即可

modprobe会自动在/lib/modules/'uname -r'下寻找模块加载,将helloworld.ko拷到/lib/modules 下然后再执命令 modprobe helloworld 发现还是找不到,从man modprobe

  modprobe  expects  an  up-to-date  modules.dep  file, as generated by depmod (see depmod(8))

看出还需要依赖命令:depmod生成的module.dep 使用这个命令后 在modprobe helloworld 成功

findcode sell program.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值