Linux remove kernel module

Как удалить полностью модуль ядра?

Перерыл гугл, ответа не нашел. Описание удаление модуля в документациях и howto это как оказывается совсем не удаление, а отключение/выключение его в ядре. Мне же, необходимо удалить его полностью из системы.

Есть модуль vmnet, который скомпилировал и установил его VMWare. Хочу вычистить этот модуль из системы вручную. Что делаю:

  • Модуль выгрузился, дполнительно проверяю, что в выводе его нет:

Если попытаться удалить файл /lib/modules/4.20.11-1-MANJARO/misc/vmnet.ko, то при следующем запросе modinfo выдаст ошибку:

Подозреваю, что есть какая-то база данных, репозиторий где устанавливаются (прописываются) модули. Как корректно удалить модуль?

Попробуй выполнить depmod .

есть какая-то база данных, репозиторий где устанавливаются (прописываются) модули

Она в файлах /lib/modules/$(uname -r)/modules* . Руками менять их не надо.

P.S. После удаления файла /lib/modules/4.20.11-1-MANJARO/misc/vmnet.ko Запустил команду sudo depmod которая видимо перестроила/атуализировала БД модулей в файлах /lib/modules/4.20.11-1-MANJARO/modules.

Vmware разве не использует механизм dkms?

Вероятно использует, но на Manjaro Linux родной VMWare installer/uninstaller не заработал, вываливался в ошибку. Связано было с отсутствующей библиотекой libncursesw.so.5 в дистрибутиве. Вместо того, чтобы разбираться с Python’ом, решил вместо vmware-installer самостоятельно подчищать за ним и упаковал всё в пакет с помощью арчевого PKGBUILD.

Но позже, обнаружил, что достаточно создать симлинки для библиотек

и vmware-installer не выдает ошибок и корректно работает, за собою подчищает установленные модули ядра.

Вместо этого кода:

сейчас вызываю просто деинсталлятор, который делает тоже самое (и не только), что и выше код:

Источник

How to: Linux delete or remove kernel

If the Linux kernel is installed using a binary package system such as rpm, yum, up2date, apt-get, etc., you can remove it with the following commands.

WARNING! Make sure you only remove or delete the unwanted Linux kernel. Removing the currently running Linux kernel will create a non-bootable system. Check Linux Kernel Version by tying the following command:
uname -r

Rpm based distro – Red Hat/CentOS/Fedora Core/Suse Linux

First, find out all installed kernel version with the following commands:
# rpm -qa | grep kernel-smp
# rpm -qa | grep kernel
# Use grep command/egrep command to filter out results #
# rpm -qa | grep kernel-5
Here is what I see before I delete or remove the installed Linux kernel on my system:

I have a total of three different kernels installed. To remove kernel-smp-2.6.9-42.EL type the rpm command:
# rpm -e kernel-smp-2.6.9-42.EL
OR
# rpm -vv -e kernel-smp-2.6.9-42.EL

Deleting or removing RHEL 8 Linux kernel

These days we use the yum command/dnf command to list installed kernels and delele them directly:
sudo dnf list —installed kernel
# get the current kernel version #
uname -r
# note down disk space using the df command #
df -H /
df -H
Now let us delete the Linux kernel version 4.18.0-240.10.1.el8_3:
sudo dnf remove kernel-4.18.0-240.10.1.el8_3.x86_64

Deleting Linux kernel using the dnf on RHEL 8 cloud VM

.deb based distro – Debian or Ubuntu Linux

Again find out all installed kernel version on your Debian or Ubuntu Linux system, run the dpkg command:
$ dpkg —list | grep kernel-image
# latest version of Debian/Ubuntu uses linux-image pkg #
$ dpkg —list | grep linux-image
Outputs from my Debian system:

  • 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
Читайте также:  Как ускорить работу ssd mac os

Join Patreon

Now remove kernel-image-2.4.27-2-386 with the help of the apt-get command or apt command itself:
# apt-get remove kernel-image-2.4.27-2-386
OR
$ sudo apt-get remove kernel-image-2.4.27-2-386
Apart from the kernel-image or linux-image , you need to remove and delete headers and module packages too. For instance, here are packages releated to Linux kernel 5.4.0-25 on my Ubuntu Linux 20.04 LTS desktop:
$ dpkg —list | grep 5.4.0-25
List:

In other words, eliminate all those four packages:
$ sudo apt —purge remove linux-headers-5.4.0-25 \
linux-headers-5.4.0-25-generic \
linux-image-5.4.0-25-generic \
linux-modules-5.4.0-25-generic
See the following pages for more info:

A note about custom compiled Linux kernel

If you have a custom compiled Linux kernel running, you need to remove the following files/dirs:

  • /boot/vmlinuz*KERNEL-VERSION*
  • /boot/initrd*KERNEL-VERSION*
  • /boot/System-map*KERNEL-VERSION*
  • /boot/config-*KERNEL-VERSION*
  • /lib/modules/*KERNEL-VERSION*/
  • Update grub configuration file /etc/grub.conf or /boot/grub/menu.lst to point to correct kernel version.

Summing up

Removing the working Linux kernel may result in an unstable/non- bootable Linux server system. Hence, care must be taken while removing the older Linux kernel. Apart from disk space-saving, you can get rid of the vulnerable Linux kernel from the system to improve the system’s stability and security.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Источник

Howto: Linux Add or Remove a Linux Kernel Modules / Drivers

=> Under MS-Windows you use term device driver for modules.

=> Under Linux you use term modules for device drivers.

Tutorial details
Difficulty level Advanced
Root privileges Yes
Requirements modprobe/lsmod/modinfo utilities
Est. reading time N/A

=> The Linux kernel has a modular design.

=> At boot time, only a minimal resident kernel is loaded into memory.

