[HOW-TO] Recompiling kernel


Recommended Posts

Part 1

In the bowls of your /usr/src directory you will find your kernel source in the /linux dir. Most often it's a symlink to another dir that has the linux verson number attached.

For starters lets become root and enter the dir. I'll show you what I have

bash-2.05$ su
Password:
bash-2.05# cd /usr/src/
bash-2.05# ls -la
total 64192
drwxr-xr-x    9 root     root         4096 Jul 13 15:43 .
drwxr-xr-x   19 root     root         4096 Jun 26 15:48 ..
lrwxrwxrwx    1 root     root           12 Oct  7  2002 linux -> linux-2.4.18
drwxr-xr-x   14 1046     console      4096 Sep  1  2002 linux-2.4.15
drwxr-xr-x   14 573      573          4096 Apr 27 15:55 linux-2.4.18
-rw-------    1 root     root     30108170 Oct  7  2002 linux-2.4.18.tar.gz
drwxr-xr-x   14 root     root         4096 Aug 31  2002 linux-2.4.5
drwxr-xr-x    7 root     root         4096 May 29  2001 rpm

now you can see that I have three kernels floating on my HD. 2.4.5 2.4.15, adn 2.4.18. The linux link is pointing to 2.4.18, my current running kenrel

bash-2.05# uname -a
Linux naru 2.4.18 #5 Fri Jan 10 01:59:23 CST 2003 i686 unknown

Now before we do *ANYTHING* we will want to copy the current kernel config from the current kernel dir. This will make a backup of you config in case anything goes funny. Also we can use it for the new kernel we will be getting. It makes upgrading much less of a pain.

bash-2.05# cp linux/.config .

You can list the contents of the .config file, and you can see what it currently configured on your system. Now what we do is download a new kernel from kernel.org or your favorite mirror.

If you don't know how to download a tarball, you shouldn't be compiling a kenrel

Let look at my dir now.

bash-2.05# ls -la
total 64192
drwxr-xr-x    9 root     root         4096 Jul 13 15:43 .
drwxr-xr-x   19 root     root         4096 Jun 26 15:48 ..
-rw-r--r--    1 root     root        31560 Jul 13 15:42 .config
lrwxrwxrwx    1 root     root           12 Oct  7  2002 linux -> linux-2.4.18
drwxr-xr-x   14 1046     console      4096 Sep  1  2002 linux-2.4.15
drwxr-xr-x   14 573      573          4096 Apr 27 15:55 linux-2.4.18
-rw-------    1 root     root     30108170 Oct  7  2002 linux-2.4.18.tar.gz
-rw-------    1 halkun   users    35475346 Jul 13 15:42 linux-2.4.21.tar.gz
drwxr-xr-x   14 root     root         4096 Aug 31  2002 linux-2.4.5
drwxr-xr-x    7 root     root         4096 May 29  2001 rpm

Ok, we have the kernel, now let's nuke the old linux symlink. After we do that we untar the new kernel and make a new symlink that points to that.

bash-2.05# rm linux
bash-2.05# tar -xvzf linux-2.4.21.tar.gz
............(it uncompresses)............
bash-2.05# ln -s linux-2.4.21 linux

Let's do a dir again, just to make sure everything is spiffy

bash-2.05# ls -la
total 64196
drwxr-xr-x   10 root     root         4096 Jul 13 16:04 .
drwxr-xr-x   19 root     root         4096 Jun 26 15:48 ..
-rw-r--r--    1 root     root        31560 Jul 13 15:54 .config
lrwxrwxrwx    1 root     root           12 Jul 13 16:04 linux -> linux-2.4.21
drwxr-xr-x   14 1046     console      4096 Sep  1  2002 linux-2.4.15
drwxr-xr-x   14 573      573          4096 Apr 27 15:55 linux-2.4.18
-rw-------    1 root     root     30108170 Oct  7  2002 linux-2.4.18.tar.gz
drwxr-xr-x   12 root     root         4096 Jul 13 16:04 linux-2.4.21
-rw-------    1 halkun   users    35475346 Jul 13 15:42 linux-2.4.21.tar.gz
drwxr-xr-x   14 root     root         4096 Aug 31  2002 linux-2.4.5
drwxr-xr-x    7 root     root         4096 May 29  2001 rpm

