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

    • Crazy. The government fired everyone who was capable of actually understanding this. More security theater. Just checked it is gone from Claude.
    • bring trump to the board, then apple will have some innovation to talk about
    • Microsoft released Windows 11 KB5094149 / KB5095971 / KB5094156 Setup, Recovery updates by Sayan Sen Earlier this week Microsoft released its newest Patch Tuesday updates (KB5094126 / KB5093998 on Windows 11 and KB5094127 on Windows 10). Alongside those, Microsoft also released new dynamic updates. These Dynamic Update packages are meant to be applied to existing Windows images prior to their deployment. Dynamic Updates also help preserve Language Pack (LP) and Features on Demand (FODs) content during the upgrade process. VBScript, for example, is currently an FOD on Windows 11 24H2. This time both recovery and setup updates were released for Windows 11 as well as Windows 10. The company writes: "KB5095185: Safe OS Dynamic Update for Windows 11, version 26H1: June 9, 2026 This update makes improvements to the Windows recovery environment (WinRE). After installing this update, the WinRE version installed on the device should be 10.0.28000.2269. KB5094149: Safe OS Dynamic Update for Windows 11, versions 24H2 and 25H2: June 9, 2026 This update makes improvements to the Windows recovery environment (WinRE). After installing this update, the WinRE version installed on the device should be 10.0.26100.8655 KB5095971: Setup Dynamic Update for Windows 11, version 23H2: June 9, 2026 This update makes improvements to Windows setup binaries or any files that setup uses for feature updates in Windows 11, version 23H2. KB5094156: Safe OS Dynamic Update for Windows 11, version 23H2: June 9, 2026 This update makes improvements to the Windows recovery environment (WinRE). After installing this update, the WinRE version installed on the device should be 10.0.22621.7219 KB5098815: Windows Recovery Environment update for Windows 10, version 21H2 and 22H2: June 9, 2026 This update automatically applies Safe OS Dynamic Update (KB5094154) to the Windows Recovery Environment (WinRE) on a running PC. The update installs improvements to Windows recovery features. KB5094154: Safe OS Dynamic Update for Windows 10, versions 21H2 and 22H2: June 9, 2026 This update makes improvements to the Windows recovery environment (WinRE). After installing this update, the WinRE version installed on the device should be 10.0.19041.7417. KB5094153: Safe OS Dynamic Update for Windows 10, version 1809 and Windows Server 2019: June 9, 2026 This update makes improvements to the Windows recovery environment (WinRE). After installing this update, the WinRE version installed on the device should be 10.0.17763.8880. KB5094152: Safe OS Dynamic Update for Windows 10, version 1607 and Windows Server 2016: June 9, 2026 This update makes improvements to the Windows recovery environment (WinRE). After installing this update, the WinRE version installed on the device should be 10.0.14393.9234." Microsoft notes that both the Recovery and Setup updates will be downloaded and installed automatically via the Windows Update channel.
    • Quantum Error Correction Validated in Nature: Microsoft and Quantinuum Log 800-Fold Improvement Two years after the original press-release announcement, independently peer-reviewed results published in Nature on June 10, 2026, have confirmed that Microsoft and Quantinuum achieved an 800-fold reduction in quantum error rates on real trapped-ion hardware — the largest gap between physical and logical error rates ever independently validated.    What Quantum Error Correction Actually Does — and Why Breaking Even Is Hard https://www.techtimes.com/articles/318329/20260613/quantum-error-correction-validated-nature-microsoft-quantinuum-log-800-fold-improvement.htm   Quantum Computing Wiring Bottleneck Cracked by HKU Silicon Carbide Chip at Qubit Temperature Engineers at the University of Hong Kong have built the first cryogenic control chip that operates at the same temperature as superconducting qubits — 10 millikelvin, or just one-hundredth of a degree above absolute zero — without generating the heat that has forced every competing approach to park its electronics hundreds of meters of cable away. https://www.techtimes.com/articles/318325/20260613/quantum-computing-wiring-bottleneck-cracked-hku-silicon-carbide-chip-qubit-temperature.htm  
    • RevPDF 4.5.0 by Razvan Serea RevPDF is a free, fully offline PDF editor for Windows, macOS, and Linux that lets you edit text and images directly inside PDF files — no internet connection, no account, and no cloud uploads required. Unlike bloated alternatives that demand subscriptions and constant connectivity, RevPDF fits in under 60MB on desktop while delivering a complete editing toolkit: annotate, redact, sign, compress, split, merge, convert, and reorganize pages, all processed locally on your device. Smart font matching ensures edited text blends seamlessly with the original, and multi-language support includes RTL scripts such as Arabic and Hebrew. Where most PDF editors force you to choose between features and simplicity, RevPDF manages both. You can build interactive forms from scratch with text fields, checkboxes, and dropdowns, permanently redact sensitive data before sharing, draw freehand on contracts and diagrams, and add custom watermarks — all without a single file leaving your machine. Edit Text and Images Directly Inside PDFs RevPDF supports true inline PDF editing — not just annotation layers on top of a document, but actual modification of existing text and images within the file. A smart font-matching engine identifies the font used in the original document and applies it automatically when you make edits, so changes blend naturally with the surrounding content. You can reposition elements, resize images, and update text across single pages or entire documents. RevPDF 4.5.0 release notes: This is one of the biggest updates to RevPDF yet. A lot of things people have been asking for are finally here. New Features Auto Redaction Permanently redact sensitive text and areas from your PDFs before sharing. Clean, irreversible, and fully offline. Comments, Links & Bookmarks Add comments for review, insert clickable links, and create bookmarks to jump around long documents without scrolling forever. Find & Replace Search across the whole document and replace text in one go. Long overdue. Split Pages Vertically or Horizontally Split any page down the middle, vertically or horizontally. Perfect for scanned books or double-page spreads. New Drawing Tools More tools for freehand drawing and markup, better for annotations, sketches, and detailed notes. Continuous Scrolling in Editor The editor now scrolls continuously through pages instead of jumping between them. Working through long documents is a lot smoother now. PDF Metadata Editor View and edit the metadata stored inside your PDFs, including title, author, subject, and keywords. Better Font Matching Text edits now blend in more naturally by doing a better job of matching the original font. Tabbed PDF Viewer Open multiple PDFs at once in tabs and switch between them without going back to the home screen. Add Links Insert hyperlinks anywhere in your PDF, to external URLs or to other pages within the document. Share & Print Shortcuts Share or print directly from the editing screen, home screen, and viewer. No extra steps. Minor Updates Paste images directly from clipboard into your PDF New image editing tools for more control over images inside documents Bug Fixes Fixed file saving issues on Windows and Linux Everything still works fully offline. No login, no cloud, no account. Your files stay on your device. Download: RevPDF 4.5.0 | 58.0 MB (Open Source) Links: RevPDF Home Page | Github | Screenshots 1 | 2 Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • Week One Done
      agatameier earned a badge
      Week One Done
    • One Month Later
      agatameier earned a badge
      One Month Later
    • Week One Done
      ssd21345 earned a badge
      Week One Done
    • Contributor
      MarkHughes4096 went up a rank
      Contributor
    • Dedicated
      jordanspringer earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      508
    2. 2
      +Edouard
      175
    3. 3
      PsYcHoKiLLa
      139
    4. 4
      ATLien_0
      91
    5. 5
      Steven P.
      76
  • Tell a friend

    Love Neowin? Tell a friend!