Linux Kernel: Difference between revisions

From wikinotes
No edit summary
Line 45: Line 45:
|}
|}


== managing kernel modules ==
== Managing Kernel Modules ==
<blockquote>
<source lang="bash">
<source lang="bash">
lsmod                                          # list loaded kernel modules
lsmod                                          # list loaded kernel modules
Line 52: Line 53:
cat /lib/modules/$(uname -r)/modules.builtin  # list builtin kernel modules
cat /lib/modules/$(uname -r)/modules.builtin  # list builtin kernel modules
</source>
</source>
</blockquote><!-- Managing Kernel Modules -->


== automatically loading kernel modules ==
== automatically loading kernel modules ==
<blockquote>
Similar to other systemd files, you can gather a bunch of kernel modules in a single file.
Similar to other systemd files, you can gather a bunch of kernel modules in a single file.
The syntax of the file is a newline separated list of modules. Their names will be exactly
The syntax of the file is a newline separated list of modules. Their names will be exactly
Line 64: Line 67:
btusb
btusb
</source>
</source>
</blockquote><!-- automatically loading kernel modules -->
</blockquote><!-- Kernel Modules -->


== list kernel modules ==
= Dynamic Kernel Modules (DKMS) =
<source lang="bash">
<blockquote>
lsmod  # list loaded kernel modules
DKMS packages include kernel modules that are recompiled every time a new kernel is installed.<br>
</source>
You can safely install/build these modules after an update without reboot, but you'll need to restart to use them (so the new kernel is used).
 
== kernel module load order ==


</blockquote><!-- Kernel Modules -->
</blockquote><!-- Dynamic Kernel Modules (DKMS) -->


= Kernel Downgrades =
= Kernel Downgrades =
<blockquote>
<blockquote>
Boot your distro off a USB stick, and chroot into your existing installation.  
Boot your distro off a USB stick, and chroot into your existing installation.
You'll need to uninstall all packages that are particular to your kernel version  
You'll need to uninstall all packages that are particular to your kernel version
like linux, linux-headers, virtualbox-host-modules, virtualbox-guest-modules.
like linux, linux-headers, virtualbox-host-modules, virtualbox-guest-modules.



Revision as of 15:42, 14 May 2022

Documentation

kernel option docs https://www.kernel.org/doc/html/v4.14/admin-guide/kernel-parameters.html
tut: kernel programming guide https://sysprog21.github.io/lkmpg/

Locations

/etc/modprobe.d/*.conf load kernel modules on startup
/lib/modules/$(uname -r)/* kernel modules (modules.builtin lists builtin modules)

Kernel Options

Your can add boot options for your kernel.
The location depends on your bootloader, for systemd-boot it would be in a file like /boot/loader/entries/archlinux.conf.

# /boot/loader/entries/archlinux.conf

# ...
options rdblacklist=nouveau nofb nomodeset

Some useful kernel options

nofb       # disable framebuffer
nomodeset  # disable kernel modesetting (increased resolution)

Kernel Modules

/etc/modprobe.d/*.conf location of kernel-module files

Managing Kernel Modules

lsmod                                          # list loaded kernel modules
modinfo btusb                                  # list kernel options for btusb
modprobe btusb                                 # load 'btusb' kernel module
cat /lib/modules/$(uname -r)/modules.builtin   # list builtin kernel modules

automatically loading kernel modules

Similar to other systemd files, you can gather a bunch of kernel modules in a single file. The syntax of the file is a newline separated list of modules. Their names will be exactly as they would be called by modprobe. A newline with a first character of '#', marks a comment.

/etc/modprobe.d/wiimote.conf

# /etc/modprobe.d/{yourname}.conf
uinput
btusb

Dynamic Kernel Modules (DKMS)

DKMS packages include kernel modules that are recompiled every time a new kernel is installed.
You can safely install/build these modules after an update without reboot, but you'll need to restart to use them (so the new kernel is used).

Kernel Downgrades

Boot your distro off a USB stick, and chroot into your existing installation. You'll need to uninstall all packages that are particular to your kernel version like linux, linux-headers, virtualbox-host-modules, virtualbox-guest-modules.

# Connect to the internet
sudo mount /dev/sda2 /mnt
arch-chroot /mnt /bin/bash
cd /var/cache/pacman/pkg

pacman -Rs linux-3.9.7 linux-headers-3.9.7 virtualbox-host-modules virtualbox-guest-modules
pacman -U linux-3.7.1 linux-headers 3.7.1
exit

sudo reboot