# Bloated kernel... how can I make it smaller?

## shgadwa

 *Quote:*   

> Try disabling these: 
> 
> Code:
> 
> CONFIG_RFKILL=y 
> ...

 

Any ideas? It seems that my kernel is a little bloated. I probably have at least a couple dozen things in there that I don't need, and there might even be half a dozen or so things that I do need that I don't have enabled.

Are there any good guides somewhere for configuring a kernel and disabling uneeded stuff?

----------

## xibo

hmmm... how about you need only ext3 driver if you want to mount ext3 and ext2 filesystems ( because the ext3 driver is downward comatible )... many device drivers you don't need might be enabled per default...

i used to delete /usr/src/linux/.config and then menuconfig and resetup everything, though it took alot of time and i rarely did that ( since i didn't need to often )

----------

## aCOSwt

 *belikeyeshua wrote:*   

> Are there any good guides somewhere for configuring a kernel and disabling uneeded stuff?

 

As a simple minded n00b configuring my Gentoo kernel for the first time, I loved suggestions made in the make menuconfig <help> section :

Things like :

- If you do not know what to do here say 'N'...

- If you do not understand this, say 'N'...

These comments are and wise and what has been for me the first guideline !

- Second valueable guidlines are the pappy's seeds (about which a special thread is findable under this forum)

- Third valueable guideline is... not to take pappy's advices to the letter...   :Twisted Evil: 

i.e. build as many things as possible as modules. => It will not bloat your kernel and you can easily detect if they are needed or not at run time.

For example, if you load a driver module which catches no device => then you do not need it !

- Fourth guideline (not to say the very first one...)

know your hardware...

- Fifth guideline (not to say the very very first one...) know what kind of kernel you want to achieve ! (v.g. : what are you going to do on your machine)

----------

## Leocifre

go to http://kernel-seeds.org/

over there, you can basically load a .config that has been stripped of everything you probably won't need, and of all drivers. Then you go to http://kmuto.jp/debian/hcl/ and post the output of 

```
lspci -n
```

 there. The site shows you which drivers you will need, from that you can configure them in you kernel.

----------

## StringCheesian

A quicker way to see help for an option in menuconfig is to type a question mark (?).

The online book "Linux Sea" devotes a chapter to Gentoo kernel configuration.

I found the "Recommended Linux Kernel Configurations" section in Chapter 7: Configuring a Linux Kernel helpful because it explains some of the options.

----------

## Jaglover

Whatever software you build - the first place to look is the README file (not posting on forums). How about make allnoconfig target.

Feel free to read the rest of README.   :Wink: 

```
CONFIGURING the kernel:

   Do not skip this step even if you are only upgrading one minor

   version.  New configuration options are added in each release, and

   odd problems will turn up if the configuration files are not set up

   as expected.  If you want to carry your existing configuration to a

   new version with minimal work, use "make oldconfig", which will

   only ask you for the answers to new questions.

 - Alternate configuration commands are:

        "make config"      Plain text interface.

        "make menuconfig"  Text based color menus, radiolists & dialogs.

        "make xconfig"     X windows (Qt) based configuration tool.

        "make gconfig"     X windows (Gtk) based configuration tool.

        "make oldconfig"   Default all questions based on the contents of

                           your existing ./.config file and asking about

                           new config symbols.

        "make silentoldconfig"

                           Like above, but avoids cluttering the screen

                           with questions already answered.

                           Additionally updates the dependencies.

        "make defconfig"   Create a ./.config file by using the default

                           symbol values from either arch/$ARCH/defconfig

                           or arch/$ARCH/configs/${PLATFORM}_defconfig,

                           depending on the architecture.

        "make ${PLATFORM}_defconfig"

                          Create a ./.config file by using the default

                          symbol values from

                          arch/$ARCH/configs/${PLATFORM}_defconfig.

                          Use "make help" to get a list of all available

                          platforms of your architecture.

        "make allyesconfig"

                           Create a ./.config file by setting symbol

                           values to 'y' as much as possible.

        "make allmodconfig"

                           Create a ./.config file by setting symbol

                           values to 'm' as much as possible.

        "make allnoconfig" Create a ./.config file by setting symbol

                           values to 'n' as much as possible.

        "make randconfig"  Create a ./.config file by setting symbol

                           values to random values.

   You can find more information on using the Linux kernel config tools

   in Documentation/kbuild/kconfig.txt.

        NOTES on "make config":

        - having unnecessary drivers will make the kernel bigger, and can

          under some circumstances lead to problems: probing for a

          nonexistent controller card may confuse your other controllers

        - compiling the kernel with "Processor type" set higher than 386

          will result in a kernel that does NOT work on a 386.  The

          kernel will detect this on bootup, and give up.

        - A kernel with math-emulation compiled in will still use the

          coprocessor if one is present: the math emulation will just

          never get used in that case.  The kernel will be slightly larger,

          but will work on different machines regardless of whether they

          have a math coprocessor or not. 

        - the "kernel hacking" configuration details usually result in a

          bigger or slower kernel (or both), and can even make the kernel

          less stable by configuring some routines to actively try to

          break bad code to find kernel problems (kmalloc()).  Thus you

          should probably answer 'n' to the questions for

          "development", "experimental", or "debugging" features.

```

----------