Yup, it's pointing to the new kernel now, so let copy out old config in there and then get out fingers really dirty by going in!

bash-2.05# cp .config linux
bash-2.05# cd linux

Part 2

Ok, now we need to set up and compile the puppy. The first thing you should do is run a config program. What this will do is read in your .config and set up everything.

Now what I would do, as this was just a dry run, is simply let it parse the .config and then save it. This will update the .config with any new items that the new kernal has, compleating it. It will also keep our original config intact.

bash-2.05# make menuconfig
(press alt-E to exit, it will as if you want to save your new kernel configuration. Say yes)

Now that we have a config, we need to clean it all up and compile it out

bash-2.05# make dep
(...works for a bit and it creates some stuff....)

bash-2.05# make modules
(...works a bit more, makes all the loadable modules...)

bash-2.05# make modules_install
(...copies all the modules into a new /lib/modules/2.4.21 dir)

bash-2.05# make bzImage
(...go get a sandwich, wash the car, and come to Maine to visit. It may be done by the time you get back...)

Now you will have a compiled kernel. The last bit is getting it to boot.

Part 3

Now that we have a kernel lets grab it, let the bootloader know about it, and then do a reboot.

The kernel (bzImage) is tucked away in /usr/src/linux/arch/i386/boot. We need to put that in a more appropoate place and rename it as to not to cause confusion. It should go in your /boot dir.

bash-2.05# cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImage-2.4.21

Now you need to copy your system map so the new kernel can find functions within iteslf correctly.

bash-2.05# cp System*.map* /boot/

Now that that's done, let's config lilo, so the bootloader knows about the new kernel. This requres a littel know-how, not bad though. Everyone's lilo config is diffrent, but's it easy to navigate.

You are going to want to add these lines at the bottom

     image=/boot/bzImage-2.4.21
      label=newkernel
      root=/dev/hda1
      read-only

also make sure that there are these lines in there

prompt
timeout 50

the number after timeout is how many tenths of a second to wait for imput, it's set here to 5 seconds. Also make a note of what you old kernel's name is. You may need to boot back into that.

then RUN LILO

bash-2.05# lilo

that will tell you what kernels are installed and any updates will have a star before them

*newkernel

Now what you do next is cross your fingers, reboot, and at the lilo prompt type "newkernel" That should boot up your new kenrel!

If something goes wrong No worries! You can just put in the other kenel's label (usally "Linux" by default) and it will load the old one like nothing ever happened. Then you can fix what went wrong where.

That's it. I hope I was a help.

  • 2 weeks later...
  • 2 months later...

A module is something built into a file seperate from the kernel, useful for when you need support for something but you only need to use it occasionally - keeps the kernel a little smaller. Don't build support for your root file system as a module for instance ;)

A module is something built into a file seperate from the kernel, useful for when you need support for something but you only need to use it occasionally - keeps the kernel a little smaller. Don't build support for your root file system as a module for instance ;)

then support for ext3 should be set built-in for better perfomance.

i guess my hardware like my videocard should be set built-in too, right?

thanks

support for your filesystem should be built in so you know it works. This isn't true for modules for your vidcard, usb, etc. There are a few essential modules that should be compiled in, while most parts can just be modules. Normally you won't notice any difference in performance between modules and compiled in parts, however some people do. You just got to experiment.

  • 9 months later...
  • 1 month later...
Can anyone post a guide that actually works and is relevant for the 2.6 kernal?  I've followed all the steps in the initial post, and I'm still using 2.4...

585374426[/snapback]

Theoretically this guide will work with a 2.6 kernel. I'm aware this reply is late considering you posted in Jan '05 - but I'm just getting back into Linux.

I will try this guide out on the 2.6.11 kernel once FC3 is completely installed (had to wipe because I screwed it up by playing). As soon as it's complete I'll come back here and let ya'all know.

Theoretically this guide will work with a 2.6 kernel. I'm aware this reply is late considering you posted in Jan '05 - but I'm just getting back into Linux.

I will try this guide out on the 2.6.11 kernel once FC3 is completely installed (had to wipe because I screwed it up by playing). As soon as it's complete I'll come back here and let ya'all know.

