- Как загружать и выгружать модули ядра в Linux
- Список всех загруженных модулей ядра в Linux
- Как загрузить или выгрузить (удалить) модули ядра в Linux
- Управление модулями ядра с помощью команды modprobe
- modprobe, lsmod, modinfo Command Tutorial With Examples To Load, List Linux Kernel Modules
- List Available Kernel Modules
- List Loaded Modules
- Get Information About Kernel Module
- Load or Install New Kernel Modules
- Remove or Unload Loaded Kernel Module
- Linux: Find out what kernel drivers (modules) are loaded
- lsmod command
- Get more information about the driver
- How to Load and Unload Kernel Modules in Linux
- List All Loaded Kernel Modules in Linux
- How to Load and Unload (Remove) Kernel Modules in Linux
- How to Manage Kernel Modules Using modprobe Command
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- Howto: Display List of Modules or Device Drivers In the Linux Kernel
- Task: List or display loaded modules
- Finding more info about any module or driver
Как загружать и выгружать модули ядра в Linux
Оригинал: How to Load and Unload Kernel Modules in Linux
Автор: Aaron Kili
Дата публикации: 13 июня 2017 года
Перевод: А. Кривошей
Дата перевода: июль 2017 г.
Модуль ядра — это программа, которая может быть загружена в ядро операционной системы, или выгружена из него по запросу без перекомпиляции ядра или перезагрузки системы. Модули предназначены для расширения функциональности ядра. Другими словами можно сказать, что модули похожи на плагины к программам, например к WordPress. Плагины расширяют функциональность программы без включения их в исходный код.
Аналогично, без модулей ядро должно быть собрано с включением всей необходимой функциональности непосредственно в образ ядра. Это приводит к увеличению его размеров, кроме того, для добавления любой новой функциональности системным администраторам необходимо перекомпилировать ядро.
Простой пример модуля — драйвер, который предоставляет ядру доступ к аппаратному устройству, подключенному к компьютеру.
Список всех загруженных модулей ядра в Linux
В Linux названия всех модулей заканчиваются расширением .ko, и обычно они загружаются автоматически при обнаружении оборудования во время загрузки системы. Однако системный администратор может управлять модулями с помощью специальных команд.
Для вывода списка всех загруженных модулей в Linux может использоваться команда lsmod (list modules), которая читает содержимое /proc/modules.
Как загрузить или выгрузить (удалить) модули ядра в Linux
Для загрузки модуля ядра мы можем использовать команду insmod (insert module). Здесь необходимо задать полный путь к модулю. Приведенная ниже команда загружает модуль speedstep-lib.ko.
Для выгрузки модуля ядра мы будем использовать команду rmmod (remove module). Следующая команда выгрузит модуль speedstep-lib.ko.
Управление модулями ядра с помощью команды modprobe
modprobe — это интеллектуальная команда для чтения списка, загрузки и выгрузки модулей ядра. Она производит поиск всех модулей и соответствующих файлов в директории /lib/modules/$(uname -r), но не включает в поиск альтернативные конфигурационные файлы в директории /etc/modprobe.d. Таким образом, здесь вам не нужно вводить полный путь к модулю — в этом преимущество modprobe по сравнению с ранее описанными командами.
Для загрузки модуля просто введите его имя.
Для выгрузки модуля используется флаг -r.
Замечание: в modprobe выполняется автоматическое преобразование подчеркивания, поэтому при вводе названий модулей нет никакой разницы между _ и -.
Более подробно ознакомиться с опциями можно на man-странице modprobe.
Источник
modprobe, lsmod, modinfo Command Tutorial With Examples To Load, List Linux Kernel Modules
What makes an Operating system Linux Distribution? All Linux distributions use same kernel named Linux Kernel. Linux kernel provides operating system services, hardware management, process management, memory management etc.
Linux kernel is a monolithic kernel which means single executable all in one. But the operating systems should provide dynamic environments to comply user needs. Linux provides mechanism to load some drivers, features etc. This is called kernel modules. In this tutorial we will look kernel modules operations with modprobe command. Most of the examples in this tutorial requires root privileges.
List Available Kernel Modules
Linux kernel came with a lot of default kernel modules. These modules are loaded according to requirements and kernel config provided by the distribution. There is also an option to add new kernel modules externally to the Linux. We can list all of these modules with lsmod command
List Available Kernel Modules
List Available Kernel Modules
List Loaded Modules
As we know kernel modules are loaded or unloaded. We can list only installed kernel modules by using previous command. but in this command we need some external help. We will use egrep to filter installed kernel modules.
List Loaded Modules
Get Information About Kernel Module
Kernel modules can get different parameter for configuration purposes. Also there are different type of information. Here are some of them which can be listed with modinfo command.
- filename what is modules file name and the path
- license modules license type like GPL,GPL2,Apache,TM
- description short description about the kernel module
- depends specify what other kernel modules are needed to load this module
- intree specify if this kernel module is maintained in kernel git repository
- vermagic specifies the version of the kernel module
- parm specifies parameter that can be used to configure this kernel module.
Get Information About Kernel Module
Load or Install New Kernel Modules
Generally Linux operating system automatically loads related kernel modules. There is no need to load them manually in most situations. But some times manual operation may be needed to load kernel modules. We will install module named ipx by using insmod in this example.
Remove or Unload Loaded Kernel Module
We can remove kernel modules. We will use modprobe command again with -r option by providing the kernel module name. In this example we unload ipx kernel module
Источник
Linux: Find out what kernel drivers (modules) are loaded
lsmod command
You need to use lsmod command to show the status of modules in the Linux Kernel. Simply type the lsmod at a shell prompt to list all loaded modules:
$ lsmod
Sample outputs:
Get more information about the driver
To get more information about specific driver use modinfo command. The syntax is:
modinfo < driver-name >
To see information about a Linux Kernel module called e1000, enter:
$ modinfo e1000
Sample outputs:
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
See modinfo and lsmod man pages for more info.
🐧 Get the latest tutorials on Linux, Open Source & DevOps via
Источник
How to Load and Unload Kernel Modules in Linux
A kernel module is a program which can loaded into or unloaded from the kernel upon demand, without necessarily recompiling it (the kernel) or rebooting the system, and is intended to enhance the functionality of the kernel.
In general software terms, modules are more or less like plugins to a software such as WordPress. Plugins provide means to extend software functionality, without them, developers would have to build a single massive software with all functionalities integrated in a package. If new functionalities are needed, they would have to be added in new versions of a software.
Likewise without modules, the kernel would have to be built with all functionalities integrated directly into the kernel image. This would mean having bigger kernels, and system administrators would need to recompile the kernel every time a new functionality is needed.
A simple example of a module is a device driver – which enables the kernel to access a hardware component/device connected to the system.
List All Loaded Kernel Modules in Linux
In Linux, all modules end with the .ko extension, and they are normally loaded automatically as the hardware is detected at system boot. However a system administrator can manage the modules using certain commands.
To list all currently loaded modules in Linux, we can use the lsmod (list modules) command which reads the contents of /proc/modules like this.
How to Load and Unload (Remove) Kernel Modules in Linux
To load a kernel module, we can use the insmod (insert module) command. Here, we have to specify the full path of the module. The command below will insert the speedstep-lib.ko module.
To unload a kernel module, we use the rmmod (remove module) command. The following example will unload or remove the speedstep-lib.ko module.
How to Manage Kernel Modules Using modprobe Command
modprobe is an intelligent command for listing, inserting as well as removing modules from the kernel. It searches in the module directory /lib/modules/$(uname -r) for all the modules and related files, but excludes alternative configuration files in the /etc/modprobe.d directory.
Here, you don’t need the absolute path of a module; this is the advantage of using modprobe over the previous commands.
To insert a module, simply provide its name as follows.
To remove a module, use the -r flag like this.
Note: Under modprobe, automatic underscore conversion is performed, so there is no difference between _ and – while entering module names.
For more usage info and options, read through the modprobe man page.
Do not forget to check out:
That’s all for now! Do you have any useful ideas, that you wanted us to add to this guide or queries, use the feedback form below to drop them to us.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
Howto: Display List of Modules or Device Drivers In the Linux Kernel
H ow do I display the list of loaded Linux Kernel modules or device drivers on Linux operating systems?
You need to use lsmod program which show the status of loaded modules in the Linux Kernel. Linux kernel use a term modules for all hardware device drivers.
Tutorial details | |
---|---|
Difficulty level | Easy |
Root privileges | Yes |
Requirements | lsmod |
Est. reading time | Less than a one minute |
Please note hat lsmod is a trivial program which nicely formats the contents of the /proc/modules , showing what kernel modules are currently loaded.
This is an important task. With lsmod you can verify that device driver is loaded for particular hardware. Any hardware device will only work if device driver is loaded.
Task: List or display loaded modules
Open a terminal or login over the ssh session and type the following command
$ less /proc/modules
Sample outputs:
To see nicely formatted output, type:
$ lsmod
Sample outputs:
First column is Module name and second column is the size of the modules i..e the output format is module name, size, use count, list of referring modules.
- No ads and tracking
- In-depth guides for developers and sysadmins at Opensourceflare✨
- Join my Patreon to support independent content creators and start reading latest guides:
- How to set up Redis sentinel cluster on Ubuntu or Debian Linux
- How To Set Up SSH Keys With YubiKey as two-factor authentication (U2F/FIDO2)
- How to set up Mariadb Galera cluster on Ubuntu or Debian Linux
- A podman tutorial for beginners – part I (run Linux containers without Docker and in daemonless mode)
- How to protect Linux against rogue USB devices using USBGuard
Join Patreon ➔
Finding more info about any module or driver
Type the following command:
# modinfo driver-Name-Here
# modinfo thermal_sys
# modinfo e1000e
Sample outputs:
Источник