Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Building kernel and recompile?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC
View previous topic :: View next topic  
Author Message
pertonn
n00b
n00b


Joined: 23 Aug 2023
Posts: 1

PostPosted: Wed Aug 23, 2023 8:06 am    Post subject: Building kernel and recompile? Reply with quote

I understand how to build a kernel but lets say you forgot something in kernel that you need.

Best approach?

I was thinking of
make mrproper
cp /boot/config-version /usr/src/linux/.config

or this not necessary?

is this correct approach? what about modules? lets say you want to remove a module from kernel, do you need to delete it from /lib/modules/kernel-version first?
Back to top
View user's profile Send private message
rfx
Tux's lil' helper
Tux's lil' helper


Joined: 19 Apr 2023
Posts: 142
Location: de-by

PostPosted: Wed Aug 23, 2023 9:28 am    Post subject: Reply with quote

The .config is stored in /usr/src/linux-6.1.46-gentoo/.config or whatever Version you use, you dont have to copy it again. When you change 1-2-3 Things and build the Kernel. Then after reboot you want to change more 2-3 things, the previous .config is still in /usr/src/linux-6.1.46-gentoo/

It is not a big deal. Just type:

Code:
1) cd /usr/src/linux && make menuconfig

Check your stuff, make your changes.

Code:
2) make && make modules_install && make install


When using initramfs you need additional steps. First rename the existing initramfs, then create a new one:
Code:
3.1) mv /boot/initramfs-6.1.46-gentoo.img /boot/initramfs-6.1.46-gentoo.img.old


Code:
3.2) dracut --kver=6.1.46-gentoo


now check your /boot/, you should have new config, initramfs, System.map & vmlinuz and everything (from your older stuff as e.g. vmlinuz-6.1.46-gentoo.old). When this has worked, you can tell grub to find the new stuff

Code:
grub-mkconfig -o /boot/grub/grub.cfg


This was all the magic. Your system should work after reboot. if yes, you can cleanup old stuff from /boot/, all the *.old files and cleanup grub with a new:
Code:
grub-mkconfig -o /boot/grub/grub.cfg


So you are on the right side that you can boot your system when you make some kernelchanges that your system can not boot anymore, you have the old versions. after the second grub-mkconfig.. you know that your system is working
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5127
Location: Bavaria

PostPosted: Wed Aug 23, 2023 9:31 am    Post subject: Re: Building kernel and recompile? Reply with quote

pertonn,

Welcome to Gentoo Forums !

pertonn wrote:
I understand how to build a kernel but lets say you forgot something in kernel that you need.

Best approach? [..]

If you want change your existing kernel configuration (from a manual kernel configuration) there is only one approach:

https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Manual_kernel_configuration#Cheat_Sheets

This you have to do if you want ADD or REMOVE some options / modules.

pertonn wrote:
[...] what about modules? lets say you want to remove a module from kernel, do you need to delete it from /lib/modules/kernel-version first?

No. This is handled by "make modules_install".
Back to top
View user's profile Send private message
Goverp
Advocate
Advocate


Joined: 07 Mar 2007
Posts: 2180

PostPosted: Wed Aug 23, 2023 6:34 pm    Post subject: Re: Building kernel and recompile? Reply with quote

pertonn wrote:
I understand how to build a kernel but lets say you forgot something in kernel that you need.
...
make mrproper
...

Definite overkill. If you have a working config, and you haven't changed the kernel sources, you don't even need "make clean", just "make". Sorting what needs recompiling in such circumstances is the whole purpose of "make". I have never found "make mrproper" necessary.

I update my kernel source using "git pull" from the stable kernel tree. I have so far found I sometimes need "make clean" after a change to a new kernel release such as 6.4 to 6.5, so now I do it on each such change. For smaller changes (6.4.9 to 6.4.10) a simple "make" is enough.

If you update your kernel source using more mainstream Gentoo tools - say "emerge gentoo-sources", you may as well do "make clean" for a new source set, though it shouldn't make any difference, as the new set will already be clean.
_________________
Greybeard
Back to top
View user's profile Send private message
sublogic
Apprentice
Apprentice


Joined: 21 Mar 2022
Posts: 270
Location: Pennsylvania, USA

PostPosted: Thu Aug 24, 2023 2:08 am    Post subject: Reply with quote

To what was said above I would only add: "make clean" if you upgraded your compiler since your last kernel build. (If you forget, you'll get an obscure error message about a missing file deep in the weeds of your compiler setup.)
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Gentoo on PPC All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum