knowledge_map/linux/linux 自动加载ko驱动.md
2024-11-16 14:33:59 +08:00

30 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

要在Ubuntu 20上实现开机自动加载内核模块.ko驱动可以按照以下步骤进行操作
1. 确保你已经编译好了你的内核模块,并且拥有一个.ko文件。
2. 打开终端,使用以下命令将.ko文件复制到/lib/modules/<kernel_version>/目录下,其中<kernel_version>是你当前正在使用的内核版本号:
```
sudo cp your_module.ko /lib/modules/$(uname -r)/
```
3. 运行以下命令将你的模块的信息添加到modules.dep文件中
```
sudo depmod
```
4. 创建一个新的文件,以在系统启动时加载模块。在终端中运行以下命令:
```
sudo nano /etc/modules-load.d/<your_module>.conf
```
这里的<your_module>是你想要加载的模块的名称。
5. 在打开的文件中,输入你的模块的名称,保存并关闭文件。
6. 重启你的系统。你的模块应该会在启动时自动加载。
这样,你的.ko驱动模块应该会在Ubuntu 20的启动时自动加载。请确保你的模块编译正确并且与你的内核版本兼容。如果你的模块依赖其他模块你也需要确保这些模块已正确加载。