| View previous topic :: View next topic |
| Author |
Message |
tester
Joined: 17 Nov 2004 Posts: 25
|
Posted: Sun Nov 21, 2004 8:18 pm Post subject: How to compile RedHat Linux kernel |
|
|
Compiling a RedHat Linux Kernel
Preliminary Steps:
First you need bootable media; either CD or floppy disk. If you cannot boot from CD, you will need to make a bootable floppy disk. In the images directory of the RedHat Linux CD, you will find several images for different methods of installation. Use RAWRITE, a DOS command, to copy the image from the CD to the floppy disk.
1. Boot the computer with the bootable media. Linux will prompt you for the installation mode at the boot prompt. Press <Enter>.
2. The next few steps are simple. You will be asked to pick your language, time zone, monitor type, mouse type, etc. If you have a SCSI device or network card you want to install, you will need to add those specifically.
3. The next step is to select the type of installation you want to perform: Install GNOME Workstation, Install KDE Workstation, Install Server System, Install Custom System, or Upgrade Existing Installation. We suggest custom installation.
4. To copy the source code of the kernel during installation of Linux, select the Kernel Development option. This will copy the kernel into the /usr/src/linux-<version number> directory. To install the C++ compiler, select the Development option1.
5. The installation creates a kernel image called 'vmlinuz-<version number>' in the /boot directory; however, in our case we had two kernel images2
vmlinuz-2.2.14smp supporting multiprocessors
vmlinuz-2.2.14 supporting uniprocessor
6. The kernel is loaded at boot time. To load a kernel, enter the label of the kernel at the lilo prompt. To view the list of kernels, press <TAB> at the lilo prompt. If you do not enter the kernel label at the lilo prompt, lilo will timeout and load the default kernel.3
Building the new Kernel
1. You need to be the root user to compile a kernel.
2. Change directories to /usr/src.
> cd /usr/src
3. List the contents of /usr/src directory with attributes.
> ls -la
In the list of contents there will be a link called linux which points to the kernel source directory (ie. linux-<version number>).
4. Change directories to the linux kernel source directory. (If you would like to build a version of the kernel that is different than the one you installed. There are a few extra steps.)
> cd ./linux
5. Open Makefile in a text editor and verify the entry:
ROOT_DEV=current
6. To prepare for the compilation, we issue the following commands:
> make menuconfig4
This presents a list of configuration options. There are three choices: *, <blank>, and M. The '*' selects the option, <blank> deselects the option, and 'M' means you wish the option to be compiled as a module.5
> make dep
This will check for dependencies in selected options.
> make clean
This will remove any files from previous compilations.
Compiling the Kernel
1. To initate compilation, type:
> make zImage
This will create a kernel image called zImage in the /usr/src/linux/arch/i386/boot. Go have a cup of coffee; this takes some time. If you get the error "system too large", type:
> make bzImage
This will allow you to compile a big zImage. This won't take as long.
2. If you selected any options to be modules you need to compile those. Type:
> make modules
This will compile the options selected as modules.
Next type:
> make module_install
This will install all the modules.
Editing /etc/lilo.conf
1. Now copy either the bzImage or the zImage into the /boot directory.
> cp /usr/src/linux/arch/i386/boot/bzImage
/boot/vmlinuz-<version-number>
This command copies the bzImage file into the /boot directory and renames it to vmlinuz-<version-number>.
2. Open /etc/lilo.conf in a text editor and add the following lines
image=/boot/vmlinuz-<version number>
label=newlinux-up
read-only
root=/dev/sda1
newlinux-up would be the label for the new kernel image.
3. Save the changes and quit the text editor.
4. Now you need to run lilo. Lilo will read the /etc/lilo.conf file and make the appropriate changes.
Reboot with your new kernel
Hacking the Source Code on Schemp
There are currently two source trees:
/usr/src/kernel-2.2.17/linux and
/usr/src/linux-2.2.14/linux
If you would like to edit the source code, please do so in the /usr/src/kernel-2.2.17/linux directory only. |
|
| Back to top |
|
 |
Linux-faqs.com Owner

|
Posted: Sun Nov 21, 2004 8:18 pm Post subject: Support this site |
|
|
|
|
| Back to top |
|
 |
Peeyush Maurya
Joined: 17 Nov 2004 Posts: 92 Location: Noida
|
Posted: Wed Dec 15, 2004 10:46 pm Post subject: How to upgrade your kernel? |
|
|
How to upgrade your kernel?
Compiling new kernel
Using the patch
If you downloaded the patch you will need to go through this section.We are assuming right now that you are located in /usr/src/ directory. We have unpacked the patch (Section A.6.1). Now we will move to the kernel directory (assuming linux). Type cd linux.
Now we are located in the kernel directory. At this point we have a lot of options and questions. Is this your first patch of the kernel? No? Yes? We won't go into details and we will assume that this is your first kernel patch. Now we are ready to patch the kernel.
To do this we will use the patch utility. For more detail and wider information about this I suggest checking out the article from the www.linuxpower.org web site, located at this url: http://www.linuxpower.org/display_item.phtml?id=101 .
Type patch -E -p1 < ../patch-2.2.12
Lots of text will fly by. If it doesn't stop anywhere but only at the end (otherwise it will be asking you a question) everything went ok. If not, then you might have a problem (you already patched a kernel once, or something went really really wrong).
If everything went ok read on. Now it's time to configure the kernel and then compile it. We now have 2 choices. One is to compile the new kernel totally from scratch, the other one is to just re-compile it using the old configuration. Since you used the patch we are assuming that you're going to compile with the old configuration. If you don't wish to, read section 6.2 where we compile the kernel from scratch and use the steps there. The only difference is in step 1, where you should type make menuconfig.
This is the re-compile of the kernel using the old configuration. Follow these steps:
1. type make oldconfig
At this point you could have been asked for new drivers and development ones. Unless you really need them answer no (n).
2. type make dep
3. type make clean
4. type make zImage (if this fails use bzImage, which stands for big zImage)
5. type make modules (if you enabled them)
6. type make modules_install (if you typed #5)
If everything went ok, we have a new kernel, ready to be installed and used on the system.
Using the full source
If you downloaded the full source you will need to go through this section.
We are assuming right now that you are located in /usr/src/ directory. We have unpacked the new kernel (Section A.6.2). Now we will move to the kernel directory (assuming linux). Type cd linux.
Now we are located in the kernel directory. Now let's start our fresh compile.
1. type make menuconfig
Here you will have to configure your kernel. We won't go into details or explanations here since the configuration is different from machine to machine. Go through the configuration wisely and if you don't know what something is, rather leave it in then putting it out of the configuration.
2. type make dep
3. type make clean
4. type make zImage (if this fails use bzImage, which stands for big zImage)
5. type make modules (if you enabled them)
6. type make modules_install (if you typed #5)
If everything went ok, we have a new kernel, ready to be installed and used on the system |
|
| Back to top |
|
 |
Peeyush Maurya
Joined: 17 Nov 2004 Posts: 92 Location: Noida
|
Posted: Wed Dec 15, 2004 10:49 pm Post subject: Installing the new kernel |
|
|
Installing the new kernel
Installing the new kernel takes a knowledge of editing the lilo.conf file located in the /etc/ directory. I will state now that lilo.conf differs from machine to machine and it might not look the same on your machine as it does on my machines.
First of all, we will assume that you are still in the /usr/src/linux/ directory. We will have to copy the new kernel and System.map to certain location which again is different on some distributions.
Let's change directory to the new kernel.
Type cd /arch/i386/boot/
Type ls -al just to see what's there. You'll see something like this:
| Code: | <= start of example page =>
total 588
drwxr-xr-x 4 1046 1046 1024 Apr 5 20:54 .
drwxr-xr-x 7 1046 1046 1024 Mar 13 02:39 ..
-rw-r--r-- 1 1046 1046 2633 Jan 2 19:27 Makefile
-rwxr-xr-x 1 root root 544 Apr 5 20:54 bootsect
-rw-r--r-- 1 1046 1046 9536 Jun 24 1998 bootsect.S
-rw-r--r-- 1 root root 1238 Apr 5 20:54 bootsect.o
-rw-r--r-- 1 root root 8293 Apr 5 20:54 bootsect.s
drwxr-xr-x 2 1046 1046 1024 Apr 5 20:54 compressed
-rw-r--r-- 1 1046 1046 904 Jan 3 1995 install.sh
-rwxr-xr-x 1 root root 1428 Apr 5 20:54 setup
-rw-r--r-- 1 1046 1046 20136 Nov 29 02:18 setup.S
-rw-r--r-- 1 root root 3053 Apr 5 20:54 setup.o
-rw-r--r-- 1 root root 24136 Apr 5 20:54 setup.s
drwxr-xr-x 2 1046 1046 1024 Apr 5 20:54 tools
-rw-r--r-- 1 1046 1046 36836 Sep 30 1998 video.S
-rw-r--r-- 1 root root 477285 Apr 5 20:54 zImage
<= end of example page => |
If, you used make zImage you should copy the zImage file, otherwise copy the bzImage file. We will assume zImage.
The option which we encounter now is where to copy the kernel. On Red Hat distributions the kernel is located in /boot/ on Slackware in / . I'm not very familiar with other distributions (Debian, SuSe, etc.). Depending on your distribution make your choice where you will copy the new kernel.
We will make an example for Red Hat.
Type cp zImage /boot/vmlinuz-2.2.12
Now change the directory back to /usr/src/linux/ .
Type cd /usr/src/linux/ .
Now let's copy the new System.map. Please note that System.map is always located in /boot/ .
Type cp System.map /boot/System.map-2.2.12
Now we have to make a new symbolic link which points to the new System.map.
First change the directory to /boot by typing cd /boot .
Now delete the old symbolic link (note that deleting the symbolic link only deletes the link, not also the file or directory to which it points). Type rm System.map .
Now let's create a new symbolic link which points to our new System.map-2.2.12. Type ln -s System.map-2.2.12 System.map .
All we have to do now is to edit the lilo.conf file, add our new kernel in there and run lilo.
Let's change directory to /etc by typing cd /etc . With your favourite editor (vi, joe, pico) edit the lilo.conf file. For our example we will use joe.
You will see something like this in your file :
| Code: | <= start of example page =>
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
image=/boot/vmlinuz-2.0.36-0.7
label=linux.old
root=/dev/hda1
read-only
<= end of example page => |
Please note that this can and probably is different on your system.
Now we will add the new kernel to our lilo.conf file. Copy the part from image to the end and paste it before the current image. You should get something like this:
| Code: | <= start of example page =>
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
image=/boot/vmlinuz-2.0.36-0.7
label=linux.old
root=/dev/hda1
read-only
image=/boot/vmlinuz-2.0.36-0.7
label=linux.old
root=/dev/hda1
read-only
<= end of example page => |
Now change the pasted part to the settings and version(s) of your new kernel. For our example (we use the 2.2.4 kernel) it looks like this:
| Code: | = start of example page =>
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
prompt
timeout=50
image=/boot/vmlinuz-2.2.12
label=linux
root=/dev/hda1
read-only
image=/boot/vmlinuz-2.0.36-0.7
label=linux.old
root=/dev/hda1
read-only
<= end of example page => |
We changed the label part, the image part, everything else stayed that same.
I won't explain the basics of the lilo.conf file, since it's very well described in the LILO How-To .
Now run lilo by simply typing that. You should see something like this (more or less exactly this):
| Code: | = start of example page =>
Added linux *
Added linux.old
<= end of example page => |
You can now reboot your machine to the new kernel |
|
| Back to top |
|
 |
|