Multiple flavours of the same kernel version ======== ======== == === ==== ====== ======= NOTE: THIS IS NOW OBSOLETE. Use the append_to_version flag instead There is an expressed need from people to have several alternative flavors of a single kernel version around. It is certainly useful to have a backup flavour of a kernel version around when one is experimenting with device driver variations (it may not be possible to run a different version of a kernel and hence have that as a backup). Unfortunately, this is more complicated than it initially appears, since the presence of possibly incompatible modules has to be addressed. Firstly, the modules from different flavours have to be installed in separate directories, the modutils have to be made aware of this alternative directory, and also, the kernel (and klogd) should be able to load the right set of symbols from a System.map file (which are different enough in different flavours that klogd refuses to load the wrong one). The proper way to address this may well be to modify the kernel version in some fashion (Note: this would involve modifying the kernel source's top level Makefile). Unfortunately, SUBLEVEL needs to stay numeric (and under 255, as far as I can tell), so it is a wee bit more complex than just modifying the SUBLEVEL variable. The solution seems to be to add a FLAVOUR field to the end of UTS_RELEASE, which uname then reads properly. As of 2.1.47, this variable is used purely for output purposes (nothing seems to parse it). Oh, please note that the FLAVOUR field needs be all lowercase to meet Debian policy; and the packaging tools may reject the kernel image package unless the resulting package name is all lower case (and the kernel image name is going to be kernel-image-VERSION-FLAVOUR). This way, the user has to modify the kernel Makefile (an sample patch is provided below) to read, say, "FLAVOUR := speed_hack", and the kernel would be installed as /boot/vmlinuz-2.0.30-speed_hack, the modules would be installed under /lib/modules/2.0.30-speed_hack, uname -r would report the version as 2.0.30-speed_hack. Note: Debian users should keep the Flavour lower case, in order to comply with Debian package naming conventions. There is a patch appended to the bottom of this message that would allow klogd to discover the new System.map file, and to not choke on the non-numeric kernel version. This effort has been based on the ideas and work of Bill Mitchell and Noel Maddy . The following patch works for newer 2.2 kernels (please note that the patch may not apply cleanly, but the intent should surely be clear). This should be used as a guideline; we are adding a new variable, and adding it to the tail end of KERNELRELEASE. (Make sure that the MODLIB accomodates the Flavour, or else the installed kernel shall not be able to see its modules). ====================================================================== --- Makefile.~1~ Wed Apr 28 14:38:52 1999 +++ Makefile Fri May 14 14:18:50 1999 @@ -5,2 +5,13 @@ +# FLAVOUR is like EXTRAVERSION, but it's meant for local use, and the +# dash between it and the rest of the version is supplied here. It's used +# by make-kpkg's --flavour switch, see /usr/share/doc/kernel-package/Flavours. +#FLAVOUR = + +ifneq ($(strip $(FLAVOUR)),) +INT_FLAV := +$(FLAVOUR) +else +INT_FLAV := +endif + ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/) @@ -61,3 +72,3 @@ -KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) +KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(INT_FLAV) ====================================================================== The patch provided below is from the sources for 2.4.2 kernel, and may not apply cleanly on other versions of the kernel. It is recommended that you use it purely as a guideline. ====================================================================== diff -Naur linux-2.4.2.orig/Documentation/kbuild/makefiles.txt linux-2.4.2/Documentation/kbuild/makefiles.txt --- linux-2.4.2.orig/Documentation/kbuild/makefiles.txt Wed Feb 14 00:13:42 2001 +++ linux-2.4.2/Documentation/kbuild/makefiles.txt Wed Feb 28 09:59:30 2001 @@ -127,7 +127,7 @@ The top Makefile exports the following variables: - VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION + VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION, FLAVOUR These variables define the current kernel version. A few arch Makefiles actually use these values directly; they should use @@ -140,6 +140,9 @@ $(EXTRAVERSION) defines an even tinier sublevel for pre-patches or additional patches. It is usually some non-numeric string such as "-pre4", and is often blank. + + $(FLAVOR) can be locally set to enable multiple installation + of a kernel with the same version number, without modules clashing. KERNELRELEASE diff -Naur linux-2.4.2.orig/Makefile linux-2.4.2/Makefile --- linux-2.4.2.orig/Makefile Thu Feb 22 02:54:15 2001 +++ linux-2.4.2/Makefile Wed Feb 28 09:59:51 2001 @@ -3,7 +3,10 @@ SUBLEVEL = 2 EXTRAVERSION = -KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) +ifdef FLAVOUR + INT_FLAVOUR:=+$(FLAVOUR) +endif +KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(INT_FLAVOUR) ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/) diff -Naur linux-2.4.2.orig/arch/arm/boot/Makefile linux-2.4.2/arch/arm/boot/Makefile --- linux-2.4.2.orig/arch/arm/boot/Makefile Fri Feb 9 02:32:44 2001 +++ linux-2.4.2/arch/arm/boot/Makefile Wed Feb 28 09:45:36 2001 @@ -129,10 +129,10 @@ @test "$(INITRD)" != "" || (echo You must specify INITRD; exit -1) install: $(CONFIGURE) Image - sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) Image $(TOPDIR)/System.map "$(INSTALL_PATH)" + sh ./install.sh $(KERNELRELEASE) Image $(TOPDIR)/System.map "$(INSTALL_PATH)" zinstall: $(CONFIGURE) zImage - sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)" + sh ./install.sh $(KERNELRELEASE) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)" clean: $(RM) Image zImage bootpImage diff -Naur linux-2.4.2.orig/scripts/Menuconfig linux-2.4.2/scripts/Menuconfig --- linux-2.4.2.orig/scripts/Menuconfig Sun Oct 8 19:30:40 2000 +++ linux-2.4.2/scripts/Menuconfig Wed Feb 28 09:46:05 2001 @@ -1372,7 +1372,7 @@ DIALOG="./scripts/lxdialog/lxdialog" -kernel_version="${VERSION}.${PATCHLEVEL}.${SUBLEVEL}${EXTRAVERSION}" +kernel_version="${KERNELRELEASE}" backtitle="Linux Kernel v$kernel_version Configuration" ====================================================================== The patch provided below is from the Makefile for 2.1.47 kernel, and may not apply cleanly on other Makefiles. It is recommended that you use it purely as a guideline, and modify the Makefile manually. ====================================================================== --- Makefile.dist Mon Aug 4 12:18:57 1997 +++ Makefile Mon Aug 4 12:24:55 1997 @@ -2,6 +2,22 @@ PATCHLEVEL = 1 SUBLEVEL = 47 +# This is an example only: Uncomment the FLAVOUR line below and name +# this flavour. +# +# If you want to have more than one kernel configuration per kernel +# version, set FLAVOUR -- it will be appended to UTS_RELEASE in +# version.h (separated by a hyphen) +# +#FLAVOUR = speed_hack + +ifneq ($(strip $(FLAVOUR)),) +INT_FLAV := +$(FLAVOUR) +else +INT_FLAV := +endif + + ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/) # @@ -244,7 +260,7 @@ @mv -f .ver $@ include/linux/version.h: ./Makefile - @echo \#define UTS_RELEASE \"$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)\" > .ver + @echo \#define UTS_RELEASE \"$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(INT_FLAV)\" > .ver @echo \#define LINUX_VERSION_CODE `expr $(VERSION) \\* 65536 + $(PATCHLEVEL) \\* 256 + $(SUBLEVEL)` >> .ver @mv -f .ver $@ @@ -289,7 +305,7 @@ modules_install: @( \ - MODLIB=/lib/modules/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL); \ + MODLIB=/lib/modules/$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(INT_FLAV); \ cd modules; \ MODULES=""; \ inst_mod() { These="`cat $$1`"; MODULES="$$MODULES $$These"; \ ______________________________________________________________________ ______________________________________________________________________ From: Yann Dirson Ah, there still were some minor corrections to do. Here's my final version (compiled fine with glibc 2.0.6, but had to replace with in ksym_mod.c). kern.log now says: ==== Mar 24 11:18:52 bylbo kernel: klogd 1.3-3, log source = /proc/kmsg started. Mar 24 11:18:53 bylbo kernel: Loaded 2589 symbols from /boot/System.map-2.0.33-std. Mar 24 11:18:53 bylbo kernel: Symbols match kernel version 2.0.33-std. ==== ==== --- ksym.c.orig Mon Mar 23 23:23:03 1998 +++ ksym.c Tue Mar 24 11:18:09 1998 @@ -105,7 +105,7 @@ static int num_syms = 0; static int i_am_paranoid = 0; -static char vstring[12]; +static char vstring[65]; /* see /usr/include/linux/utsname.h */ static struct sym_table *sym_array = (struct sym_table *) 0; static char *system_maps[] = @@ -438,7 +438,7 @@ { - auto int vnum, + auto int vnum, kvnum, major, minor, patch; @@ -458,42 +458,41 @@ /* - * Since the symbol looks like a kernel version we can start - * things out by decoding the version string into its component - * parts. + * Get the numeric code from the system map. */ vnum = atoi(version + strlen(prefix)); - major = vnum / 65536; - vnum -= (major * 65536); - minor = vnum / 256; - patch = vnum - (minor * 256); - if ( debugging ) - fprintf(stderr, "Version string = %s, Major = %d, " \ - "Minor = %d, Patch = %d.\n", version + - strlen(prefix), major, minor, \ - patch); - sprintf(vstring, "%d.%d.%d", major, minor, patch); /* - * We should now have the version string in the vstring variable in - * the same format that it is stored in by the kernel. We now - * ask the kernel for its version information and compare the two - * values to determine if our system map matches the kernel - * version level. + * We now ask the kernel for its version information and + * compare the two values to determine if our system map + * matches the kernel version level. */ if ( uname(&utsname) < 0 ) { Syslog(LOG_ERR, "Cannot get kernel version information."); return(0); } + + if ( sscanf (utsname.release, "%d.%d.%d", &major, &minor, &patch) < 3 ) + { + Syslog(LOG_ERR, "Kernel send bogus release string `%s'.", + utsname.release); + return(0); + } + + /* Compute the version code from data sent by the kernel */ + kvnum = (major << 16) | (minor << 8) | patch; + if ( debugging ) - fprintf(stderr, "Comparing kernel %s with symbol table %s.\n",\ - utsname.release, vstring); + fprintf(stderr, "Comparing kernel %s with symbol table 0x%6x.\n",\ + utsname.release, vnum); /* Failure. */ - if ( strcmp(vstring, utsname.release) != 0 ) + if ( vnum != kvnum ) return(-1); + strcpy (vstring, utsname.release); + /* Success. */ return(1); } ==== ______________________________________________________________________ Old solution; that does not work cleanly: One can edit /etc/init.d/syslogd (or however you start klogd) like so (this is from the Debian init.d directory) ---------------------------------------------------------------------- # Use KLOGD="-k /boot/System.map-$(uname -r)" to specify System.map # KLOGD="-k /boot/System.map-$(uname -r)" .... .... /sbin/klogd $KLOGD ----------------------------------------------------------------------