• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Compiling/Recompiling Kernels

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

I.M.O.G.

Glorious Leader
Joined
Nov 12, 2002
Location
Rootstown, OH
So I've mastered the basics of building kernels. These are the questions I have right now.

Hypothetically... I have recent kernel 2.A.BC and realize I forgot to build a component into the kernel and want to recompile kernel 2.A.BC with the same options I built thru the last menuconfig, and one additional option. I download the kernel source and am ready to go - is there a way to provide the same options I selected in my previous menuconfig, then just provide the one additional option and compile?

For example, if I need to recompile my kernel, I would hunt thru all the options so I can remember everything I need. There has to be a better way, other than writing them down.

Summary:

1. Can I export to a file the options I selected in menuconfig? When is it possible to do this - when configuring the kernel and/or after the kernel is compiled?

2. Can I provide the options I used on my last compile to recompile a new kernel in a non-purely-manual way?

3. Do the answers to these questions possibly change if I'm changing from recent kernel 2.A.BC to newer kernel 2.A.YZ?

4. Also, if I update gcc from 4.1 to 4.3 then do an "emerge -eav world", I should recompile my kernel also or my kernel modules will fail to load, if I understand correctly. So in this case, I would want to recompile my kernel with the exact same options I manually selected the previous time. If this is not answered in the previous questions, please address this also.
 
Last edited:
So I've mastered the basics of building kernels. These are the questions I have right now.

Hypothetically... I have recent kernel 2.A.BC and realize I forgot to build a component into the kernel and want to recompile kernel 2.A.BC with the same options I built thru the last menuconfig, and one additional option. I download the kernel source and am ready to go - is there a way to provide the same options I selected in my previous menuconfig, then just provide the one additional option and compile?

For example, if I need to recompile my kernel, I would hunt thru all the options so I can remember everything I need. There has to be a better way, other than writing them down.

Summary:

1. Can I export to a file the options I selected in menuconfig? When is it possible to do this - when configuring the kernel and/or after the kernel is compiled?

2. Can I provide the options I used on my last compile to recompile a new kernel in a non-purely-manual way?

3. Do the answers to these questions possibly change if I'm changing from recent kernel 2.A.BC to newer kernel 2.A.YZ?

The config file is in /usr/src/linux/.config

At the bottom of the first screen when building the kernel there are options to load and save kernel configs.

ls -al /usr/src/linux to make sure the link is pointing to the correct kernel. There is a symlink USE flag for kernel sources that will link it for you if it is set.
 
The config file is in /usr/src/linux/.config

At the bottom of the first screen when building the kernel there are options to load and save kernel configs.

ls -al /usr/src/linux to make sure the link is pointing to the correct kernel. There is a symlink USE flag for kernel sources that will link it for you if it is set.

Thanks Fishy, I see that load/save option now. I went thru every option in menuconfig reading the shift+? help, but I honestly didn't see the load/save options seperated off at the bottom.

You've been a lot of help with my n00b questions so far, I appreciate it.
 
1. Can I export to a file the options I selected in menuconfig? When is it possible to do this - when configuring the kernel and/or after the kernel is compiled?

Menuconfig should have an option to export this configuration to an external file (as well as an import option). Or, use .config as fishy pointed out.

2. Can I provide the options I used on my last compile to recompile a new kernel in a non-purely-manual way?

Yes, you can drop in a .config from an older kernel and run a specific command to upgrade using make oldconfig:

http://www.gentoo.org/doc/en/kernel-upgrade.xml said:
10. Advanced: Using your old kernel .config to configure a new one

It is sometimes possible to save time by re-using the configuration file from your old kernel when configuring the new one. Note that this is generally unsafe -- too many changes between every kernel release for this to be a reliable upgrade path.

The only situation where this is appropriate is when upgrading from one Gentoo kernel revision to another. For example, the changes made between gentoo-sources-2.6.9-r1 and gentoo-sources-2.6.9-r2 will be very small, so it is usually OK to use the following method. However, it is not appropriate to use it in the example used throughout this document: upgrading from 2.6.8 to 2.6.9. Too many changes between the official releases, and the method described below does not display enough context to the user, often resulting in the user running into problems because they disabled options that they really didn't want to.

To reuse your old .config, you simply need to copy it over and then run make oldconfig. In the following example, we take the configuration from gentoo-sources-2.6.9-r1 and import it into gentoo-sources-2.6.9-r2.

3. Do the answers to these questions possibly change if I'm changing from recent kernel 2.A.BC to newer kernel 2.A.YZ?

For the same kernel, copying .config across is perfectly safe and requires no configuration step at all. Between kernels, see above. Not recommended.

4. Also, if I update gcc from 4.1 to 4.3 then do an "emerge -eav world", I should recompile my kernel also or my kernel modules will fail to load, if I understand correctly. So in this case, I would want to recompile my kernel with the exact same options I manually selected the previous time. If this is not answered in the previous questions, please address this also.

Yes, use the .config for this too.

Nice to see you around again IMOG :)
 
Thanks for the further descriptions, thats helpful.

Good to see you too David, its nice seeing a lot of familiar faces still around here.
 
a little off-topic and bloated but you did bring up a gcc update and emerge -e, the following is what i have been using from gcc3 odd, and solved a lot of headaches ;)

For me the best method is after updating gcc to run gcc-config to configure your new gcc install which will prevent a emerge -e being pointless because its compiling against the old gcc. you will need your CHOST so your make.conf should have that infomation

((note: my chost x86_64-pc-linux-gnu and gcc versions [4.1.2/4.3.1] are just examples. change to suit your needs))

Code:
cat /etc/make.conf | grep CHOST
CHOST="x86_64-pc-linux-gnu"


then with the CHOST and the version of gcc we just upgraded to, we would then as root

Code:
gcc-config x86_64-pc-linux-gnu--4.3.1

then we want to update our environment
Code:
 env-update && source /etc/profile

then the last step to make the system recognize our new gcc we would run fix_libtool_files script.

Code:
/usr/share/gcc-data/x86_64-pc-linux-gnu/4.3.1/fix_libtool_files.sh 4.1.2

once that is done the next step would to re-emerge libtool which handles shared library's

Code:
emerge -1av libtool

now would be the time you emerge -e @System, followed by @world safely knowing we are building against the new gcc not the old one.

then compile/re-compile your kernel against the new gcc

of course after compiling a new kernel, you will have to re-compile things like ati/nvidia propriety drivers or ndiswrapper, a good way of knowing what needs to be recompiled, run
Code:
module-rebuild list
if you have not used module-rebuild before run 'module-rebuild populate' first, then to actually rebuild them 'module-rebuild rebuild'
 
I'm confused... if you are just changing an option in the kernel, why are you re-downloading the kernel source? Just go to your kernel dir, type make menuconfig, and it will have your current config. Then just add whatever option, exit out and save, and run make && make modules_install. Copy the kernel over and you're done. It also will only recompile those parts that were changed, so it should be quick.

What am I missing here?
 
You are just missing the fact that I'm a noob to real linux... Ubuntu doesn't require the kind of understanding Gentoo does.

What you said makes sense... I just never thought of doing it because I'm mostly just following the handbook when I do this sort of stuff. Didn't occur to me that the source was still present in the kernel directory.
 
Back