# (sensibly) cleaning out the kernel

## Uncle_Psychosis

Hi guys

Yesterday I had to update my kernel to fix a problem and it dawned on me that my exisiting kernel is full of junk that never gets used. I'm sure that I have loads of built in modules and so on for hardware that I don't have, features that I've never used, and so on. 

Basically, I want to clear it out, but sensibly. Is there a sensible way to do some kind of sanity check before I remove something from the kernel?

Basically, what I would like to do is this:

1. go through menuconfig.

2. when I find something that I don't think I need, check whether or not my system is actually using it (lsmod? lspci? anything else??).

3. If not, remove it. 

I'd prefer to minimise the number of times I have to reboot in order to do this (clearly one way to do this would be to remove one thing at a time and see what breaks or doesn't on a reboot but that would be a real pain!) 

Finally, if something is marked as deprecated in the kernel is it (generally) safe to remove it?

----------

## Bill Cosby

 *Uncle_Psychosis wrote:*   

> lsmod? lspci? anything else??

 

dmesg, the Internet and your hardware manual.

 *Uncle_Psychosis wrote:*   

> Finally, if something is marked as deprecated in the kernel is it (generally) safe to remove it?

 

If you use a recent userland then usually yes.

I have no legacy or deprecated stuff enabled in my kernel, and it is doing fine.

As a general rule, for drivers I remove what I do not know about, for system features I do it the other way around, I only remove where I know I don't need it  :Smile: 

Good luck.

----------

## Nacon

 *Quote:*   

> I'm sure that I have loads of built in modules and so on for hardware that I don't have, features that I've never used, and so on. 

 

Basically you need the following:

    * http://kernel-seeds.org (Awesome starting point)

    * http://kmuto.jp/debian/hcl/ (lspci -n driver check)

With the explanations from kernel-seeds (and the <help> to the entries) you should be able to set up a kind of basic, lightweight kernel.

I just did it a few days ago for my laptop: 

    * build a lightweight kernel with the help of kernel-seeds and enable only the drivers you really need

    * reboot and check if the kernel is working correctly

    * now fine-tune your kernel by going through the settings a second time, to disable/enable drivers not covered by the kernel-seeds

If you do not know what a specific driver is actually doing, just google it! (instead of testing it by: disable -> reboot)

----------

## phajdan.jr

 *Uncle_Psychosis wrote:*   

> I'd prefer to minimise the number of times I have to reboot in order to do this (clearly one way to do this would be to remove one thing at a time and see what breaks or doesn't on a reboot but that would be a real pain!)

 

You can build most things as modules (you need the filesystem and disk controller built-in, at least for the root filesystem), reboot, and list loaded modules (lsmod). Feel free to remove anything not listed there. Then, if you want, you can change the remaining things to be built-in instead of module.

----------

