"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