[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

    • Same, never saw it on Android or iOS. Guess only some people got it *shrugs*
    • Anthropic pulls Fable 5 and Mythos 5 after US export control order by Pradeep Viswanathan In April this year, Anthropic launched the Claude Mythos Preview frontier model with state-of-the-art cyber and coding capabilities for a select set of companies around the world. After preparing appropriate guardrails, early this week, Anthropic launched Claude Fable 5 and Mythos 5, its most capable AI models. Claude Fable 5 is for general users and comes with strict safeguards, while Mythos 5 is designed with fewer safeguards for cybersecurity and biology use cases. Today, Anthropic abruptly suspended access to its Fable 5 and Mythos 5 AI models for all customers after receiving an export control directive from the US government. The company received the directive from the government today at 5:21 p.m. ET, and the received letter did not provide any details regarding the national security concern. Anthropic understands that the government became aware of a method to bypass, or “jailbreak,” Fable 5, which might be the reason behind the directive. The order was issued under national security authorities and requires the company to suspend all access to Fable 5 and Mythos 5 by any foreign national, whether they are inside or outside the United States. The restriction also applies to foreign national employees working at Anthropic. As a result, the company has disabled both models for all customers to ensure compliance. Access to previous Anthropic models like Opus and Sonnet is not affected by this government order. The company highlighted that it had developed strong safeguards to reduce the possibility that Fable is misused for tasks related to cybersecurity. In fact, many developers are complaining that the safeguards are going overboard. Additionally, the company worked with the US government, the UK AISI, multiple private third-party organizations, and internal teams to red-team Fable’s safeguards for thousands of hours. Finally, Anthropic noted that no testers have yet been able to find a universal jailbreak on Fable 5. As expected, Anthropic disagrees that a narrow potential jailbreak should lead to the recall of a commercial model used by hundreds of millions of people. It warned that applying this standard across the AI industry could effectively halt new frontier model deployments. Anthropic concluded by mentioning that it is working to restore access to Fable 5 and Mythos 5 as soon as possible and plans to share more details within the next 24 hours.
    • Brave Browser 1.91.172 is out.
    • Any Video Converter Free 9.2.3 by Razvan Serea Any Video Converter is an All-in-One video converting tool with an easy-to-use graphical interface, fast converting speed and excellent video quality. Any Video Converter supports all popular video formats and converts your videos to different video formats including MP4, MOV, MKV, M2TS, M4V, MPEG, AVI, WMV, ASF, OGV, WEBM, and more. It supports converting videos to customized percent (50%, 100%, 200%, and more) or resolution (480p, 720p, 1080p, 4K, and more); It supports encoding videos into x264, x265, h263p, xvid, mpeg, wmv, and more. Any Video Converter Free key features: Compatible with Windows 11/10/8.1/8/7 (32-64bit) User interface are available in 14 languages Convert all kinds of video formats including high-definition videos Extract audio from any videos and save as MP3/WMA for your mp3 player Take snapshot from any videos and build your own picture collection Support high-definition for both input and output Batch add videos from hard drive and batch convert Customize output parameters completely as you like Manage your output videos files by group or output profile Merge several video files into a single and long one Clip a video into segments Free Audio Filter: Adjust audio volume and add audio effects Crop frame size to remove black bars and retain what you want only Adjust the brightness, contrast, saturation Rotate or flip or add noise/sharpen effects Produce output video with subtitles of your own dialogue and much, much more... Any Video Converter Free 9.2.3 changelog: Fixed video download engine auto-update failures. Added custom speed control support in the speed change tool. Added support for downloading YouTube AI-generated subtitles. Added support for preserving original audio stream in the format convert tool (e.g., Dolby Atmos, DTS:X). Fixed other bugs and improved overall performance. Download: Any Video Converter Free 9.2.3 | 7.6 MB (Freeware) View: Any Video Converter Free Home Page | Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • Not sure what country you’re in but in many countries you can absolutely jail the sellers behind businesses… in fact I’d say in most countries you can do that
  • Recent Achievements

    • Contributor
      MarkHughes4096 went up a rank
      Contributor
    • Dedicated
      jordanspringer earned a badge
      Dedicated
    • Rookie
      Rimplesnort went up a rank
      Rookie
    • One Year In
      Markus94287 earned a badge
      One Year In
    • One Month Later
      Markus94287 earned a badge
      One Month Later
  • Popular Contributors

    1. 1
      +primortal
      507
    2. 2
      +Edouard
      176
    3. 3
      PsYcHoKiLLa
      148
    4. 4
      ATLien_0
      92
    5. 5
      Steven P.
      79
  • Tell a friend

    Love Neowin? Tell a friend!