1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Linux Professional Institute Certification — 102 Angus Lees Context Objectives Documentation Kernel Modules Utilities /etc/modules.conf Low level commands License Angus Lees gus@inodes.org Nick Urbanik nicku@nicku.org This document Licensed under GPL—see section 8 2005 July Outline 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives Documentation Kernel Modules Context Objectives Documentation Kernel Modules Utilities uname lsmod modprobe modinfo /etc/modules.conf Low level commands License Utilities /etc/modules.conf Low level commands License Topic 105 Kernel [7] Where we are up to 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives Documentation Kernel Modules Utilities 1.105.1 Manage/Query kernel and kernel modules at runtime [4] 1.105.2 Reconfigure, build, and install a custom kernel and kernel [3] /etc/modules.conf Low level commands License Description of Objective 1.105.1 Manage/Query kernel and kernel modules at runtime 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives Candidates should be able to manage and/or query a kernel and kernel loadable modules. This objective includes using command-line utilities to get information about the currently running kernel and kernel modules. It also includes manually loading and unloading modules as appropriate. It also includes being able to determine when modules can be unloaded and what parameters a module accepts. Candidates should be able to configure the system to load modules by names other than their file name. Documentation Kernel Modules Utilities /etc/modules.conf Low level commands License Key files, terms, and utilities include: 1.105.1 Manage/Query kernel and kernel modules at runtime 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives Documentation Kernel Modules Utilities /etc/modules.conf Low level commands License /lib/modules/kernel-version/modules.dep — the file built by depmod showing which module depends on what other modules /etc/modules.conf & /etc/conf.modules — configuration file for modprobe depmod — determines module dependencies and rebuilds modules.dep insmod — low level command to insert a module into running kernel lsmod — list modules loaded into kernel rmmod — low level command to remove a module from kernel modinfo — shows details about a particular module modprobe — the tool for inserting and removing Manage/Query Kernel and kernel modules at runtime Resources of interest 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives Documentation Kernel Modules Utilities /etc/modules.conf Low level commands linux-source /Documentation/ License Kernel Module Basics 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives Documentation Kernel modules are chunks of kernel code which can get loaded and unloaded at runtime. Some modules depend on code in other modules. Good for shipping pre-built kernels – but not loading all available code; good for changing between conflicting modules (eg. OSS and ALSA), etc. Kernel Modules Utilities /etc/modules.conf Low level commands License uname – Who the kernel thinks it is 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Modules are stored in /lib/modules/$(uname -r)/kernel/ -a print all information -s kernel name (“Linux”) -n “node name” (hostname) -r kernel release (“2.4.20-3-686”) -v kernel version (compile time) -m machine hardware name (“i686”) -o operating system (“GNU/Linux”) Objectives Documentation Kernel Modules Utilities uname lsmod modprobe modinfo /etc/modules.conf Low level commands License lsmod – Currently loaded modules lsmod uses /proc/modules to show you which kernel modules are currently loaded. Module bsd_comp ppp_async ppp_generic slhc ipv6 ds pcmcia_core irda parport_pc lp parport Size 5888 10624 29072 7040 230624 14596 62688 174400 34088 10560 40552 Used by 1 1 6 bsd_comp,ppp_async 1 ppp_generic 10 0 1 ds 0 1 0 2 parport_pc,lp 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives Documentation Kernel Modules Utilities uname lsmod modprobe modinfo /etc/modules.conf Low level commands License modprobe – Loading and removing modules 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives Load a module and its dependencies: $ sudo modprobe modulename [ module options ] ← eg: $ sudo modprobe ftape ft_fdc_base=0x123 ← Documentation Kernel Modules Utilities uname lsmod modprobe modinfo /etc/modules.conf Low level commands Unload a module if it’s unused: $ sudo modprobe -r modulename ← eg: $ sudo modprobe -r ftape ← License modinfo – Module options 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives “modinfo ftape” gives: parm: parm: parm: parm: . . . author: description: license: ft_fdc_base:Base address of FDC controller. ft_fdc_irq:IRQ (interrupt channel) to use. ft_fdc_dma:DMA channel to use. ft_fdc_threshold:Threshold of the FDC Fifo. Documentation Kernel Modules Utilities uname lsmod modprobe modinfo /etc/modules.conf Low level commands (c) 1993-1996 Bas Laarhoven (bas@vimec.nl), (c) 1995-1996 Kai Harrekild License QIC-117 driver for QIC-40/80/3010/3020 floppy tape drives. GPL modprobe maintenance 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives Configuration in /etc/modules.conf (aka /etc/conf.modules). Documentation Kernel Modules Utilities /etc/modules.conf # bogus example Low options ftape ft_fdc_base=0x123 fg_fdc_irq=5 ft_fdc_dma=1level commands License alias char-major-27 ftape depmod builds modules.dep, describing module dependencies. Loading modules - low-level 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives Documentation Low level commands to actually insert or remove a module: insmod filename module options rmmod modulename Kernel Modules Utilities /etc/modules.conf Low level commands License You will probably never use these directly; use modprobe or modprobe -r instead. Topics Covered Context Objectives Documentation Kernel Modules Utilities uname lsmod modprobe modinfo /etc/modules.conf Low level commands License 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives Documentation Kernel Modules Utilities /etc/modules.conf Low level commands License License Of This Document 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Angus Lees Context Objectives Documentation Copyright c 2005, 2003 Angus Lees and Nick Urbanik . Permission is granted to make and distribute verbatim copies or modified versions of this document provided that this copyright notice and this permission notice are preserved on all copies under the terms of the GNU General Public License as published by the Free Software Foundation—either version 2 of the License or (at your option) any later version. Kernel Modules Utilities /etc/modules.conf Low level commands License