LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 09-21-2006, 09:04 AM   #1
b345713
LQ Newbie
 
Registered: Dec 2005
Posts: 19

Rep: Reputation: 0
kernel patch (.tgz) for BT


Hello all!

I am new to linux and have been playing with slack 10.2 as it seems to be one of the distributions with a high learning curve. Hoppefully this way I will learn what I want a bit quicker.

Recently I've been playing with slack based Livecd's and now I would like to create a slackware package (.tgz) that detects the kernel version (uname -a) and then patches the kernel accordingly so that it can load a wireless driver (rt2x00) and further convert this package (kernel patch + driver) to a (.mo) using tgz2mo, but this last part I can do by myself!

To start as my bash scripting is pretty poor - (close to unexistant) and my linux filesystem knowledge equally lacking, I am only concentrating on patching a single kernel vs por a particular livecd (BT - v 1.0 final using 2.6.15.6 and patching it to 2.6.17), so I will leave the script for kernel version detection and patch selection for latter.

My idea is the following:

I know that it is possible to patch the kernel using the provided kernel.org patches. After applying these, maybe it would be possible to create a link from /usr/src/linux to the new kernel!

Yet I am a bit confused! Isn't this location only for the kernel sources! Would this be the kernel used? Or would I have to create a package that would execute the 2 patches (patch -p1 < patch-2.6.16 + patch -p1 < patch-2.6.17)?

When succeded in creating this kernel package how could I make sure that the kernel patch would be applied before loading the driver package?

Would it be better to use a whole ready compiled kernel since this is for a livecd?

How can I go about this! Any particular ideas on the path to follow?

I've been instructed on the BT forum to make use of the doinst.sh file as it makes use of softlinks, but to be honest after reading the how-to on creating slacware packages I still do not know where to start.

Apologies for my ignorance and thak you for your time.

Best regards

f1x3r
 
Old 09-21-2006, 12:27 PM   #2
win32sux
LQ Guru
 
Registered: Jul 2003
Location: Los Angeles
Distribution: Ubuntu
Posts: 9,870

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
what's BT?? also, i'm curious as to why you don't just create new kernel packages with your patch applied?? and if you keep the old kernel around, you'll be able to select which one to boot by configuring your lilo...

patches are applied to the source from within your .SlackBuild script...
 
Old 09-21-2006, 12:45 PM   #3
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613Reputation: 613
You can't patch a kernel. You patch the sources and recompile to get the new kernel.
 
Old 09-21-2006, 07:16 PM   #4
b345713
LQ Newbie
 
Registered: Dec 2005
Posts: 19

Original Poster
Rep: Reputation: 0
"what's BT?? also, i'm curious as to why you don't just create new kernel packages with your patch applied?? and if you keep the old kernel around, you'll be able to select which one to boot by configuring your lilo...

patches are applied to the source from within your .SlackBuild script..."

Sorry, BT is B|T i.e Backtrack v 1.0 final - a slax based security livecd!

I don't just create kernel packages with the patch I applied because I have never created a kernel package for a livecd or for a normal install (yet) and I am not really sure I know how to, but will do as someone tells me how-to or as soon as I find a clear enough tutorial in google!

My incorrect question was how can I create a module to "patch" the kernel of a livecd so that I can load a slax driver module (.mo) that requires the new kernel!

Note: As gnashley very eloquently explained (thank you) the patches are for the kernel sources not the kernel itself!

So now that I am a little bit more informed I will refrase.

I want to create a module (if this is possible) that allows me to boot this livecd with a different kernel version from the one it originally comes with so that I can run the rt2x00 module (.mo) I created (by compiling serialmonkey's source and converting to a .mo using dir2mo) as it requires kernel vs 2.6.17.

Q:Why do I want to do this?
A:So that I can share it with other Backtrack/Slax users having the same problem as me i.e no driver module for ralink rt2561 chipsets with rfmon support, and learn something along the way.

Q:Why don't I just create a new livecd with the kernel I have patched?
A:Because then I would not be able to share a small file (or 2 relatively small files) with other B|T users as I would have to upload a whole livecd, and that is no good as:

a) the maximum module size allowed is (+-) 100MB.
b) I don't have the bandwith + space + resources to host this.
c) I don't want to copy work done by others, and clame undeserved glory. I want to learn and contribute.

