2.4 add suffix for uname -r
PATCH 1/1 2.4 add suffix for uname -r
A frequent requirement is to rename vmlinuz-2.x.y to 2.x.y-old or 2.x.y.save to preserve a working kernel. But renaming the image does not change the value of uname -r so it still tries to use modules 2.x.y, which defeats the purpose of saving an working kernel.
Normally I would say that this is a user space problem but it requires finding every program that uses uname(2) and every script that uses uname -r and changing them, not practical (modutils, alsa, pciutils, /etc/rc.d, mkinitrd etc.). Instead this small patch to the kernel adds the boot time option unamersfx (uname -r suffix). Rename a kernel image from 2.x.y to 2.x.y.foo, rename /lib/modules/2.x.y to 2.x.y.foo and boot with unamersfx=.foo to safely pick up the old kernel.
Objects that "know" the value of uname -r that they were compiled with will not work with unamersfx. Are there any?
Against 2.4.4.
Index: 4.1/init/main.c
init/main.c Sun, 06 May 2001 16:50:44 +1000 kaos (linux-2.4/k/11_main.c 1.1.5.1.1.4 644) renamed from init/main.c Sat, 28 Apr 2001 18:38:57 +1000 kaos (linux-2.4/k/11_main.c 1.1.5.1.1.4 644) +10 -0
@@ -405,10 +405,20 @@ static int __init quiet_kernel(char *str return 1; } +static int __init unamersfx(char *str) +{ + int l1 = strlen(system_utsname.release), l2 = strlen(str); + if ((l1 + l2) > sizeof(system_utsname.release)) + return 0; + memcpy(system_utsname.release+l1, str+1, l2); + return 1; +} + __setup("ro", readonly); __setup("rw", readwrite); __setup("debug", debug_kernel); __setup("quiet", quiet_kernel); +__setup("unamersfx", unamersfx); /* * This is a simple kernel command line parsing function: it parses
Index: 4.1/Documentation/kernel-parameters.txt
Documentation/kernel-parameters.txt Sun, 06 May 2001 15:39:06 +1000 kaos (linux-2.4/V/c/21_kernel-par 1.1.1.1.1.1 644) renamed from Documentation/kernel-parameters.txt Sun, 22 Apr 2001 08:26:07 +1000 kaos (linux-2.4/V/c/21_kernel-par 1.1.1.1.1.1 644) +5 -1
@@ -574,7 +574,11 @@ running once the system is up. uart401= [HW,SOUND] uart6850= [HW,SOUND] - + + unamersfx= [KNL] Copy the string as a suffix on the result of + uname -r. Use unamersfx=.xxx if you have renamed your + kernel and modules from foo to foo.xxx + usbfix [BUGS=IA-64] video= [FB] frame buffer configuration.
Quoted 19 lines · Keith Owens
Date: Sun, 06 May 2001 17:15:45 +1000
From: Keith Owens <[email protected]>
To: [email protected]
Content-Type: text/plain; charset=us-ascii
Subject: [patch] 2.4 add suffix for uname -rA frequent requirement is to rename vmlinuz-2.x.y to 2.x.y-old or 2.x.y.save to preserve a working kernel. But renaming the image does not change the value of uname -r so it still tries to use modules 2.x.y, which defeats the purpose of saving an working kernel.
Normally I would say that this is a user space problem but it requires finding every program that uses uname(2) and every script that uses uname -r and changing them, not practical (modutils, alsa, pciutils,
/etc/rc.d, mkinitrd etc.). Instead this small patch to the kernel adds the boot time option unamersfx (uname -r suffix). Rename a kernel image from 2.x.y to 2.x.y.foo, rename/lib/modules/2.x.yto 2.x.y.foo and boot with unamersfx=.foo to safely pick up the old kernel.
Quoted 2 lines
Objects that "know" the value of uname -r that they were compiled with will not work with unamersfx. Are there any?
I don't see how this patch is necessary when we have "EXTRAVERSION" available. Change EXTRAVERSION in your kernel builds and it is totally a non issue. No renaming of anything is necessary.
------------------------------------------------------------------------
Signature poll: I'm planning on getting a 12 or 16 port autosensing 10/100 ethernet switch soon for home use, and am interested in hearing others recommendations on what to buy. Cost isn't as important as is functionality and quality. Any suggestions appreciated.
------------------------------------------------------------------------
Quoted 8 lines · Mike A. Harris
Quoted 2 lines · Keith Owens
A frequent requirement is to rename vmlinuz-2.x.y to 2.x.y-old or 2.x.y.save to preserve a working kernel.
I don't see how this patch is necessary when we have "EXTRAVERSION" available. Change EXTRAVERSION in your kernel builds and it is totally a non issue. No renaming of anything is necessary.
You already have a working kernel which you want to rename to use as a backup version. Changing EXTRAVERSION and recompiling builds a new kernel and adds uncertainty about whether the kernel still works - did you change anything else before recompiling? Look at all the install scripts that rename vmlinuz to vmlinuz-old.
Quoted 11 lines · Keith Owens
Quoted 8 lines · Keith Owens
Quoted 2 lines
A frequent requirement is to rename vmlinuz-2.x.y to 2.x.y-old or 2.x.y.save to preserve a working kernel.
I don't see how this patch is necessary when we have "EXTRAVERSION" available. Change EXTRAVERSION in your kernel builds and it is totally a non issue. No renaming of anything is necessary.
You already have a working kernel which you want to rename to use as a backup version.
Why? Just use it as a backup version. No need to rename anything at all. I never rename a kernel, Sysmap, module dir or
anything when trying out a new kernel. I use EXTRAVERSION
instead - for its intended purpose - which was to eliminate these sort of problems.
Quoted 3 lines
Changing EXTRAVERSION and recompiling builds a new kernel and adds uncertainty about whether the kernel still works - did you change anything else before recompiling?
How could it possibly add any uncertainity about anything? My kernel is 2.4.2-2 right now. If I build a new one, it will be 2.4.4-1asdf probably (asdf is my machine). If I then want to try a new kernel but am not sure if I want the old one still, the new kernel will be 2.4.4-2asdf. None of the kernels have files that conflict, and the names of them never change. I add a new stanza to lilo for the new kernel, run lilo, and can easily boot any of the kernels.
Quoted 2 lines
Look at all the install scripts that rename vmlinuz to vmlinuz-old.
Better yet, rewrite those broken scripts to work with todays kernel features. My install-kernel script works just fine for adding a new kernel to the system.
By using new tools you avoid old problems.
------------------------------------------------------------------------
Signature poll: I'm planning on getting a 12 or 16 port autosensing 10/100 ethernet switch soon for home use, and am interested in hearing others recommendations on what to buy. Cost isn't as important as is functionality and quality. Any suggestions appreciated.
------------------------------------------------------------------------
Quoted 4 lines · Keith Owens
You already have a working kernel which you want to rename to use as a backup version. Changing EXTRAVERSION and recompiling builds a new kernel and adds uncertainty about whether the kernel still works - did you change anything else before recompiling?
You assign a new EXTRAVERSION to the new kernel you are building, and keep the old kernel at the old name.
Problem solved.
Sincerely,
Lars Marowsky-Brée <[email protected]>
Signature · 1 line
Perfection is our goal, excellence will be tolerated. -- J. Yahl
Quoted 2 lines · Lars Marowsky-Bree
You assign a new EXTRAVERSION to the new kernel you are building, and keep the old kernel at the old name.
Except that some patches (ie, RAID, -ac) use EXTRAVERSION. There needs to be a new variable, say USERVERSION, that will *ONLY* be set during make USERVERSION=foo.
mrc
Signature · 4 lines
Mike Castle Life is like a clock: You can work constantly [email protected] and be right all the time, or not work at all www.netcom.com/~dalgoda/ and be right at least twice a day. -- mrc We are all of us living in the shadow of Manhattan. -- Watchmen
Quoted 5 lines · Mike Castle
Quoted 2 lines · Lars Marowsky-Bree
You assign a new EXTRAVERSION to the new kernel you are building, and keep the old kernel at the old name.
Except that some patches (ie, RAID, -ac) use EXTRAVERSION.
So? You can still set EXTRAVERSION to anything you like. It is just an identifier for the admin, and not used for anything inside the kernel.
Sincerely,
Lars Marowsky-Brée <[email protected]>
Signature · 1 line
Perfection is our goal, excellence will be tolerated. -- J. Yahl
Quoted 7 lines · Mike Castle
Quoted 2 lines · Lars Marowsky-Bree
You assign a new EXTRAVERSION to the new kernel you are building, and keep the old kernel at the old name.
Except that some patches (ie, RAID, -ac) use EXTRAVERSION. There needs to be a new variable, say USERVERSION, that will *ONLY* be set during make USERVERSION=foo.
Ok, so we have $(VERSION).$(MINOR).$(PATCHLEVEL)$(EXTRAVERSION)$(USERVERSION). Isn't this the same as $(VERSION).$(MINOR).$(PATCHLEVEL)$(EXTRAVERSION) where $(EXTRAVERSION) has $(USERVERSION) appended?
In other words:
EXTRAVERSION=-ac4-build1
You can extend EXTRAVERSION infinitely, but after the first 10 or so characters, it starts to get silly.
--
Russell King ([email protected]) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html
Hi, Keith!
Quoted 4 lines
A frequent requirement is to rename vmlinuz-2.x.y to 2.x.y-old or 2.x.y.save to preserve a working kernel. But renaming the image does not change the value of uname -r so it still tries to use modules 2.x.y, which defeats the purpose of saving an working kernel.
Thank you for the patch and for taking care of the problem! I've tested it and it works for me. I'm using kernel modules and ALSA.
Quoted 2 lines
Objects that "know" the value of uname -r that they were compiled with will not work with unamersfx. Are there any?
"floppy" hardcodes the version but doesn't protest.
inserting floppy driver for 2.4.4-ac5
Floppy drive(s): fd0 is 1.44M
FDC 0 is a post-1991 82077
# uname -a Linux fonzie 2.4.4-ac5-new #3 Mon May 7 12:06:39 EDT 2001 i686 unknown
Signature · 2 lines
Regards, Pavel Roskin