Author Topic: Building a custom kernel  (Read 703 times)

Offline AnotherUser

  • Full Member
  • ***
  • Posts: 92
Building a custom kernel
« on: January 01, 2013, 05:44:22 PM »
The latest available kernel in the stable repos is 3.2.18. Testing has a 3.4.11, but only a non-PAE version. Due to a new piece of USB plug-able hardware which is supported in later kernels, I decided to build my own. So I started from the latest stable on kernel.org which is 3.7.1. Question 1: was this a good choice? What are the trade offs?

After unpackaging the sources, I cp /boot/config-3.2.18-pclos2.pae.bfs to .config to be used as a starting point for my configuration. Then applied the BFS patch. Then I ran make menuconfig and changed the Processor Family to be specific to my laptop (core2/newer because I have a quad code intel i5). Lastly, I enabled the specific USB device driver which I wanted and build the kernel (make -j4 && make -j4 modules_install install). I then booted into the new kernel as a sanity test. Question 2: Is this the preferred workflow for starting with a new kernel?

From here on, my questions are much more generic:
  • If I now want to tweak my kernel configuration, do I need to start from a very clean environment like: make clean distclean && \rm -f /boot/*3.7.1* && \rm -rf /lib/modules/3.7.1* or can I do an incremental build? When I tried to simply change some setting and build again (which was way faster) it did not boot.
  • What should be my strategy for optimizing this kernel build for my system? I shall never use it on any other hardware, so I feel like I should be able to achieve quite a bit of performance gain. How can I tell what should be compiled into the kernel vs compiled as a module vs not compiled at all?
  • What's the downfall of having too many modules in /lib/modules/*KERNEL-VERSION*/ directory? My build of the 3.7.1. kernel had over 80M of modules whereas the 3.2.18 and 3.4.11 kernels had about 45M.

Offline gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3801
Re: Building a custom kernel
« Reply #1 on: January 01, 2013, 05:59:58 PM »
When I build a kernel, I copy an existing PCLinuxOS .config, then go into 'make menuconfig' and change only those specific items that I know what I want them to be. I use a clean kernel each time, but I don't rely on the scripts, I just delete the unpacked source and untar the .xz. You can speed up the build with ccache. I believe it works even when you've deleted and started over, but I haven't tested the theory. I don't worry about the number of modules, although the script that builds the rpm compresses the modules. I think that it is an option in 'make menuconfig'. As far as the choice of 3.7.1 is concerned, that is a good choice if you are not interested in making livecd's with it. Our livecd's use unionfs by default, and unionfs is no longer maintained, so we need to switch to aufs. This appears to be really easy, but it will need to be tested. I am trying to get a .pae.bfs kernel for testing, but I've run into a couple of problems that need to be solved first.

Galen

Offline AnotherUser

  • Full Member
  • ***
  • Posts: 92
Re: Building a custom kernel
« Reply #2 on: January 01, 2013, 07:10:54 PM »
Thanks for the reply. I'm not concerned about making LiveCDs, so lack of UnionFS support is not a problem. I'm just curious, what kind of problems did you run into with your BFS+PAE build? On 3.7.1, the BFS patch just went in and enabling 64G highmem support (which pulls in PAE) was a piece of cake.

Offline gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3801
Re: Building a custom kernel
« Reply #3 on: January 01, 2013, 08:36:04 PM »
Thanks for the reply. I'm not concerned about making LiveCDs, so lack of UnionFS support is not a problem. I'm just curious, what kind of problems did you run into with your BFS+PAE build? On 3.7.1, the BFS patch just went in and enabling 64G highmem support (which pulls in PAE) was a piece of cake.

It won't build. But I copied the config for the previous pae.bfs and there may be some other conflict that interferes. I've not every built pae kernels before, so I was just hoping the config would just work. I'll try it the way you've described and see it that solves it for me.

Galen

Offline gseaman

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 3801
Re: Building a custom kernel
« Reply #4 on: January 19, 2013, 09:04:29 PM »
I must have made a mistake in my earlier attempt, because I have had no trouble creating pae and pae.bfs kernels since this post. I've put a set 3.4.25 kernels in Neal's dropbox and so far they look good.

Galen

Offline AnotherUser

  • Full Member
  • ***
  • Posts: 92
Re: Building a custom kernel
« Reply #5 on: January 20, 2013, 09:13:46 AM »
I must have made a mistake in my earlier attempt, because I have had no trouble creating pae and pae.bfs kernels since this post. I've put a set 3.4.25 kernels in Neal's dropbox and so far they look good.

Galen

I haven't seen that kernel hit the Testing section of the repos yet. As soon as it does I'll test it.