[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Sheflug] kernel patch help.



And Lo! The Great Prophet James Mears uttered these words of wisdom:
> 
> I have two questions:
> 
> 1. Does anybody know how to find out if this is a patch that will be applied 
> to the kernel in future releases? Maybe somebody with contacts could ask a 
> few questions for me?

I think the only way to do this is keep an eye on the appropriate mailing 
lists, and also http://www.qbik.ch/usb/devices/showdev.php?id=1657 - the 
parent of which is linked from 
http://www2.one-eyed-alien.net/~mdharm/linux-usb/ - the home page of the 
maintainer (lest anyone here can hunt out more info).

I've checked out the diff of 2.4.21rc3 and it isn't in there, so it may be 
a case of simply waiting, or contacting the original author of the patch to 
see what its current status is,

> 2. What to do with the info on this web page in order to alter the kernel and
> compile a new kernel (yikes- there is a first time for everything) so that I 
> can get my freecom fs-1 to work and allow me to nuke winblows off my laptop.
> Nice clear instructions would be good because I am not a programmer!!

Eeeks. Big topic. How much do you know already? :-)

 
> I am running a stock SuSE 8.2 with 2.4.20 kernel.
> 

Right. Well the patch is for 2.4.21pre3, so you're down a revision. 2.4.21 
is currently in release candidate (rc) sate, so 2.4.21 proper may be 
released from anywhere between a day and a couple of weeks - keeping an eye 
on kernel.org will inform you of the current state :)

As such, the patch may or may not apply cleanly. If it doesn't apply 
cleanly and you aren't a programmer, your best bet is to fetch the exact 
kernel you want ... this will involve getting a stock 2.4.20 kernel (SuSE 
kernels, like redhat, tend to have a bunch of other patches thrown, which 
could affect the application of this patch. To play safe, use a stock 
kernel.

You'll also then need to get the patch to take 2.4.20 to 2.4.21pre3. All of 
these are under ftp.kernel.org ...

	Kernel: /pub/linux/kernel/linux-2.4.20.tar.bz2
	Patch:  /pub/linux/kernel/testing/patch-2.4.21-pre3.bz2

Change directory to a location with plenty of free disk space (2.4 can take 
a bit of room to build). This can be anywhere; contrary to popular belief, 
kernel's don't need to be built under /usr/src/linux these days -- I build 
all mine in a directory under $HOME :)

So once location has been decided ... if the directory doesn't exist, 
create it with mkdir, then cd to it, then ...

	tar yxvf <path>/linux-2.4.20.tar.bz2

for SuSE that 'y' will probably need to change as it uses a different 
key to indicate bz2 decompression. (the y key was the original key used 
when tar first supported bzip2; Slackware still uses it, other dists use 
something else, which I can't remember off the top of head -- "man tar" 
will hopefully give a clue).

Okay ... next ...

	bzip2 -d <path>/patch-2.4.21-pre3.bz2

This gives you a file "patch-2.4.21-pre3".

Now to apply this patch ...

	cd linux-2.4.20
	patch -p1 < ../patch-2.4.21-pre3

this should apply cleanly. Running:

	find . -name '*.rej' -print

will flag up any rejected patches. If find does return something, then 
there's a possible problem which should be rectified before continuing.

Assuming everything went cleanly...you need to apply your patch:

	patch -p1 < location/and/name/of/the/patch/file/here

Once that's done, run the find command above again and check for 
rejections. If all is clean (i.e., no rejected files), then we're into 
normal build territory now.

Eight steps:
	0. Clean the kernel
	1. Configure kernel
	2. Build kernel
	3. Build modules
	4. Install modules
	5. Install kernel
	6. Sort out lilo
	7. Reboot

0. Clean the kernel
	This should be step 1, but I've only just thought of it
	after writing everything else, and am feeling too lazy to
	renumber everything.

	Cleaning the kernel basically involves running:

		make mrproper

	which deletes dead links, removes any existing configuration
	that may exist from within the tar files, and essentially
	ensures the build environment isn't tainted by anything
	lying around from previous builds.

