Rebuilding the kernel on Redhat 7.2 and fixing grub boot. I will explain the steps to create a new kernel and where the files are located and what files are created and or copied during the different steps of the building process.
on the redhat docs iso... for additional reference. The Official Red Hat Linux Customization Guide note I mounted the iso image on /hda4/vendor/REDHAT/enigma-i386-docs/
file:/hda4/vendor/REDHAT/enigma-i386-docs/RH-DOCS/rhl-cg-en-7.2/index.html from here we find the linkfile:/hda4/vendor/REDHAT/enigma-i386-docs/RH-DOCS/rhl-cg-en-7.2/custom-kernel.html Appendix A. Building a Custom Kernel
I am building a modularized kernel. I wanted to add ntfs read only support and recompile for a PIII which is also referred to as a 686.
The kernel source is located. /usr/src/ you will find linux2-4 directory softlinked to /usr/src/linux2-4-10 The source is located /usr/src/linux2-4-10.
To verify you have all the kernal source installed. [root@angle root]# rpm -qa |grep kernel kernel-headers-2.4.7-10 headers source kernel-2.4.7-10 kernel binaries, what you are running on now. kernel-source-2.4.7-10 kernel source. let's roll a kernel.
uname -r To determine your current kernel version [root@angle linux-2.4]# uname -r 2.4.7-10
0. make an emergency boot disk. mkbootdisk --device /dev/fd0 2.4.7-10 Note: 2.4.7-10 is from uname -r command. 1. cd /usr/src/linux-2.4.7-10
It is important that you begin a kernel build with the source tree in a known condition. Therefore, it is recommended that you begin with the command make mrproper. This will remove any configuration files along with the remains of any previous builds that may be scattered around the source tree. Ifyou already have a working configuration file (/usr/src/linux-2.4./.config) that you want to use, back it up to a different directory before running this command and copy it back after running the command. If you use an existing configuration file, skip the next step.
Now you must create a configuration file that will determine which components to include in your new kernel.
If you are running the X Window System, the recommended method is to use the command make xconfig. Components are listed in different levels of menus and are selected using a mouse. You can select Y (yes), N (no), or M (module). After choosing your components, click the Save and Exit button to create the configuration file /usr/src/linux-2.4/.config and exit the Linux Kernel Configuration program.
Other available methods for kernel configuration are listed below:
make config - An interactive text program. Components are presented in a linear format and you answer them one at a time. This method does not require the X Window System and does not allow you to change your answers to previous questions.
make menuconfig - A text-mode, menu driven program. Components are presented in a menu of categories; you select the desired components in the same manner used in the text-mode Red Hat Linux installation program. Toggle the tag corresponding to the item you want included: [*] (built-in), [ ] (exclude), <M> (module), or < > (module capable). This method does not require the X Window System.
make oldconfig - This is a non-interactive script that will set up your configuration file to contain the default settings. If you're using the default Red Hat kernel, it will create a configuration file for the kernel that shipped with Red Hat Linux for your architecture. This is useful for setting up your kernel to known working defaults and then turning off features that you don't want.
2. make xconfig This is how I do it. The gui with xconfig is far simpler to get a sense of what you are doing. make xconfig reads /usr/src/linux2-4-10/.config and displays the current selections in the dozens of separate selection menu. The main menu. watman.com For my changes ntfs file support. File systems watman.com To select processor. Processor type and feature watman.com Then I select Save and Exit.
At the end of the make xconfig Optional 2a. I recommend copying /usr/src/linux2-4-10/.config to "some_meaningful_name.config Note: there is a /usr/src/linux2-4-10/configs subdirectory that contains other config files.
3. make dep is to make the configured dependancies. 4. make clean this removes any object files and causes all the source to be compiled.
5. (I don't consider this optional) Edit /usr/src/linux2-4-10/Makefile Change line, EXTRAVERSION = -10custom1-686 I've added a custom1-686. This will prevent one from overwriting the existing kernal and existing modules.
6. make bzImage This builds the kernel. 7. make modules This builds the modules. 8. make modules_install This copies the mudules to /lib/modules/2.4.7-10custom1-686 Note the custom1-686 added to the end of the /lib/modules/2.4.7-10. 9. make install This copies the kernal image and the System.map files to /boot /boot/vmlinuz-2.4.7-10custom1-686 /boot/System.map-2.4.7-10custom1-686
10. Build initrd to support scsi. I have a USB mem stick reader that will mount as /dev/sda1. sbin/mkinitrd /boot/initrd-2.4.7-10custom1-386.img 2.4.7-10custom1-686
Note: 2.4.7-10custom1-686 is from vmlinuz-2.4.7-10custom1-686 and is also the name of the /lib/modules/2.4.7-10custom1-686 directory.
Now setting up the grub loader. If you use lilo edit /etc/lilo.config But I'm using grub.
11. edit /boot/grub/grub.config After install of 7.2 the /boot/grub/grub.config file read. [root@angle linux-2.4]# cat /boot/grub/grub.conf # grub.conf generated by anaconda # # Note that you do not have to rerun grub after making changes to this file # NOTICE: You do not have a /boot partition. This means that # all kernel and initrd paths are relative to /, eg. # root (hd0,0) # kernel /boot/vmlinuz-version ro root=/dev/hda1 # initrd /boot/initrd-version.img #boot=/dev/hda default=0 timeout=10 splashimage=(hd0,0)/boot/grub/splash.xpm.gz title Red Hat Linux (2.4.7-10) root (hd0,0) kernel /boot/vmlinuz-2.4.7-10 ro root=/dev/hda1 initrd /boot/initrd-2.4.7-10.img
I take the last four lines and dupe them at the end of the file. Then I edit the kernel and initrd lines to reflect the new kernel version name.
Duped and edited lines. title Red Hat Linux (2.4.7-10custum1-686) root (hd0,0) kernel /boot/vmlinuz-2.4.7-10custom1-686 ro root=/dev/hda1 initrd /boot/initrd-2.4.7-10custom1-686.img
When you reboot grub will allow you to choose the new kernel. If you are happy and wish to make the new kernel the default boot. Just re edit /boot/grub/grub.conf and reorder the kernel blocks.
tom watson tosiwmee |