# Making my kernel a bit leaner

## Shining Arcanine

Lately, I have been stripping unused functionality from my kernel to make it a bit leaner. So far, I think I have stripped everything from it I could in terms of drivers. I believe I have narrowed my list of possibly unneeded features to three things:

"Auditing Support" under "General Setup"

"Initial RAM filesystem and RAM disk (initramfs/initrd) support" under "General Setup"

"kexec system call" under "Professor type and features"I do not use SELinux. I use sys-boot/grub-0.97-r9 as my bootloader, so I am not sure if I need "Initial RAM filesystem and RAM disk (initramfs/initrd) support". They seem safe enough to remove, but I am not 100% sure, so I am asking here. Are these features needed for anything important or are they safe to remove?

----------

## bjlockie

 *Shining Arcanine wrote:*   

> Lately, I have been stripping unused functionality from my kernel to make it a bit leaner. So far, I think I have stripped everything from it I could in terms of drivers. I believe I have narrowed my list of possibly unneeded features to three things:
> 
> "Auditing Support" under "General Setup"
> 
> "Initial RAM filesystem and RAM disk (initramfs/initrd) support" under "General Setup"
> ...

 

I removed auditing and kexec but I'm not sure about initramfs either.

You can always remove it and try it.

You may have to boot off a live cd and chroot to fix it if it doesn't work.

----------

## timeBandit

I have auditing enabled because I planned to play with SELinux "someday." I don't think it is otherwise needed. 

You need initramfs/initrd support if you use gensplash (splashutils). If not, and if there are no initrd statements in your GRUB configuration, you shouldn't need it.

 *Kernel config help wrote:*   

> kexec is a system call that implements the ability to shutdown your current kernel, and to start another kernel.  It is like a reboot but it is independent of the system firmware. And like a reboot you can start any kernel with it, not just Linux.

 This is one of those "if you don't know what it means, you probably don't need it" options (or it should be). It isn't needed for normal reboots. It is necessary if you want to mess around with crash dump kernels. Otherwise, you can do without it.

----------

## Shining Arcanine

Thankyou for the information. I disabled those three without any issue. I also found a bunch of stuff for having my computer function as a proxy/router among other things I did not need, so I disabled them. It seems I keep finding stuff that I can strip out of the kernel.

I hate to ask about more things, as I said I thought those were all of my questions, but I noticed there are a few more things that I had seen in the past, but ignored because their descriptions worried me:

"Strip assembler-generated symbols during link" in "General setup"

"MTRR (Memory Type Range Register) support" in "Processor type and features"

"Sysctl checks" in "Kernel hacking"

I am not sure if checking the feature to strip assembler-generated symbols is a good idea because I do not know what assembler generated symbols are. Hopefully, I will know next semester when I take my university's compiler course, but until then, I know nothing about them. My laptop has a PCI Express video card, so from the description I would think I do not need MTRR, but the description seems somewhat ambigious, so I am not sure about it. Lastly, "Sysctl checks" seem unnecessary, but the description is really scary, so I am afraid to touch it.

So far, my kernel is down to about 12k uncompressed and is under 2.6k compressed and the time between its startup procedure and userland has been reduced from about 1.25 seconds to about 0.71 seconds, which I find to be really exciting. I am curious how close I can get to the size and performance of an embedded kernel while having a full fledged laptop.

----------

## Jaglover

You need MTRR for Xorg video.

----------

## bjlockie

 *Shining Arcanine wrote:*   

> 
> 
> "Strip assembler-generated symbols during link" in "General setup"
> 
> "Sysctl checks" in "Kernel hacking"
> ...

 

Get rid of both unless you want to debug the kernel.  :Smile: 

----------

## Spidey

I discovered some time ago that if you check EMBEDDED new settings, despite those in the EMBEDDED group, get listed everywhere else in the menuconfig interface.

----------

## Shining Arcanine

 *Spidey wrote:*   

> I discovered some time ago that if you check EMBEDDED new settings, despite those in the EMBEDDED group, get listed everywhere else in the menuconfig interface.

 

Well, I am not actually checking the embedded settings. I am just trying to get the kernel size and performance to the level of an embedded kernel for fun. I decided to go nuts and set everything that was not explicitly required to boot to be compiled as a module. Now the compressed kernel size is 1.78MB so I doubt it will get much faster than that.

Anyway, the stop watch times for my system boot have decreased from 16.95 to 13.73, so there is a definite improvement. It takes less time to get the kernel into memory, less time to decompress the kernel and less time to reach userland (about 0.5 seconds) after the kernel is decompressed. In addition, the stuff I do not use is not loaded and the stuff I do use is loaded while the system boots. Putting everything not explicitly needed for the boot process into modules also reduced system memory usage by about 5MB to 10MB after a fresh boot.

I do not think my kernel can get much leaner than this. I think that I am at the point where either disabling something will either break something or remove a module that was not being loaded anyway.

----------

