A Guide to Recompiling the Kernel


Recommended Posts

Downloading and installing the kernel

The new kernel is quite easy to find and download. Follow these steps.

1. First, become root (use the: su command in a shell)

2. Go to The Linux Kernel Archives.

3. Download the Linux 2.6.xx kernel and save it to your /usr/src directory.

4. As root, run the following commands in the console. (Note: This assumes you've installed your Linux distribution with all the developer options. If you haven't, take a look at your distribution's website for more information on 2.6 kernel packages you can download.)

tar -zxvf linux-2.6.xx.tar.gz
cd linux-2.6.xx
make menuconfig

After your machine takes a bit of time to compose the menus, you should see the Linux kernel menu system. The menu gives you the ability to choose which options are included in your kernel. After choosing these options, you'll be able to compile your kernel.

Compiling the kernel

First, type in the following.

make bzImage

If you use LILO as your boot manager, then type the following.

make install

If you configured your kernel to use modules, which many people want to do, you'll need to type in the following command.

make modules
make modules_install

Hurry up and wait

If it's your first time building a kernel, keep the boot disk from the first time you installed your OS. It'll come in handy if you did something wrong when configuring your kernel!

Building the kernel can take a lot of time, depending on your machine's specs. Think in terms of at least a half-hour and you won't be far off. It's a big plate of spaghetti for your computer to munch on, so be patient.

The good news is that Linux is great at multitasking, so you can go surf the Web while the kernel compiles. And have fun!

Link to comment
https://www.neowin.net/forum/topic/149758-a-guide-to-recompiling-the-kernel/
Share on other sites

Not a bad guide. Perhaps if you could include a run down on the recommended options in the Linux Kernel Menu system? For newbies this can be a very daunting process. Remember. Always aim your guide towards first time users. Keep it as simplified as possible. Step by step instructions are a must!

A couple of things:

1) you want to untar the file with

tar -xvjpf linux.whatever

or

tar -xvzpf linux.whatever

It keeps the permissions correct. I don't know if the p is necessary for compiling and using, but it is a good practive for kernels

2) With the latest 2.6 kernels you only need to type

make

after the menuconfig. It will make the bzlmage and the modules. then type

make modules_install

3) You don't need to symling to /usr/src/linux. This is for the kernel headers. Actually it is advisable to have this linked to an older 2.4 kernel or a 2.4 header set for backwards compatibility. It will not mess up compiling anything if you set it to a 2.4 kernel. However the 2.6 kernel's headers are slightly different than normally expected by the compiler and its libraries.

4) you can run

make install

for both lilo and grub if they are set right.

5) For the menuconfig I suggest that you get a listing of all your hardware on a piece of paper and make sure that it is very detailed. Additionally you need to check with the distro to make sure that you don't need to add in extra stuff to make that distro work right. I know you need to with gentoo.

6) lastly if you don't choose make install to install the kernel, don't overwrite the last one. and if you choose make install it will over write the last kernel installed if it has the same name. For example if you have installed a 2.6.3 kernel and want to change some things and don't do anything to the kernel source (ie add patches) and re make the 2.6.3 kernel and choose make install the original 2.6.3 kernel will be replaced with the newer one. However you can change this in the make file in the base kernel source directory. it is in the extraversion options. I suggest you patch the kernel source to see what I am talking about because most patches will change the append on the end of the image files and system map files.

7) I am sorry if I confused anyone. Compiling your own kernel isn't difficult. However you have to make sure you configure it correctly in the menuconfig. Wierd things can happen, and at worse a kernel panic. But these are all fixable. Try to have another kernel for just in case your new one fails. Then you can boot with it at lilo or grub and you can fix whatever error you made.

I get Unexpected EOF in archive error

Most likely you downloaded a bad kernel source. download a new one and try again.

What about generate-modprobe.conf?

I've always had to do that in order to get everything working. Remember that you have to specify the output of the modprobe.conf file to the /etc dir tho.

