Jump to content

10 easy steps to compiling your kernel


Recommended Posts

This is NOT for 2.6.X. There is a README in /usr/src/linux that contains these instructions in much more detail. I am using using the 2.4.24 kernel as an example. If you have not already done so, download your kernel source and install it in /usr/src.

 

1. cd /usr/src/linux (if /usr/src/linux doesnt exist, create a link from /usr/src/linux-2.4.24 to /usr/src/linux with the command ln -s /usr/src/linux-2.4.24 /usr/src/linux )

 

2. make distclean (this sets the source package back to the default)

 

3. edit your makefile. change the EXTRAVERSION = on the forth line to an extension that will identify this new kernel build. ex. "EXTRAVERSION = -custom-1". if you are using pico or nano as your editor, be sure to include the "-w" option to turn off line wrap or you will trash your makefile.

 

If this is a stock kernel and you have never built a kernel before, Redhat supplies config files that match their precompiled kernels in /usr/src/linux/config. Pick the one that matches your hardware and copy the provided config into /usr/src/linux/.config. If you are not using Redhat, your going to have to wing it. :-)

 

4. make mrproper menuconfig use the menuconfig to set the options you want in your kernel. If you are reading this as a guide, then you are probably not very experienced in building kernels. A suggestion would be to make small changes, compile and install the kernel and make sure it works before you start making major changes.

 

5. make bzImage modules modules_install This will take some time to complete. Have a cup of coffee.

 

6. cp /usr/src/linux/arch/i386/boot/bzImage /boot/bzImage-2.4.24-custom-1

 

7. cp /usr/src/linux/System.map /boot/System.map-2.4.24-custom-1

 

8. cp /usr/src/linux/.config /boot/config-2.4.24-custom-1 This is not required, but it is sometimes handy to be able to get back to the config you used to create a kernel. This puts it in a safe place and its name matches it to the kernel you just built.

 

cd /boot

 

9. mkinitrd initrd-2.4.24-custom-1 2.4.24-custom-1

 

10 edit /boot/grub/grub.conf (remember to use "-w" if you are using nano or pico)

create a new entry for your new kernel.

 

title=2.4.24-custom-1

root (hd0,0)

kernel (hd0,0)/bzImage-2.4.24-custom-1 ro root=/dev/hda6

initrd (hd0,0)/initrd-2.4.24-custom-1

 

NOTE: in this case, my /boot partition is /dev/hda1 and my / (root) partition is /dev/hda6. Yours is probably different. Look at the other entries in your grub.conf and make the entries look the same.

 

g'luck

Link to post
Share on other sites
  • 2 months later...

What i dont get is, why do people still cp the bzImage over, when you dont have to.. if you do everything in this order

 

make menuconfig

make dep

make bzImage

make clean

make modules

make modules_install

make install

 

then, simply reboot. if you read the Makefile, you'll notice that "make install" copies everything into the right location, and if your using grub, it even fills out grub for you..

 

just a tip. :) i found P38's expanded way a bit more confusing for newer users.

 

FluKex

Link to post
Share on other sites

for 2.6, it was even easier....

 

 

 

make menuconfig (if you have a /boot/config-ver.sion and the version matches the current running kernel, make menuconfig will do most of the config for you)

 

then in menuconfig, change any specific options you want, save

 

then,

make

make modules

make modules_install

make install

 

DONE.

 

easy as pie,

Link to post
Share on other sites
  • 1 month later...
  • 10 months later...

Would this be an appropriate place to ask about WHY you would compile your own kernel from source? I always wonder.

 

What are the advantages?

 

 

Are there things you can do during install that you can't otherwise?

 

What are some of those things?

 

Finally, if I ever try this, are there going to be some technical decisions to make as it is compiling that might be over my head or does it take care of itself once you've done the above?

 

Just curious.

Link to post
Share on other sites
Would this be an appropriate place to ask about WHY you would compile your own kernel from source? I always wonder.

 

What are the advantages?

 

 

Are there things you can do during install that you can't otherwise?

 

What are some of those things?

 

Finally, if I ever try this, are there going to be some technical decisions to make as it is compiling that might be over my head or does it take care of itself once you've done the above?

 

Just curious.

 

Compiling your own kernel has many advantages. Compile a kernel from source

allows you to compile code for devices that currently are not in the precompiled kernels.

 

Compiling a kernel also allows you to select new feature from the kernel such

as loopback encryption, Also tools for monitoring your power supply and you can

enable in 2.6x kernel NTFS file writing :)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...