=> If you add new hardware you need to add driver i.e. 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

=> The modprobe command intelligently adds or removes a module from the Linux kernel

=> Usually, all Linux kernel modules (drivers) are stored in the module directory located that /lib/modules/$(uname -r) directory. To see current modules, type:
$ ls /lib/modules/$(uname -r)
Output:

Use the following command to list all drivers for various devices:
$ ls /lib/modules/$(uname -r)/kernel/drivers/
Sample outputs:

Fig.01: Device drivers on my Linux based system

Task: Add a Module (driver) Called foo

Type the following command as root user:
# modprobe foo
In this example, I am loading a module called i8k, enter:
# modprobe -v i8k
Sample outputs:

Find out info about loaded module

You need to use the modinfo command to see information about a Linux Kernel module. The syntax is:
# modinfo -v
# modinfo i8k
Sample outputs:

Fig.02: Displaying information about a Linux Kernel module called i8k

Task: List all loaded modules

Use the lsmod command to show the status of modules in the Linux Kernel:
# lsmod
Sample outputs:

Task: Remove a module called foo

Pass the -r option to modprobe command to remove a module, type:
# modprobe -r foo
You can also use the rmmod command, which is simple program to remove a module from the Linux Kernel:
# rmmod foo

Recommended readings
  • man pages – modinfo, lsmod, insmod, and modprobe

🐧 Get the latest tutorials on Linux, Open Source & DevOps via

Category List of Unix and Linux commands
Documentation help • mandb • man • pinfo
Disk space analyzers df • duf • ncdu • pydf
File Management cat • cp • less • mkdir • more • tree
Firewall Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04
Linux Desktop Apps Skype • Spotify • VLC 3
Modern utilities bat • exa
Network Utilities NetHogs • dig • host • ip • nmap
OpenVPN CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04
Package Manager apk • apt
Processes Management bg • chroot • cron • disown • fg • glances • gtop • jobs • killall • kill • pidof • pstree • pwdx • time • vtop
Searching ag • grep • whereis • which
Shell builtins compgen • echo • printf
Text processing cut • rev
User Information groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w
WireGuard VPN Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04

Comments on this entry are closed.

when the system is rebooted the module inside the kernel will not be present.But i want the modules to be seen permenently.what should i do.

Thanks alot for this, very helpful for teh newbz.

Thank’s first for the helpfull command , where can i get the new modules other then my OS,

how to build linux kernel module with new device driver module during build

Thanks a lot for the info…:) 🙂

Hi there…
I am trying to remove TCP IP from a linux kernel, and want to recompile the LINUX kernel. But being a novice with the administrations of the linux (UBUNTU 10.4), I know a little about it. Agter recompilation can I again design mu own TCPIP using the C language code?
Guys please help me out…waiting for the reply .
Regards…

Thanks for this very short but very clear information. That helps me to understand the concept (of add or remove module on Linux) very much.

One question remain: how do we check to know what modules are available to add on a existing system?

Thank you in advance!

One question remain: how do we check to know what modules are available to add on a existing system?

cd to /lib/modules/$(uname -r) directory and you can see the list of available modules (run as root):

The following will list all drives

To find out more info about a module called foo:

Hope this helps!

Hi
thanks for your comments, I am trying to write a printer driver for linux, what should I do?

Please help me on this task.

Does anyone knows step by step guide for how to install ip_conntrack support into kernel Linux linux 2.6.35.14-106.fc14.i686 #1 SMP Wed Nov 23 13:57:33 UTC 2011 i686 i686 i386 GNU/Linux

I am unable to remove the following modules after issuing the commands.
$ rmmod usbhid and
$rmmod hid..

After issuing the commands the modules are not shown in “lsmod” but as soon as a device is added they again get loaded.

thanks, very clear article.

Hello there. I have an old computer Celeron, 128MB RAM and 28MB of VGA. What I want to do is keep the drivers that are needed for my system. Like if I use the Realtek Chipset for Network Card why should the Atheros driver be present on the system? Is there any way to accomplish this task?
Regards.

I have a serious problem, my Linux does not have these comands:
apt-get
uname
modprobe
mknod
man
…etc… and also has not a lot of typical commands

And there is no /dev/loop*

And mount -o loop blablabla bleble say incorrect option, does not undertand loop.

Of course, all problem seem that Kernel has no loop device support.

How can i fix it?

Please have in mind Kernel is on ROM (a chip not writteable), it is not a flasheable chip, i can not modify it on any way, … read only memory chip!!

I wish if it could be possible to add loop device support at run time as a module…

But it does not have modprobe command… neither a lot of clasic Linux commands… so i got to fail.

Need some help, i am not an expert.

Step 1: try to create /dev/loop0 (it does not exists) with mknod but mknod command not found

Try to add such coomands with apt-get, wget, etc… all says such commands not exists

I am getting mad…

Please note it is an ARM processor based, and Kernel is on a ReadOnly chip not flashable.

Thanks in advance for any help… i am getting really mad…

If I were you, rather than finding Linux Kernel modulos to have “uname”, “modprobe”, “man” recovered (maybe you have played around some kernel rebuild and screwed up some basic binaries?), I will re-install the entire Linux OS from scratch. You can download CentOS (Red Hat) or SUSE, Fedora or whatever Linux to have all these basic utilities included.

trying to add slcan module to kernel 2.6.32-504.30.3.el6.i686 but having problems with the following response … question is how to get it added

FATAL: Module slcan not found.

Thank you so much…

i want to know how many mouldes in linus and brief explanation of them.i will glad if my question is been answered.

hi all,
iam unable to remove nvme module in primary drive(ssd) by using
following comment:
rmmod nvme

Источник

Читайте также:  Вне диапазона как исправить при запуске компьютера windows
Оцените статью