585566114[/snapback]

That's ok, I know how to compile a kernel....that post is very old heh, and the very same day I knew how to compile completely :) However...a lot of those commands are now deprecated with the new kernel...

Well, I couldn't get it to work - everytime I bunzipped that .bz2 file, I was left with a single file where I couldn't do anything with it.

I ended up downloading the rpm of 2.6.10 - which installed fine. Give it a couple of weeks (hopefully) and 2.6.11 will be available in rpm format :)

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

    • No registered users viewing this page.
  • Posts

    • Because of the EU (a good thing) newer android devices been getting 5 years worth of security patches. Except some Motorola which found the loop hole, and offer ZERO updates. In addition, Google for years have been making where it can patch some stuff by updating the core Google Play Store itself.  As echoed earlier,  you take the security risk in to your own hand beyond supported.
    • Win11Debloat 06.11.2026 by Razvan Serea Win11Debloat is a lightweight, easy to use PowerShell script that allows you to quickly declutter and customize your Windows experience. It can remove pre-installed bloatware apps, disable telemetry, remove intrusive interface elements and much more. The script also includes many features that system administrators and power users will enjoy. Such as a powerful command-line interface, support for Windows Audit mode and the option to make changes to other Windows users. All changes made by Win11Debloat can be easily reversed, and most removed apps can be restored via the Microsoft Store. A full guide on how to undo the changes is available here. Win11Debloat features: Below is an overview of the key features and functionality offered by Win11Debloat. Please refer to the wiki for more information about the default settings preset. Remove a wide variety of preinstalled apps. Click here for more info. Disable telemetry, diagnostic data, activity history, app-launch tracking & targeted ads. Disable tips, tricks, suggestions & ads across Windows. Disable Windows location services & app location access. Disable Find My Device location tracking. Disable 'Windows Spotlight' and tips & tricks on the lock screen. Disable 'Windows Spotlight' desktop background option. Disable ads, suggestions and the MSN news feed in Microsoft Edge. Hide Microsoft 365 ads on the Settings 'Home' page, or hide the 'Home' page entirely. Disable & remove Microsoft Copilot. Disable Windows Recall. Disable Click to Do, AI text & image analysis tool. Prevent AI service (WSAIFabricSvc) from starting automatically. Disable AI Features in Edge. Disable AI Features in Paint. Disable AI Features in Notepad. Disable the Drag Tray for sharing & moving files. Restore the old Windows 10 style context menu. Turn off Enhance Pointer Precision, also known as mouse acceleration. Disable the Sticky Keys keyboard shortcut. Disable Storage Sense automatic disk cleanup. Disable fast start-up to ensure a full shutdown. ...and more. Once you’ve downloaded the Win11Debloat file (Get.ps1), just follow these quick steps: Locate the Get.ps1 script file. Right-click the file and select Run with PowerShell from the context menu. If prompted by User Account Control (UAC), select Yes to grant the script the necessary administrative permissions. Win11Debloat 06.11.2026 fixes: Fix lock screen spotlight option being disabled when disabling the start recommended section by @Raphire in #619 Fix log message formatting by @Raphire Note The -RemoveCommApps and -RemoveW11Outlook command-line parameters for uninstalling a few specific apps have been removed with this release. If you previously relied on these parameters, please see this wiki page for alternative methods of removing these apps. Download: Win11Debloat 06.11.2026 | Open Source View: Win11Debloat Home Page | Screenshots 1| 2 Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Yes for me, I installed 'old calculator' (Windows 7 calculator) in its place since it is more useful to me. I think paint is the only one I left installed
  • Recent Achievements

    • Rookie
      restore went up a rank
      Rookie
    • Very Popular
      AndrewSteel earned a badge
      Very Popular
    • Veteran
      Taliseian went up a rank
      Veteran
    • One Month Later
      Clizby earned a badge
      One Month Later
    • One Month Later
      Timaximus earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      501
    2. 2
      +Edouard
      162
    3. 3
      PsYcHoKiLLa
      154
    4. 4
      ATLien_0
      83
    5. 5
      Steven P.
      79
  • Tell a friend

    Love Neowin? Tell a friend!