Now according to Korneto's post (2005) also on slax's how-to forum in order to create a livecd I should:

****************************************************************************************
Quote:

"
1.) Install and configure your Linux-System according to your needs
2.) Prepare a working directory:

# mkdir /tmp/remaster
# cd /tmp/remaster

3.) organize all necessary components, i.e. download and extract them:

3.1) Linux live scripts...
3.2) unionfs...
3.3) sqashfs...
3.4) kernel...

4.) build the kernel

before we can compile the kernel, we have to apply some patches in order to be able to use it for the Live-CD.

4.1) unionfs patch:

# cd /tmp/remaster/unionfs-1.0.13
# ./patch-kernel.sh /tmp/remaster/linux-2.6.12.5

you now should have a new directory containg a lot of files at /tmp/remaster/linux-2.6.12.5/fs/unionfs

4.2) squashfs patch:

# cd /tmp/remaster/linux-2.6.12.5
# patch -p1 < /tmp/remaster/squashfs2.2/linux-2.6.12/squashfs2.2-patch

4.3) configure the kernel

We need some specific settings are mandatory to get a Live-CD suitable kernel:
the easiest way for this is to use config-file coming with the live-scripts as a starting base.
this will automatically activate unionfs, squashfs and all other settings necessary for a live-cd:

# cp /tmp/remaster/linux-live-5.1.4/initrd/kernel-modules/2.6.12.2/.config /tmp/remaster/linux-2.6.12.5
# make menuconfig

now make your changes, but ensure that the following values remain with these values:
CONFIG_EXT2_FS=y
CONFIG_TMPFS=y
CONFIG_BLK_DEV_RAM=y
CONFIG_BLK_DEV_INITRD=y

as soon as you finished with your adaptions, exit the config-tool.
It will ask you for saving the changes.

Confirm this with Y(es)

start the compile-process:

# make

5.) install the kernel

# mv /boot/System.map /boot/System.map.old
# cp /tmp/remaster/linux-2.6.12.5/System.map /boot/System.map
# mv /boot/vmlinuz /boot/vmlinuz.old
# cp /tmp/remaster/linux-2.6.12.5/arch/i386/boot/bzImage /boot/vmlinuz
# mv /boot/config /boot/config.old
# cp /tmp/remaster/linux-2.6.12.5/.config /boot/config

install the modules:

# make modules_install

reconfigure your boot manager (eg. lilo) in order to support the newly compiled kernel.
for lilo the file /etc/lilo.conf has to be modified extended, then lilo has to be executed once to apply the changes

6.) test the kernel
reboot your PC, cross your fingers and as soon as the machine is up and running check the linux kernel version:

# uname -a

it should show you your kernel version

7.) build unionfs

# cd /tmp/remaster/unionfs-1.0.13
# echo

the default for the unionfs module makes a debug version, which is much bigger in space compared to the non-debug version.
if you want to create the smaller version execute the following line optionally:

# echo EXTRACFLAGS=-DUNIONFS_NDEBUG > fistdev.mk

now build the module and install it:

# make
# make install

8.) build squashfs-tools

Actually the so-called squashfs tools should have been created automatically by patching the kernel as described at 4.2.
You can check that simply by looking into /usr/sbin. If you have a file there called mksquashfs with a reasonable timestamp you should be fine and can directly jump over to point 9, if not, compile and install the tools manually:

# cd /tmp/remaster/squashfs2.2/squashfs-tools
# make
# make install
# cp /tmp/remaster/squashfs2.2/squashfs-tools/mksquashfs /usr/sbin/mksquashfs

9.) final steps
we are close to finish now.
linux is doing some checks during boot sequence, which do not harm, but produce annoying messages and even wait for the user to press a key.
If you want to avoid such messages, open the file /etc/rc.d/rc.S, go to line 137 which looks somehow like that:

Code:
if [ ! "$ROOTTYPE" = "umsdos" ]; then # no warn for UMSDOS