1. Configure kernel
	Use one of "make menuconfig" or "make xconfig". This 
	will bring up a text or X based config menu tool thingy
	where you can tailor your kernel and build what you and
	set what you want as modules etc... this can be a long
	(and occasionally tedious) process.

2. Build kernel
	Once you're out of the config tool and the changes are
	saved, simply type:

		make bzimage

	now go away and make a cup of tea. Actually make that a 
	pot of tea. In fact a large pot of tea. This takes time
	depending on what you've asked to build.

3. Build modules
	if the build suceeds, type:

		make modules

	and wait some more.

4. Install modules
	First off, we play safe:

		cd /lib/modules
		tar cvf /root/current-modules.tar .

	that way if the next step overwrites the existing modules (it 
	shouldn't do), they can be restored.

	Now if the build in step 3 suceeds, type:

		make modules_install

	this will install the modules into /lib/modules/<kernel-version>/
	Check this is the case by cd'ing to the directory and doing an
	ls -l. If there is only a 2.4.20 directory, worry. The backup
	we made may need to be restored. Either restore it yourself, or
	post here. Rebooting would be a last resort -- depending on what
	modules your machine requires at boot (if any), it might not come
	back up.

5. Install kernel
	This is where it gets tricky as I don't know how SuSE has set 
	things up. Essentially, you need to copy the built kernel into a 
	bootable location, usually /boot ... so on my machine I'd make
	a backup of the old kernel, copy the new one in place, run lilo
	and reboot. As I don't know what SuSE has done, I suggest doing:

		cp arch/i386/boot/bzImage /boot/bzImage-2.4.21pre3-patched

	as I suspect that that destination filename is going to be pretty
	much unique :-)

6. Sort out lilo
	If SuSE doesn't use LILO, you'll need to get someone else to tell
	you about this step. LILO is the boot manager, and its configuration
	is held in /etc/lilo.conf. All you need to do is add a section to
	the end of lilo.conf that reads something like:

		image = /boot/bzImage-2.4.21pre3-patched
			root = /dev/hdc1
			label = mynewlinux
			read-only

	The "root" will probably need to change - this is the partition of
	your root filesystem; look at the output of mount to determine this
	if you aren't sure. The label can be anything you want -- this is
	the name of this boot option.

	Once this is added (to the end ideally at the moment) of lilo.conf,
	save changes, exit, and type:

		/sbin/lilo

	This will install the new boot instructions ... or report an error
	in lilo.conf :-)

7. Reboot
	shutdown -r now

	Then choose the new image that lilo should boot, either by choosing
	it off a menu, or typing its name (pressing <tab> at a lilo prompt
	gives a list of images, of which your new one should be one of them.

	If you let LILO timeout, the default kernel that boots will be your
	original kernel as we've left the rest of the LILO config alone and
	also left the old kernel and modules alone.


> Hope anybody can help.
> 

This is a quick guide, and I may have left summat out. Lots could be 
written on each step, and I'm at a disadvantage as well with not having 
SuSE as a reference platform -- but these are the core tasks that would be 
performed on any distribution with a stock linux kernel.

If someone can add SuSE specific details, it may ease the, er, pain of 
reconfiguration by reusing the SuSE configuration file (kernel 
configurations can be brought forward by copying the .config file created 
in a previous kernel version to the latest version and running "make 
oldconfig" which will read it and prompt only on new config options).

Someone correct me if I've missed something out or made something rather 
ambiguous; if you need more read the file "README" in the Linux source tree 
which also gives an overview, and also see the Kernel-HOWTO at:

http://www.ibiblio.org/pub/Linux/docs/HOWTO/other-formats/html_single/Kernel-HOWTO.html

(hopefully exmh won't force that URL to linewrap).

Cheers,

Chris...

-- 
\ Chris Johnson           \ NP: Strawberry Switchblade - 06. Let Her Go
 \ cej [at] nightwolf.org.uk    ~-----,  
  \ http://cej.nightwolf.org.uk/  ~-----------------------------------, 
   \ Redclaw chat - http://redclaw.org.uk - telnet redclaw.org.uk 2000 \____

___________________________________________________________________

Sheffield Linux User's Group -
http://www.sheflug.co.uk/mailfaq.html

  GNU the choice of a complete generation.