Thursday, December 24, 2009

kernel recompile

Please let me know if you had trouble with this document or find any errors.

1. Go to http://www.kernel.org and download the latest stable kernel
2. Change user to root

su

3. Copy the downloaded kernel to your /usr/src directory:

cp linux-2.4.19.tar.gz /usr/src/

4. Uncompress the kernel.

tar -zxvf linux-2.4.19.tar.gz

5. Change to the linux-2.4.19 directory

cd linux-2.4.19

6. Make mrproper (This will erase any .config file) This cleans out the configuration files and any object files an older version might have.

make mrproper

The next step is optional, depending on if you want to keep your old configuration or base your new kernel on your old configuration and add the new options found in the new kernel.

OPTIONAL: Copy over the old configuration file. (assumes it is an i686)

cp -p /usr/src/linux-2.4.19/configs/kernel-2.4.18-i686.config .config

7. Complete configuration by one of these four options:

make oldconfig


This will ask you if you want to add in the new options from the kernel by selecting y/n/m.

make xconfig


(uses a GUI configuration) or

make menuconfig


(uses a terminal configuration based on curses) or

make config


You would need to edit the .config in order to select what options you want and then run make config to make the configuration file.

xconfig and menuconfig have a help option which is nice if you are unsure of what option you are turning on/off. make config and make oldconfig DO NOT have this help menu option.
8. Make the dependencies, which insures all things, like include files, are in place.

make dep

9. Make your bzImage

make bzImage

10. Make your modules

make modules

11. Copy the image over to /boot.

cp /usr/src/linux-2.4.19/arch/i386/boot/bzImage /boot/vmlinuz-2.4.19

12. Install the modules

make modules_install

13. Copy the new System.map over to /boot

cp /usr/src/linux-2.4.19/System.map /boot/System.map-2.4.19

14. Change back to the /usr/src directory

cd ..

15. At this point (for Red Hat) I remove the linux-2.4 symlink

rm linux-2.4

16. Then I make a new symlink to my new kernel directory.

ln -s linux-2.4.19 linux-2.4

17. Add the new kernel in the configuration file. For example, in grub.conf add:

title Red Hat Linux (2.4.19)
root (hd0,1)
kernel /boot/vmlinuz-2.4.19 ro root=/dev/hda2 hdd=ide-scsi


If your /boot is on its own partition please remove /boot part of the kernel location. Your last line in grub should read (If your /boot is on it's own partition)

kernel /vmlinuz-2.4.19 ro root=/dev/hda2 hdd=ide-scsi

18. Edit grub.conf

vi /etc/grub.conf

19. Add the new kernel in the configuration file

Example: grub.conf

title Red Hat Linux (2.4.19)
root (hd0,1)
kernel /boot/vmlinuz-2.4.19 ro root=/dev/hda2 hdd=ide-scsi

Blue: This is the title that Grub will show in the Splash Screen. It will say

Red Hat Linux (2.4.19)

Red: This is essentially for grub's benefit. It is where grub is installed. (since I am dual booting Windows 2000 this is hd0,1, not hd0,.)

Green: this is where the kernel Image is located and what device root is (/dev/hda2) The hdd=ide-scsi is for scsi emulation (In my case I need it for my IDE CDRW, ATAPI Zip Drive, and USB Smartmedia Reader)
20. Reboot.

reboot


reference: http://www.justlinux.com/nhf/Compiling_Kernels/20_Steps_to_a_New_Kernel_with_Grub.html

No comments:

Post a Comment