Also I found make gconfig better than menuconfig, but I guess that is a matter of personal taste.

I'm not an expert but, like I think that like I said, make install will usually update grub for you so that the new kernel is listed on the statup menu.

For example here is my /etc/grub.conf file:

# 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,4)
# ? ? ? ? ?kernel /boot/vmlinuz-version ro root=/dev/hda5
# ? ? ? ? ?initrd /boot/initrd-version.img
#boot=/dev/hda
default=0
timeout=10
splashimage=(hd0,4)/boot/grub/splash.xpm.gz
title Fedora Core (2.4.22-1.2174.nptl)
	root (hd0,4)
	kernel /boot/vmlinuz-2.4.22-1.2174.nptl ro root=LABEL=/ hdd=ide-scsi rhgb
	initrd /boot/initrd-2.4.22-1.2174.nptl.img
title Fedora Core (2.4.22-1.2115.nptl)
	root (hd0,4)
	kernel /boot/vmlinuz-2.4.22-1.2115.nptl ro root=LABEL=/ hdd=ide-scsi rhgb
	initrd /boot/initrd-2.4.22-1.2115.nptl.img
title Windows XP
	rootnoverify (hd0,0)
	chainloader +1

You see I have two different linux kernel entries (2.4.22-1.2174.nptl?& 2.4.22-1.2115.nptl)?

You could try manually adding the new kernel to the grub.conf file but to me it sounds like the install has not worked properly as it has always done this itself for me.

  • 3 weeks later...

For LILO try running the $lilo command from the terminal see if this adds the kernel to your config

Alternate

-----------

1.Assumes that you have "root" or "sudo"

Take a look in the "/boot" partition or file path depending on how you partitioned your drive.

use the following from your terminal of choice

$ls -F /boot

See what you have got there and double check that with your grub.conf file.

<snip>

kernel /boot/vmlinuz-2.4.22-1.2174.nptl ro root=LABEL=/ hdd=ide-scsi rhgb

initrd /boot/initrd-2.4.22-1.2174.nptl.img

title Fedora Core (2.4.22-1.2115.nptl)

root (hd0,4)

</snip>

Your output from the "ls" command should be able to be matched to one of your kernel entries,

ie..

If you have kernel named vmlinuz-2.4.22-1.nptl in your config file you should also have a file named

vmlinuz-2.4.22-1.nptl in your "/boot" directory. If for some chance your kernel image is not listed in

your "/boot" directory search for it then move it to your /"boot" directory manualy.

#Update your locate database

$updated

#Search for the kernel image

$locate vmlinuz-2.6.* | less

See what you can find, use the up & down cursor keys to navigate to the end of the results or until you

find what you are looking for, if you find the kernal image then move it to the "/boot" directory.

$mv -r /file.name/path/to file /boot

Repeat the above steps for the initrd image.

Now double check that your conf file and your kernel images line up. Restart the box to see if you get an option for the kernel at boot.

Hope this helps,

The_Geek

i did this question in other thread, but i guess i can repeat it here too because are pretty the same post...

wich is the diference in set to Built-in or Module on the kernel configuration when you enter the make menuconfig command?

that's all. thanks

built-in compiles the part into the kernel. modules compiles the part as an externel module that can be loaded or unloaded at any given time given the correct circumstances. Some parts need to be compiled in otherwise you risk a kernel panic, most doesn't and you need to experiment with those to determine the optimum settings for your computer.

I got a kernel panic :oops: :D

Couldnt mount the hard drive or something, which i imagine is pretty serious :p Im sure it just needs a little bit more care and adaptation from me, and i'll try later, but if anyone has any tips that would be appreciated.

Oh, by the way, im using SuSE and have been told that i shouldnt of just compiled 2.6.0 randomly and needed a SuSE-adapted kernel. How correct is this? Sounds a load of rubbish to me

Kongit - is there any speed advantage to using modules over compiled-in or do I have that back to front?

Specifically I'd like to improve the boot speed of the kernel as currently it takes 5 or 10 secs before my services etc start.

