[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

    • Umm, read my answer again! If you have something to add or contribute, feel free. Otherwise my point was that you apparently dont want faster updates... so you want slower updates by process of elimination. If you have something to contribute, meaningful answers are better.
    • These features described above are good, but far from what developers will like the most. The main feature that developers will care and love the most it's called "Bring Your Own Models". It gives us the ability to connect to LOCAL AI models running on Ollama. The feature it's located on GitHub Copilot tab -> On the model picker where you can select "manage models" instead of paid models and then it will show you the "Bring your own models" window where you can now select Ollama and the endpoint of your local server. So if you have a beefy spec machine you can now use your own model 100% local inside Visual Studio 2026 18.7.0
    • Microsoft Teams is getting a controversial location tracking feature that users may hate by Usama Jawad Image generated with Microsoft Copilot Earlier this year, Microsoft planned to roll out a controversial location tracking feature in Teams, but following customer feedback, it decided to delay its release. The bad news is that the company has decided to launch it later this year, but it's based on roughly the same design that was shared earlier, which means that many users still have good reason to worry. Basically, Microsoft Places and Teams have received workplace check-ins via Wi-Fi. The idea is that if an employee arrives at the office and connects to their enterprise network, their profile status indicator will show them as being present in the office. For example, if you arrive at work, open Teams on your PC, and connect to the "Studio B" company Wi-Fi network, your Teams profile will indicate that you are present in "Studio B", as shown below: Microsoft says that this feature is basically a replacement for physical workplace check-in peripherals, it reduces the need to manually update your status, and it also enables co-workers to know that you're at work so that they can coordinate in-person meetings with you. IT admins can enable this workplace check-in capability at a tenant level, and users have the ability to control whether they want to enable it or not. Of course, all of that sounds great on paper, but naturally, many Teams customers may still have concerns, as they did before. This is because it enables your reporting manager and other members of the organization to track if you are at the office, when you arrive at the office, and where you are right now. This could be problematic for people who work in what they consider to be flexible work environments or hybrid setups, and this kind of location tracking could be considered an invasion of privacy. Microsoft has tried to alleviate some of these concerns by letting users know that they can manually set their location easily, which essentially overrides workplace check-in if they feel uncomfortable with it. However, that doesn't really solve the problem because your organization could enforce a workplace policy that mandates that this feature remains enabled. The Redmond tech giant has also assured users that this capability does not store historical data and is only a real-time indicator of location. Finally, it only generates a signal when you connect to a corporate network, which means that if you are working from home and connect your PC to your personal Wi-Fi, it won't broadcast your location to your employer; you will simply be shown as "Remote". Microsoft has encouraged IT admins to prepare for this change and begin informing users so they know what to expect once it begins rolling out later this year.
  • Recent Achievements

    • 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
    • Week One Done
      Timaximus earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      516
    2. 2
      +Edouard
      162
    3. 3
      PsYcHoKiLLa
      157
    4. 4
      Steven P.
      82
    5. 5
      ATLien_0
      81
  • Tell a friend

    Love Neowin? Tell a friend!