rickenbacherus
06-16-2003, 05:22 AM
After reading and trying some of the various methods I've seen for recompiling a Knoppix hdinstalled kernel, I have simplified it just a bit and we won't be using the xfs patch. This is more or less just the standard Debian way of installing a new kernel.
*NOTE* I (not wishing to tempt fate) am behind a very secure firewall and do not concern myself with logging in as root to get things done when necessary. You can log in as user, become root, apt-get install kernel-source blah and then relog in as root to build your new kernel if it makes you more comfortable.
You need to log in as root or you risk having permission problems. You can use fakeroot but this is one less thing to bother with in the process.
# apt-cache search ^ kernel-source
# apt-get install debhelper modutils kernel-package libncurses5
# apt-get install kernel-source-2.4.21
or whichever kernel you'd like to use.
# mcedit /etc/kernel-pkg.conf
Enter your name and email.
# cd /usr/src
# tar --bzip2 -xvf kernel-source-2.4.21.tar.bz2
# cd kernel-source-2.4.21
Now you have a choice. You can do this:
# cp /boot/config-2.4.20xfs.config
A) You can either keep the 2.4.20xfs.config file you just copied as it is or change it as you like. Then go on to the make xconfig step.
-OR- (my preference) you can skip that cp step and create your own .config file from scratch (from the default configuration actually). This can be a time consuming, hair yanking process but it is a very worthwhile effort that will produce a slimmer, trimmer, faster, tailor-made kernel.
Take your time and read about anything that you aren't familiar with. You can save the file and return to it later too.
# make xconfig
*NOTE* Make sure to select cramfs and initrd!!!
Of course do not forget to save your configuration.
# make-kpkg clean
# make-kpkg --initrd --revision=custom.1.0 kernel_image modules
*NOTE* adding the modules target to the above line is critical or your new kernel will fail to boot because the existing modules were compiled for 2.4.20xfs instead of 2.4.21 Also it eliminates making another kpkg and installing another kpkg.
# cd ..
(yes that IS cd<single space>..)
# dpkg -i kernel-image-2.4.21_custom.1.0_i386.deb
Make the boot floppy if you can. It is possible that your kernel will be too big to fit on a floppy(if you copied the xfs.config for example) Select yes to Install LILO. I cannot guide you specifically as I don't know what your setup is like. I can however briefly explain how my system boots as an example:
In /dev/hda1 I have installed GRUB. I highly recommend it as a boot manager. I never install anything else to /dev/hda1, instead I only edit the grub.conf file as necessary and add or remove partitions I would like to boot. You should be safe choosing to use the /etc/lilo.conf file that you already have. Just be sure to add your new kernel to /etc/lilo.conf. Here's mine:
# Boot up Linux by default.
#
default=Linux
image=/boot/vmlinuz-2.4.20-xfs
label=Linux
initrd=/boot/initrd.gz
read-only
Then, just add the new kernel like this:
image=/boot/vmlinuz-2.4.21
label=NewKernel
initrd=/boot/initrd.img-2.4.21
read-only
Now do /sbin/lilo and if there are no errors it's time to reboot! Select "NewKernel" (or whatever you have called your new kernel) and see if it boots. By not removing the original you can reboot and select it instead so that you aren't left with an unbootable system.
What if after I do make-kpkg --revision=custom.1.0 kernel_image modules it errors and fails to compile?
# make-kpkg clean
*TIP* If it fails while making the modules then change your command to this:
make-kpkg --revision=custom.1.0 kernel_image
This way, you can build the kernel package and then the modules. If it fails on the modules a second time you won't be recompiling the kernel too.
If it failed compiling the kernel then continue...
Then try again from make xconfig. Enter the error into G4L (http://www.google.com/linux) to find out what it is in your configuration that isn't working if you can't figure it out. Sometimes if you select option A you must also select option B and visa-versa. There's really only one way to learn and that's by just doing it.
Remember- you don't have to finish it, you can always come back to it later.
Recommended reading: man make-kpkg
*HINT* If you installed Knoppix to a 3G partition and haven't at least moved your /home directory to another partition you might run out of room when compilng this kernel. Make sure you have enough room before you start.
gluck
*NOTE* I (not wishing to tempt fate) am behind a very secure firewall and do not concern myself with logging in as root to get things done when necessary. You can log in as user, become root, apt-get install kernel-source blah and then relog in as root to build your new kernel if it makes you more comfortable.
You need to log in as root or you risk having permission problems. You can use fakeroot but this is one less thing to bother with in the process.
# apt-cache search ^ kernel-source
# apt-get install debhelper modutils kernel-package libncurses5
# apt-get install kernel-source-2.4.21
or whichever kernel you'd like to use.
# mcedit /etc/kernel-pkg.conf
Enter your name and email.
# cd /usr/src
# tar --bzip2 -xvf kernel-source-2.4.21.tar.bz2
# cd kernel-source-2.4.21
Now you have a choice. You can do this:
# cp /boot/config-2.4.20xfs.config
A) You can either keep the 2.4.20xfs.config file you just copied as it is or change it as you like. Then go on to the make xconfig step.
-OR- (my preference) you can skip that cp step and create your own .config file from scratch (from the default configuration actually). This can be a time consuming, hair yanking process but it is a very worthwhile effort that will produce a slimmer, trimmer, faster, tailor-made kernel.
Take your time and read about anything that you aren't familiar with. You can save the file and return to it later too.
# make xconfig
*NOTE* Make sure to select cramfs and initrd!!!
Of course do not forget to save your configuration.
# make-kpkg clean
# make-kpkg --initrd --revision=custom.1.0 kernel_image modules
*NOTE* adding the modules target to the above line is critical or your new kernel will fail to boot because the existing modules were compiled for 2.4.20xfs instead of 2.4.21 Also it eliminates making another kpkg and installing another kpkg.
# cd ..
(yes that IS cd<single space>..)
# dpkg -i kernel-image-2.4.21_custom.1.0_i386.deb
Make the boot floppy if you can. It is possible that your kernel will be too big to fit on a floppy(if you copied the xfs.config for example) Select yes to Install LILO. I cannot guide you specifically as I don't know what your setup is like. I can however briefly explain how my system boots as an example:
In /dev/hda1 I have installed GRUB. I highly recommend it as a boot manager. I never install anything else to /dev/hda1, instead I only edit the grub.conf file as necessary and add or remove partitions I would like to boot. You should be safe choosing to use the /etc/lilo.conf file that you already have. Just be sure to add your new kernel to /etc/lilo.conf. Here's mine:
# Boot up Linux by default.
#
default=Linux
image=/boot/vmlinuz-2.4.20-xfs
label=Linux
initrd=/boot/initrd.gz
read-only
Then, just add the new kernel like this:
image=/boot/vmlinuz-2.4.21
label=NewKernel
initrd=/boot/initrd.img-2.4.21
read-only
Now do /sbin/lilo and if there are no errors it's time to reboot! Select "NewKernel" (or whatever you have called your new kernel) and see if it boots. By not removing the original you can reboot and select it instead so that you aren't left with an unbootable system.
What if after I do make-kpkg --revision=custom.1.0 kernel_image modules it errors and fails to compile?
# make-kpkg clean
*TIP* If it fails while making the modules then change your command to this:
make-kpkg --revision=custom.1.0 kernel_image
This way, you can build the kernel package and then the modules. If it fails on the modules a second time you won't be recompiling the kernel too.
If it failed compiling the kernel then continue...
Then try again from make xconfig. Enter the error into G4L (http://www.google.com/linux) to find out what it is in your configuration that isn't working if you can't figure it out. Sometimes if you select option A you must also select option B and visa-versa. There's really only one way to learn and that's by just doing it.
Remember- you don't have to finish it, you can always come back to it later.
Recommended reading: man make-kpkg
*HINT* If you installed Knoppix to a 3G partition and haven't at least moved your /home directory to another partition you might run out of room when compilng this kernel. Make sure you have enough room before you start.
gluck