insert a new line right after this one and just simply put the command "exit" there.
So, this part should look somehow like this:
...
...
if [ ! "$ROOTTYPE" = "umsdos" ]; then # no warn for UMSDOS
exit
echo
echo "*** ERROR: Root partition has already been mounted read-write. Cannot check!"
echo
...
...

Save the file.

Copy unionfs and squashfs to the live-scripts:

# mkdir /tmp/remaster/linux-live-5.1.4/initrd/kernel-modules/2.6.12.5
# cp /lib/modules/2.6.12.5/kernel/fs/unionfs.ko /tmp/remaster/linux-live-5.1.4/initrd/kernel-modules/2.6.12.5/
# cp /lib/modules/2.6.12.5/kernel/fs/squashfs/squashfs.ko /tmp/remaster/linux-live-5.1.4/initrd/kernel-modules/2.6.12.5/

...
here there was a fix on how to solve ram-size being too small and configuring a higher resolution
...

11.) let's do it!

# cd /tmp/remaster/linux-live-5.1.4/
# ./runme.sh
"
End Quote
****************************************************************************************

And then I should have a livecd.

As I already have a live cd and I:

a) installed it on my hard drive.
b) patched the kernel sources and compiled them
c) installed the rt2x00 driver and converted the binaries to a module (.mo)

I believe all that I should worry about is getting B|T livecd to load the kernel I compiled instead of the default one without creating a whole new livecd.

As this is a live cd at boot I have ISOLINUX, so configuring lilo (or grub for that matter) to allow me to choose which kernel to boot is my next learning goal!

Any insight is welcome, but I know google is my friend

Further as the modular structure of slax allows me to convert tgz2mo and it is possible to create a kernel package which I then can convert to .mo, maybe I should focus on the kernel itself, and how to get the boot manager to load the kernel module.

So.......

According to Zariweb's post (2006) on slax's how-to forum, in order to produce a livecd usable kernel I should:

Quote:

"1. Install kernel sources:

Assuming the kernel sources are installed at /usr/src/linux-2.6.x.x

2. Patch for SquashFS support:

Uncompress Squashfs tarball to a temp directory, i.e $SQUASHFS_DIR

Patch kernel sources for SquashFS:

# cd /usr/src/linux-2.6.x.x
# patch -p1 < /$SQUASHFS_DIR/linux-2.6.16/squashfs3.0-patch

3. Optional: use current kernel configuration as base. If kernel has support for /proc/config.gz then:

# zcat /proc/config.gz > .config

If not, chances are a config-2.6.15.6 is on /boot directory. If so simply copy this file to kernel source dir:

# cp /boot/config-2.6.x.x .config

Configure kernel:

# make menuconfig

NB: Check SquashFS filesystem support is enabled.

<<< Kernel configuration >>>
Filesytems --> Miscellaneous Filesystems --> SquashFS 3.0 (M)

3. Compile and install kernel:

# make
# make modules_install
# cp arch/i386/boot/bzImage /boot/vmlinuz
# cp .config /boot/config-2.6.x.x
# cp System.map /boot/System.map

***COMMENT REGARDING win32sux's suggestion***

A much better approach is to create a *KERNEL PACKAGE* first and install from there, but as this depends on the Linux flavor your are using I'll leave it as a homework

4. Reboot with your new kernel.

You must first configure your boot loader to boot using your new kernel. As precaution you should have the possibility to boot from another kernel in case something goes wrong.

5. Compile UnionFS as an external module:

Untar unionfs gzipped tar file to a working directory. According to Unionfs documentation you should be able to just type make and compile a module for your running kernel and the utilities, however I make some changes to reduce the final size of the kernel module.

# tar xvzf unionfs-x.x.tar.gz
# cd unionfs-x.x.tar.gz
# sed -i 's/UNIONFS_DEBUG_CFLAG[[:blank:]]*-g/UNIONFS_DEBUG_CFLAG=/'
# echo "EXTRACFLAG=-DSUPPORT_BROKEN_LOSETUP=1" > fistdev.mk
# echo "EXTRACFLAG+=-DUNIONFS_DEBUG" >> fistdev.mk

Build the module:

# make

Install the UnionFS module by doing:

# mkdir -p /lib/modules/2.6.x.x/kernel/fs/unionfs
# cp unionfs.ko /lib/modules/2.6.x.x/kernel/fs/unionfs
# depmod

