1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Geoff Robertson 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Linux Professional Institute Certification — 102 Angus Lees gus@inodes.org Geoffrey Robertson ge@ffrey.com Nick Urbanik nicku@nicku.org 2005 July 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 Geoff Robertson 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. Key files, terms, and utilities include: 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Geoff Robertson /lib/modules/kernel-version/modules.dep /etc/modules.conf & /etc/conf.modules depmod insmod lsmod rmmod modinfo modprobe uname Manage/Query kernel and kernel modules at runtime Objective 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Geoff Robertson 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. Manage/Query Kernel and kernel modules at runtime Key files, terms, and utilities 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Geoff Robertson /lib/modules/kernel-version/modules.dep /etc/modules.conf & /etc/conf.modules depmod insmod lsmod rmmod modinfo modprobe uname Manage/Query Kernel and kernel modules at runtime Resources of interest 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Geoff Robertson linux-source/Documentation/ Kernel Module Basics 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Geoff Robertson 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. uname – Who the kernel thinks it is 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Geoff Robertson 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”) 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 Geoff Robertson modprobe – Loading modules 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Geoff Robertson 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 modinfo – Module options 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Geoff Robertson “modinfo ftape” gives: parm: parm: parm: parm: . . . 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. author: (c) 1993-1996 Bas Laarhoven (bas@vimec.nl), (c) 1995 description: QIC-117 driver for QIC-40/80/3010/3020 floppy tape d license: GPL modprobe maintenance 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Geoff Robertson 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. Loading modules - low-level 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Geoff Robertson Low level commands to actually insert or remove a module: insmod filename module options rmmod modulename You will probably never use these directly. License Of This Document 1.105.1 Manage/Query kernel and kernel modules at runtime Weight 4 Geoff Robertson Copyright c 2005, 2003 Angus Lees , Geoffrey Robertson 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.