insmod: ERROR: could not insert module HelloWorld.ko: Operation not permitted
insmod: ERROR: could not insert module HelloWorld.ko: Operation not permitted
我正在努力学习linux和内核开发。
我可以构建模块,但无法加载它。
HelloWorld.c
/*
* hello-1.c - The simplest kernel module.
*/
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}
这是我的 make 文件:
KERNEL_SOURCE := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
obj-m += HelloWorld.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
在执行 insmod 加载模块权限时被拒绝。我什至尝试用 root 和 modprobe 来做,但没有用。
我也试过Link但是问题还是一样
希望能得到一些帮助。我正在使用 ubuntu 18.04LTS。
首先,确保 makefile
中有制表符:并且干净:没有 space
然后保存它并 运行 命令 make
之后,通过以下命令插入内核。
$ sudo insmod file_name.ko
最后,展示。
$ dmesg | tail -1
所以我遇到了同样的问题,这对我有用:
您需要使用 mokutil 禁用安全启动 use the first answer in this link
运行 通过 sudo 的 insmod 命令。
祝你好运。
如果 $ sudo insmod file_name.ko
因上述错误而失败,则执行 dmesg | tail -1
它会告诉你安装时到底出了什么问题 kernel-module。
在我的例子中,这是因为另一个模块重叠在相同的 /sys/class 位置。
完成 sudo rmmod <that_module.ko>
后,我能够加载我的新内核模块。
我正在努力学习linux和内核开发。
我可以构建模块,但无法加载它。
HelloWorld.c
/*
* hello-1.c - The simplest kernel module.
*/
#include <linux/module.h> /* Needed by all modules */
#include <linux/kernel.h> /* Needed for KERN_INFO */
int init_module(void)
{
printk(KERN_INFO "Hello world 1.\n");
/*
* A non 0 return means init_module failed; module can't be loaded.
*/
return 0;
}
void cleanup_module(void)
{
printk(KERN_INFO "Goodbye world 1.\n");
}
这是我的 make 文件:
KERNEL_SOURCE := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)
obj-m += HelloWorld.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
在执行 insmod 加载模块权限时被拒绝。我什至尝试用 root 和 modprobe 来做,但没有用。
我也试过Link但是问题还是一样
希望能得到一些帮助。我正在使用 ubuntu 18.04LTS。
首先,确保 makefile
中有制表符:并且干净:没有 space
然后保存它并 运行 命令 make
之后,通过以下命令插入内核。
$ sudo insmod file_name.ko
最后,展示。
$ dmesg | tail -1
所以我遇到了同样的问题,这对我有用:
您需要使用 mokutil 禁用安全启动 use the first answer in this link
运行 通过 sudo 的 insmod 命令。
祝你好运。
如果 $ sudo insmod file_name.ko
因上述错误而失败,则执行 dmesg | tail -1
它会告诉你安装时到底出了什么问题 kernel-module。
在我的例子中,这是因为另一个模块重叠在相同的 /sys/class 位置。
完成 sudo rmmod <that_module.ko>
后,我能够加载我的新内核模块。