6. Create the initial RAM disk:

Use Linux-Live's initrd_create script to create the initial RAM disk for your kernel.

Copy the Squashfs and Unionfs modules for LiveCD kernel into the kernel-modules directory, under initrd, and then simply call initrd_create script.

# cd linux-live-x.x.x/initrd
# cp /lib/modules/2.6.x.x/kernel/fs/squashfs/squashfs.ko kernel-modules/2.6.x.x/
# cp /lib/modules/2.6.x.x/kernel/fs/unionfs/unionfs.ko kernel-modules/2.6.x.x/
# ./initrd_create

"
End quote

And then I should have a livecd kernel

Now as I have installed the livecd to my hard drive, I assume (maybe incorrectly) I am already using a livecd kernel, and as such I don't have to follow all these steps!

Maybe I only have to patch the sources and follow zariweb's instructions from step 3 onwards, so that then I can create a kernel package from this (which I don't really know how to do) + convert it to a module + get lilo configured to load the kernel MODULE (which I also do not know how to do yet) so that I can load the rt2x00 driver module?

Any ideas on how to configure the doinst.sh for the kernel package?

DOES THIS MAKE ANY SENSE?

If you have read the whole post up to here thank you for your patience and your time!

Best regards,

f1x3r
 
Old 09-25-2006, 12:50 PM   #5
b345713
LQ Newbie
 
Registered: Dec 2005
Posts: 19

Original Poster
Rep: Reputation: 0
Post bsdiff?

Nobody replied to my last thread (maybe because it is to long and messy), so I wonder wether I am posting this in the right place!

Anyway as I had some free time I decided to inform myself and learn a bit more about my problem!

This kernel module in particular (rt2x00) requires kernel 2.6.17 as the rt2x00 developers cannot maintain support for previous versions. The reason for this is due to the fact that a bug occurred upon the implementation of this new devicescape stack vs which ships with the module causing general system crashes whilst running on previous kernels!

So what I have to do is change the kernel version of the live cd. What I did not know ( ) is that as .mo files are kernel modules, they are loaded by the kernel itself and as such a .mo file would not solve the problem, only make it a bigger problem! By implementing a module that would patch the kernel, compile it and then load the kernel driver I would be complicating the situation, not solving it, as this would result in a huge boot time and a reboot where the situation would repeat itself, never getting solved.

So what I have to do is change some files in the livcd.(vmlinuz, initrd and 01_core.mo, plus all the kernel modules).

Now in order to share this with others that have the same problem I believe the most efficient solution is to create a binary delta compressed package that patches the original cd so that it satisfies the necessary requirements.

I believe the easier way to do this is by (correct me if I am wrong) making a clean hdd install of the livecd + patching it + compiling the kernel and all modules and then recreating a livecd from my hdd install so that I can make a "BSDIFF" by comparing the original and the new cd's so that others can use it to patch their own! Maybe there is a better (more efficient or ellegant) way, but this the only one I have come up with.

Do you know if bcm43xx wireless cards are supported as off kernel 2.6.17? I don't really know + think the broadcom developers make people use a whole kernel tree rather than a module + this intel / dscape stack mix makes matters a lot more confusing! As far as I know dscape as not been implemented in the official kernel tree yet being maintaned as the wireless-dev tree, reason why the rt2x00 guys have to ship a vs with their module. But the broadcom people have a different startegy.

A little aside question? How can I create a binary kernel package (.tgz)?

Best regards and thank you for your help!

f1x3r
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How do i patch 2.4.21-37 kernel with antidote2 security patch suchi Linux - Kernel 4 09-05-2006 02:29 AM
Unable to patch 2.6.11.7 kernel with Reiser4 mm patch SlackwareInAZ Slackware 9 04-26-2005 06:33 AM
debian-patch-debianlogo w/2.6.5 kernel-patch-lpp Outabux Debian 11 05-20-2004 01:21 PM
kernel 2.6.3 compile time and tgz newinlinux Slackware - Installation 2 02-19-2004 09:32 PM
X Sever crash after xset.tgz & vg16.tgz install lachlan Slackware 0 08-13-2003 02:48 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration