Page tags

Add a new page

This manual will guide you to compile a Kernel from Kernel.org the Fedora way. There are only 3 main commands that needs to be done to completely compile and install the Kernel. The more time you take to configure the Kernel, the more effective will be the result.

So first, download the Kernel from Kernel.org. When I am writing this documentation, the latest one available for me is linux-2.6.21.6. There archived files are available in .gz and .bz2 versions. Actually, there are no differences in both those formats, but the bz2 will be smaller in size compared to gz file.

Once done, move the extracted folder into a suitable location of your choice. I select /usr/src/linux as the place where I compile my Kernel. So I would give this commands.

# mv linux-2.6.21.6 /usr/src/linux
# cd /usr/src/linux

Now make sure you have 'ncurses' and its development packages 'ncurses-dev' installed in your system. If not, the RPM can be downloaded easily from Internet.

Once done, just issue the below commands.

# make clean
# make menuconfig

This will bring up the configuration utility of your Linux Kernel. You will be able to choose the modules that are to be added or removed from your Kernel module. The basic rule here is: Don't touch anything, if you don't know what it does. But if you know what you are doing, then you must change that.

The most important thing that you will need to do is, to set the "Processor Type". Please make sure to select the correct processor you are using. The below command will give you all details of your processor

# cat /proc/cpuinfo

The next thing is to modify the "Device Drivers". Be careful here. The below command will list all the connected devices of your computer and its details.

# lspci -vvv

Note this down and go through the "Device Drivers" section. Turn off any device driver that you wont need and enable those that you require.

If you want your system to be working in an networked environment, I would recommend to enable all options that comes under Iptables section. It will be under "Network" section. Unwanted modules like that of Bluetooth and Infrared needs to be removed. Modules for Gigabit 1000 Mbit LAN and 10000 MBit LAN can be removed if not used. Also modules for PPPoE and TUN/TAP (for VPN) can be removed.

In file system type, ext3 is set to dynamic [*]. Modules of SCSI can be removed if no SCSI devices are connected. USB SCSI drives has another module set from which were its loaded, so turning off the SCSI options wont affect the functioning of your USB devices. Make sure to check, check and re-check the Kernel configuration settings. This is a bit hard, but the fruit will taste so good once you put enough effort into it.

Once done, select "Exit" from the menu and you will be asked whether to save the configuration the the .config file. Say "YES" there. This .config will contain the details of the modules that are going to be compiled into your processor. You can save this file and keep this if for future Kernel compilations.

Once completed, execute the below command to compile the Kernel.

# make

This is a bit lengthy process and will take time. The time taken will depend on your system configuration and its performance. The time taken will vary from 9 minutes to 45 minutes. Sit back and relay. Once done, you will need to issue this command.

# make modules_install

This will install the modules for the current Kernel. It will make a new directory under /lib/modules/ with the name <version>.<patch>.<sub_level>

Then we need to install the Kernel into the /boot directory. Just issue the command, which will install the Kernel.

# make install

This actually runs a script. Here is what it does.

Add entry to /etc/grub.conf for the new Kernel

Add the initrd for new Kernel

Adds system.map into /boot

NOTE: For servers, just edit the new Kernel parameter under Grub Configuration file and add the 'panic=10'. Here is what needs to be done. You can use your favorite text editor instead of VIM, like 'nano' or 'pico' or 'joe' etc.

# vim /boot/grub/grub.conf

There find the entery for the new Kernel and add the 'panic=10' at the end of the line. Here is what it will look like.

Kernel /vmlinuz-2.6.19 ro root=LABEL=/ rhgb quiet panic=10

This is helpful as if the booting get a Kernel panic error, it will automatically reboot itself in 10 seconds.

Now to test the new Kernel, reboot your machine and stop at the Grub. There select the new Kernel you just compiled and press Enter. If everything goes fine, you will end up in a better and faster system.