– General Linux 2 – Manage/Query Kernel and Kernel Modules at Runtime (Linux Professional Institute Certification) Copyright c 2003 Angus Lees. 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. $Id: gl2.105.1.slides.tex,v 1.1 2003/10/25 04:33:06 anguslees Exp $ 1 Manage/Query kernel and kernel modules at runtime Objective 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. 2 Manage/Query Kernel and kernel modules at runtim Key files, terms, and utilities /lib/modules/kernel-version/modules.dep /etc/modules.conf & /etc/conf.modules depmod insmod lsmod rmmod modinfo modprobe uname 3 Manage/Query Kernel and kernel modules at runtim Resources of interest • linux-source/Documentation/ 4 Kernel Module Basics • 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. 5 uname – Who the kernel thinks it is 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”) 6 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 7 modprobe – Loading modules Load a module and its dependencies: modprobe modulename [module options] eg: modprobe ftape ft_fdc_base=0x123 Unload a module if it’s unused: modprobe -r modulename eg: modprobe -r ftape 8 modinfo – Module options “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. (c) 1993-1996 Bas Laarhoven (bas@vimec.nl), (c) 1995QIC-117 driver for QIC-40/80/3010/3020 floppy tape dr GPL 9 modprobe maintenance Configuration in /etc/modules.conf (aka /etc/conf.modules). # bogus example options ftape ft_fdc_base=0x123 fg_fdc_irq=5 ft_fdc_dma=1 alias char-major-27 ftape depmod builds modules.dep, describing module dependencies. 10 Loading modules - low-level Low level commands to actually insert or remove a module: insmod filename module options rmmod modulename You will probably never use these directly. 11