It depends. I for one have noticed no speed increase on boot with the exception of usb. I use hotplug (almost all distros do) so only the usb stuff that is plugged in at boot will be loaded. If you get your kernel properly configured and the modules that are supposed to load at boot properly configured then you will probably have the best in time for boot. However boot times for a normal linux user shouldn't matter as you stay booted for long periods of time.

It shouldn't make a difference between compiling in or as modules if everything is configured correctly for boot speed.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • There is a lot of reasons not to use Edge but faster fixes and security updates is not one of them.
    • Can't reproduce. I installed Edge, went to neowin.net > accepted the cookie consent > used menu to go to forums, everything loads and I can browse around the forums. If you can't interact with the dialog on the forums for some reason, go to the main site and accept the cookie consent there? It is true that the site will not function properly until the cookie consent is accepted or rejected,. it's a legal requirement and I also know that certain VPN/ad blockers block it, which is a user related issue and not a neowin.net problem.   This is not our cookie consent dialog. Gotta love browser hijacking... /s Edit: this may be what Californians see, I will confirm with our consent provider.
    • Google Chrome 149.0.7827.115 (offline installer) by Razvan Serea The web browser is arguably the most important piece of software on your computer. You spend much of your time online inside a browser: when you search, chat, email, shop, bank, read the news, and watch videos online, you often do all this using a browser. Google Chrome is a browser that combines a minimal design with sophisticated technology to make the web faster, safer, and easier. Use one box for everything--type in the address bar and get suggestions for both search and Web pages. Thumbnails of your top sites let you access your favorite pages instantly with lightning speed from any new tab. Desktop shortcuts allow you to launch your favorite Web apps straight from your desktop. Chrome has many useful features built in, including automatic full-page translation and access to thousands of apps, extensions, and themes from the Chrome Web Store. Google Chrome is one of the best solutions for Internet browsing giving you high level of security, speed and great features. Important to know! The offline installer links do not include the automatic update feature. Download web installer: Google Chrome Web 32-bit | Google Chrome 64-bit | Freeware Download: Google Chrome Offline Installer 64-bit | Direct Link | 131.0 MB Download: Google Chrome Offline Installer 32-bit | Direct Link | 119.0 MB Download page: Google Chrome Portable Download: Chrome ARM64 | Direct Link View: Chrome Website | Release Notes Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Oh, it's happening on more than one dialog? This is the dialog that I'm unable to interact with.
    • WSCC - Windows System Control Center 10.0.3.8 by Razvan Serea Windows System Control Center is a free, portable program that allows you to install, update, execute and organize the utilities from various system utility suites. WSCC can install and update the supported utilities automatically. Alternatively, WSCC can use the http protocol to download and run the programs. WSCC is portable, installation is not required. Extract the content of the downloaded zip archive to any directory on your computer. Free for personal use. The setup packages and updates are downloaded directly from their author's website! This edition of WSCC supports the following utility suites: Windows Sysinternals Suite (including support for "Sysinternals Live" service) NirSoft Utilities Mitec and more... WSCC - Windows System Control Center 10.0.3.8 changelog: [NEW] update progress is now visible on the Windows taskbar [FIXED] fixed an issue with the Update dialog [FIXED] minor fixes Download: WSCC (64-bit) | 5.4 MB (Free for personal use) Download: WSCC (32-bit) | 6.3 MB View: WSCC Homepage | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • One Month Later
      Clizby earned a badge
      One Month Later
    • One Month Later
      Timaximus earned a badge
      One Month Later
    • Week One Done
      Timaximus earned a badge
      Week One Done
    • Rookie
      FBSPL went up a rank
      Rookie
    • First Post
      davidbazooked earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      491
    2. 2
      PsYcHoKiLLa
      170
    3. 3
      +Edouard
      164
    4. 4
      Steven P.
      85
    5. 5
      ATLien_0
      76
  • Tell a friend

    Love Neowin? Tell a friend!