

如何加载linux kernel module
source link: https://www.lujun9972.win/blog/2018/06/04/%E5%A6%82%E4%BD%95%E5%8A%A0%E8%BD%BDlinux-kernel-module/index.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

如何加载linux kernel module
kernel module存放在哪里
linux自带了很多kernel module文件, 这些文件一般以 .ko
或 .ko.xz
文件结尾,存放在 /lib/module/$(uname -r)
目录中。
ls -l /lib/modules/$(uname -r)
总用量 5844 drwxr-xr-x 3 root root 4096 6月 1 12:04 build lrwxrwxrwx 1 root root 25 5月 26 08:26 extramodules -> ../extramodules-4.16-ARCH drwxr-xr-x 12 root root 4096 6月 1 12:04 kernel -rw-r--r-- 1 root root 1373746 6月 1 12:05 modules.alias -rw-r--r-- 1 root root 1351352 6月 1 12:05 modules.alias.bin -rw-r--r-- 1 root root 4820 5月 26 08:24 modules.builtin -rw-r--r-- 1 root root 6584 6月 1 12:05 modules.builtin.bin -rw-r--r-- 1 root root 708369 6月 1 12:05 modules.dep -rw-r--r-- 1 root root 939730 6月 1 12:05 modules.dep.bin -rw-r--r-- 1 root root 433 6月 1 12:05 modules.devname -rw-r--r-- 1 root root 210735 5月 26 08:24 modules.order -rw-r--r-- 1 root root 598 6月 1 12:05 modules.softdep -rw-r--r-- 1 root root 610067 6月 1 12:05 modules.symbols -rw-r--r-- 1 root root 746894 6月 1 12:05 modules.symbols.bin
大部分的module file都按类别分好类存放在其中的 kernel
目录中。
ls -l /lib/modules/$(uname -r)/kernel
总用量 40 drwxr-xr-x 3 root root 4096 6月 1 12:04 arch drwxr-xr-x 3 root root 4096 6月 1 12:04 crypto drwxr-xr-x 102 root root 4096 6月 1 12:04 drivers drwxr-xr-x 48 root root 4096 6月 1 12:04 fs drwxr-xr-x 6 root root 4096 6月 1 12:04 lib drwxr-xr-x 2 root root 4096 6月 1 12:04 mm drwxr-xr-x 52 root root 4096 6月 1 12:04 net drwxr-xr-x 3 root root 4096 6月 1 12:04 security drwxr-xr-x 14 root root 4096 6月 1 12:04 sound drwxr-xr-x 3 root root 4096 6月 1 12:04 virt
linux当然不可能将所有的module都加载进kernel,要查看目前加载了哪些module,可以执行 lsmod
命令:
lsmod |head
Module Size Used by rfcomm 86016 4 nls_iso8859_1 16384 0 nls_cp437 20480 0 vfat 24576 0 fat 81920 1 vfat uas 28672 0 usb_storage 69632 1 uas fuse 118784 3 ipt_MASQUERADE 16384 1
如何加载module
加载module特别简单,只需要使用 modprobe module名
就行了。
其中 module名
中无需带 .ko
或 .ko.xz
的后缀名,也无需指定文件路径。
sudo modprobe vboxvideo
卸载module
卸载module也很简单,只需要使用 rmmod module名
就行了。
其中 module名
中也无需带 .ko
或 .ko.xz
的后缀名,也无需指定文件路径。
sudo rmmod vboxvideo
Recommend
-
37
If you’ve ever compiled a module for the Linux Kernel you’ve probably seen (or assumed there’s) quite a lot of voodoo going on between the stages of running make and insmod . As a quic...
-
22
Earlier this year, we used the C2Rust framework to translate applications such asQuake 3 to Rust. In this post, we’ll show you that it is also possible to translate privileged software such as modules that are loaded by t...
-
7
Kernel The Kernel module is included by class Object, so its methods are available in every Ruby ob...
-
20
Remotely reinstalling a node on CentOS 8 with DuD (Driver Disk Update /...
-
6
Day 5: I wrote a kernel module!!! I WROTE A KERNEL MODULE. It doesn’t do anything useful or anything, but still! This is a pretty quick post because there was an awesome talk today by
-
34
The Linux Kernel Module Programming Guide...
-
12
The Linux Kernel Module Programming Guide This project keeps the Linux Kernel Module Programming Guide reasonably up to date, with working examples for recent 5.x...
-
65
RedPill LKM THIS IS WORK IN PROGRESS There's nothing to run/see here (yet ;)). What is this? This is a...
-
5
Go 1.17新特性详解:module依赖图修剪与延迟module加载 八月 19, 2021 0 条评论
-
9
antipatterns.ko: the world's worst kernel module caution:DO NOT LOAD THIS MODULE This kernel module contains numerous security vulnerabilities. It is intended purely as a testbed for vulnerability detection tools. The i...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK