Date: Thu, 11 Feb 1999 07:14:47 -0800 (PST) From: Greg Herlein <gherlein@herlein.com> To: redhat-devel-list@redhat.com Subject: Modules and New Kernels Someone posted a question here yesterday about a problem with modules not working correctly after he upgraded his kernel. I am "modernizing" a document that was sent to me about the same question recently, so I thought I would post it here as a resource. I have written Riley Williams (rhw@bigfoot.com) who maintains the Modules Mini-HOWTO and he has indicated that he has little time to update the document, and says to go for it if I see the need. I plan to roll the document below into the Mini-HOWTO here soon, and try to update it for the new 2.2.X kernels. Anyone want to participate with me? Here is the basic Red Hat Module Upgrade Howto: ---------------------------------------------------------------- Installing/updating a new kernel on Red Hat Linux ------------------------------------------------- (attributed to Gene Czarcinski, edited 2/99 by Greg Herlein - needs lot more modernization and fixes to make it current) The following is based on kernel => 2.0.35 (or 2.1.125 for rawhide) and initscripts => 3.67 (or 3.78 for rawhide). It also includes some info from RedHat HOWTOs for kernel upgrade procedures (these seem to change early and often). The following info is NOT intended for the novice but may be helpful anyway. The "binary" (i386) packages involved are: - kernel - kernel-modules - kernel-pcmcia-cs - iBCS - kernel-headers - kernel-source - initscripts You may also need/want to install the kernel<<...>.src.rpm [see below] 1. If you do not need pcmcia or iBCS support, ignore these packages. You can do a rpm -e to delete them if they are installed but not needed. 2. You can copy the kernel, kernel-modules, and (optionally) the kernel-pcmcia-cs packages to a temporary directory. Do the commands: cd /<<the temp dir>/ rpm -ivh *.i386.rpm in the temporary directory. This will INSTALL the new kernel and modules while leaving the OLD kernel in place. DO NOT (repeat), DO NOT install a kernel with -Uvh since any slip and you will have NO system to boot. 3. At some time you will want to update (rpm -Uvh ...) the kernel-headers and kernel-source but you may want to wait until you make sure the new kernel works (at least that is what I do). 4. Check to make sure the installed initscripts package is correct for the new kernel. Look at the CHANGES file in the kernel source directory to see what version is required for the kernel you want to run. If you have an old version, then update it. 5. If you have any scsi devices and want to boot off of one (check /etc/conf.modules), you will need to generate an initial ramdisk. This is to get the SCSI driver into a place where it can be read before it mounts the SCSI drive (makes sense, doesn't it?). I do this anyway if there is anything in /etc/conf.modules. Issue the command mkinitrd of the form: /sbin/mkinitrd /boot/initrd-<<version>.img <<version> where <<version> is the version of your kernel/kernel-modules rpms such as 2.0.35-2. If you build SCSI support into your kernel then you do not need to do this. 6. Modify (edit) you /etc/lilo.conf file to add an entry of the form: image=/boot/vmlinuz-2.0.35-2 label=test root=/dev/hda2 initrd=/boot/initrd-2.0.35-2 read-only and then run /sbin/lilo. Take particular note that you specify the initrd-<xxx> correctly. 7. Reboot the system and select test at the lilo prompt. When you are satisfied that the new kernel is OK, you can "move" the lilo.conf entry to the top (so it is the default) and change the labels of the kernels to something like: test -> linux linux -> old 8. If you need to modify the kernel, upgrade/install kernel-source and rebuild the kernel to your liking. Assuming that you have installed 2.0.35-2 and then do your own kernel, install the indicated files in more or less the following form (supply your own version idents: cp -vp /usr/src/linux/arch/i386/boot/zImage /boot/vmlinuz-2.0.35-2a mv /lib/modules/2.0.35 /lib/modules/2.0.35-2a cp -vp /usr/src/linux/System.map /boot/System.map-2.0.35-2a cp -vp /boot/module-info-2.0.35-2 /boot/module-info-2.0.35-2a /sbin/mkinitrd /boot/initrd-2.0.35-2a.img 2.0.35-2a NOTE: /lib/modules/2.0.35 was created by "make modules_install". Now, modify you /etc/lilo.conf file, run /sbin/lilo, and reboot to begin testing. 9. More than likely, the new system WILL NOT WORK PROPERLY ... no modules! The "current" versions of initscripts (3.65 on 5.1 and 3.78 on rawhide) requires the file /lib/modules/<<version>/.rhkmvtag to exist and to contain exactly the same information as in /proc/version for the booted kernel. RedHat's i386.rpm packages install the appropriate file but if you create your own kernel, there will be no such file. If you use the kernel-<<version>.src.rpm, then this will not be a problem since it is created by the (non-installed) program rhkmvtag.c. If you can boot at all, you can create the appropriate file by running: cat /proc/version >/lib/modules/<<version>/.rhkmvtag Then reboot and everything "should" be OK. Note that Red hat uses this tag file to create a symbolic link at boot time that links the "preferred" modules directory to the modules dirirectory whose name matches the currently running kernel. For example, it creates the link: /lib/modules/2.0.35 -> /lib/modules/preferred. /etc/rc.d/rc.sysinit removes this link and rebuilds it on every boot. Alternately, you can modify /etc/rc.d/rc.sysinit so that it will find the correct directory and files. WARNING: you must edit this again later if you repeat these steps for another kernel version, or you will once again not find your modules. I personally do not recommend this approach. If you want to do something similar but less risky, edit /etc/rc.d/rc.sysinit to not remove the link to /lib/modules/preferred on boot, and make that link by hand. Again, you will need to change that link every time you upgrade your kernel or you will not find the right modules. 10. If you are running the OSS sound driver, be sure to rename/delete the /lib/modules/preferred/misc/sound.o file. 11. Here is a kernel building script that was posted awhile ago by James Keller (jmkeller@radix.net) that doesmuch of what is needed on a kernel rebuild all in one script. ######################################################################## #!/bin/sh cd /usr/src/linux rm -rf /lib/modules/2.2.1 make dep make clean make modules make modules_install make bzImage depmod -a 2.2.1 cp -a /usr/src/linux/arch/i386/boot/bzImage /boot/custom-2.2.1 cp /usr/src/linux/System.map /boot/System.map-2.2.1 cat /proc/version > /lib/modules/2.2.1/.rhkmvtag lilo ######################################################################## WARNING! This script assumes that /etc/lilo.conf is set up to boot custom compiled kernels from /boot/custom-<version number>; you will need to edit these entries by hand before running this script, or re-run lilo after you make the edit. ---------------------------------------------------------------------- Hope this helps someone! Greg /************************************************************** Greg Herlein gherlein@herlein.com Herlein Engineering www.herlein.com Software Development - Communications - Networking - Linux/Unix ***************************************************************/ -- To unsubscribe: mail -s unsubscribe redhat-devel-list-request@redhat.com < /dev/null