This document describes how to compile the kernel and how to use the commands of the module. I. Linux kernel-related information [plain] # view Linux system [root @ serv01 ~] # Uname Linux # view all information [root @ serv01 ~] # Uname-a Linux serv01.host. com2.6.32-131.0.15.el6.x86 _ 64 #1 SMP Tue May 10 15:42:40 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux # kernel information [root @ serv01 ~] # Uname-r 2.6.32-131.0.15.el6.x86 _ 64 #/boot directory/boot # driver initrd-2.6.32-131.0.15.el6.x86_64kdump.img # kernel vmlinuz-2.6.32-131.0.15.el6.x86_64 # desktop version of the kernel storage location [root @ larrywen boot] # cd/usr/ src/kernels/2.6.32-131.0.15.el6.x86 _ 64/[root @ larrywen 2.6.32-131.0.15.el6.x86 _ 64] # ls arch crypto firmware include ipc lib Makefile. common Module. symvers samples security System. map usr block drivers fs init kernel Makef Ile mm net scripts sound tools virt # decompress the kernel to/usr/src [root @ serv01 ~] # Tar-xvf linux-2.6.38.tar.gz-C/usr/src/[root @ serv01 ~] # Cd/usr/src/linux-2.6.38/[root @ serv01 linux-2.6.38] # pwd/usr/src/linux-2.6.38 # The installed version has a configuration file [root @ larrywen ule-sa2] # cd/ usr/src/kernels/2.6.32-131.0.15.el6.x86 _ 64/[root @ larrywen 2.6.32-131.0.15.el6.x86 _ 64] # ls. config. config # view the configuration file [root @ serv01 linux-2.6.38] # vim/boot/config-2.6.32-131.0.15.el6.x86_64 # Source Code does not distinguish between 32-bit and 64-bit # view make help # Need To Be In The linux-2.6.38 directory [root @ serv01 linux-2.6.38] # make help clean clear, Keep the configuration file mrproper to clear, do not keep the configuration file, more thoroughly make menuconfig: graphical interface make xconfig: graphical interface, you need to install QT # <*>: make it into a kernel # <M>: make the Module Two compilation configuration [plain] [root @ serv01 linux-2.6.38] # make menuconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/basic/docproc HOSTCC scripts/kconfig/conf. o HOSTCC scripts/kconfig/kxgettext. o *** Unable to find the ncurses libraries or the *** required header files. * ** 'make menuconfig' requires the ncurses librar Ies. * ***** Install ncurses (ncurses-devel) and try again. * ** make [1]: *** [scripts/kconfig/dochecklxdialog] Error 1 make: * ** [menuconfig] Error 2 [root @ serv01 linux-2.6.38] # yum install "ncurses-devel"-y # OCFS: Oracle Class FileSystem # generated after configuration. config File [root @ serv01 linux-2.6.38] # ls. config [root @ serv01 linux-2.6.38] # vim Makefile [root @ serv01 linux-2.6.38] # lsarch/x86/boot/-d arch/x86/boot/three compilation [Plain] [root @ serv01 linux-2.6.38] # make bzImage Root device is (8, 2) Setup is 14908 bytes (padded to 15360 bytes ). system is 3704 kB CRC 7521c374 Kernel: arch/x86/boot/bzImage is ready (#1) four compilation module [plain] [root @ serv01 linux-2.6.38] # make modules five installation module [plain] [root @ serv01 linux-2.6.38] # makemoudule_install # make moudule_install copy to this directory [root @ serv01 linux-2.6.38] # ls/lib/modules/2.6.32-131.0.15.el6.x8 6_64/kernel/[root @ serv01 linux-2.6.38] # ls/lib/modules/2.6.38/kernel # This error occurs because the swap partition is too small/bin/sh: line 1: 10010 Killed/sbin/depmod-AE-F System. map2.6.38 make: *** [_ modinst_post] Error 137 six install [plain] [root @ serv01 linux-2.6.38] # make install # can compare the existing version and compiled version, (compiled version: no firewall selected) [root @ serv01 linux-2.6.38] # ls/lib/modules/2.6.38/kernel/net/802 9 p bluetooth can dccp ieee802154 ipv6 llc phonet rfkill SC Tp wimax xfrm 8021q atm bridge core dns_resolver ipv4 key mac80211 rds sched sunrpc wireless [root @ serv01 linux-2.6.38] # ls/lib/modules/2.6.32-131.0.15.el6.x86 _ 64/kernel/net/802 9 p bluetooth can dccp ipv4 key mac80211 phonet rfkill sctp wimax xfrm 8021q atm bridge core ieee802154 ipv6 llc netfilter rds sched sunrpc wireless [root @ serv01 linux-2.6.38] # ls/lib/modules/2.6.38/kernel /fs/ntfs. ko [Root @ serv01 linux-2.6.38] # ls/boot/grub. conf/boot/grub. conf [root @ serv01 linux-2.6.38] # cat/boot/grub. conf # grub. conf generated by anaconda #### Note that you do not have to rerun grubafter making changes to this file ## NOTICE: You have a/boot partition. thismeans that # all kernel and initrd paths are relative to/boot/, eg. # root (hd0, 0) # kernel/vmlinuz-version Ro root =/dev/sda2 ## initrd/initrd-[generic-] version. img # boot =/dev/sda default = 0 timeout = 5 splashimage = (hd0, 0)/grub/splash.xpm.gz hiddenmenu title Red Hat Enterprise Linux (2.6.32-131.0.15.el6.x86 _ 64) root (hd0, 0) kernel/vmlinuz-2.6.32-131.0.15.el6.x86_64 ro root = UUID = 110fab7c-85c4-4bae-9114-98bc2ada24d8rd_NO_LUKS rd_NO_LVM rd_NO_MD rd_NO_DMLANG = en_US.UTF-8 SYSFONT = latarcyrheb-sun16KEYBOARDTYPE = Pc KEYTABLE = us crashkernel = auto rhgb quiet initrd/initramfs-2.6.32-131.0.15.el6.x86_64.img [root @ serv01 linux-2.6.38] # cat/boot/grub. conf #/boot directory new file initramfs-2.6.38.img vmlinuz-2.6.38 # will add a new kernel information in this file [root @ serv01 linux-2.6.38] # cat/boot/grub. conf # an error occurs generally because the swap partition is too small. We can add swap partitions. For more information about how to add swap partitions, see system O & M skills (3) -- using the dd command to increase the swap partition seven module related commands using [SQL] # view the current system loaded module [root @ serv01 linux-2.6.38] # lsmod # manually loaded module [root @ serv01 linux-2.6.38] # cd/lib/modules/2.6.38 [root @ serv01 linux-2.6.38] # cd kernel/ns [root @ serv01 linux-2.6.38] # insmod/lib/modules/2.6.38/kernel/fs/fat/ fat. ko [root @ serv01 linux-2.6.38] # lsmod | grep fat [root @ serv01 linux-2.6.38] # insmod/lib/modules/2.6.38/kernel/fs/fat/vfat. ko [root @ serv01 linux-2.6.38] # lsmod | grep fat # uninstall module, can be with the module name, can also be with the full path [root @ serv01 linux-2.6.38] # rmmod fat ERROR: module fat is in use by vfat [root @ serv01 linux-2.6.38] # rmmod vfat [root @ serv01 linux-2.6.38] # lsmod | grep fat # There is dependency between modules, add this cannot add [root @ serv01 linux-2.6.38] # insmod/lib/modules/2.6.38/kernel/fs/fat/vfat. ko # automatic processing of dependencies, do not need to add full path [root @ serv01 linux-2.6.38] # modprobe vfat [root @ serv01 linux-2.6.38] # lsmod | grep fat #-r parameter, represents remove [root @ serv01 linux-2.6.38] # modprobe-r fat [root @ serv01 linux-2.6.38] # modprobe-rvfat # record module dependency [root @ serv01 linux-2.6.38] # vim/lib/modules/ 2.6.32-131.0.15.el6.x86 _ 64/modules. dep [root @ larrywen pdf] # pwd/opt/soft/ule-sa2/pdf [root @ larrywen pdf] # ls ule-kerenl.pdf [root @ larrywen pdf] # ls ule-module.pdf # View module information [root @ serv01 linux-2.6.38] # modinfo vfat filename: /lib/modules/2.6.32-131.0.15.el6.x86 _ 64/kernel/fs/fat/vfat. ko author: Gordon Chaffee description: VFAT filesystem support license: GPL srcversion: ACCC2F7E9526F402F526976 depends: fat vermagic: 2.6.32-131.0.15.el6.x86 _ 64 SMPmod_unload modsions versions