Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
how to i switch from a kernel-bin to genkernel?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
cornplayz256
Tux's lil' helper
Tux's lil' helper


Joined: 25 Jun 2023
Posts: 107
Location: /dev/mmcblk0

PostPosted: Wed Aug 16, 2023 6:13 pm    Post subject: how to i switch from a kernel-bin to genkernel? Reply with quote

im using a bin-kernel and now i want to switch to genkernel so i can build my own kernel. can anyone tell me how to switch from a bin kernel to a genkernel? any help is appreciated. :mrgreen:
Back to top
View user's profile Send private message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 5654
Location: Bavaria

PostPosted: Wed Aug 16, 2023 8:00 pm    Post subject: Re: how to i switch from a kernel-bin to genkernel? Reply with quote

cornplayz256 wrote:
[...] so i can build my own kernel [...]


What do you mean by that ?

What do you want to do ? Hardening your kernel ?

Do you want a "Hybrid approach: Genkernel" ?

=> https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel#Alternative:_Genkernel

Or do you want to do a "Full manual approach" ?

=> https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel#Alternative:_Manual_configuration

In every case you must install the sources before:

https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel#Installing_the_kernel_sources

and then select one of the links above.


If you can boot your new kernel it should be safe to uninstall sys-kernel/installkernel-gentoo and sys-kernel/gentoo-kernel-bin later.

----

Attention: If you want a full manual approch I recommend to read some wiki articles before. A good start (with many links to important articles) is my:
https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Manual_kernel_configuration
Back to top
View user's profile Send private message
stefan11111
l33t
l33t


Joined: 29 Jan 2023
Posts: 954
Location: Romania

PostPosted: Wed Aug 16, 2023 9:40 pm    Post subject: Re: how to i switch from a kernel-bin to genkernel? Reply with quote

pietinger wrote:
cornplayz256 wrote:
[...] so i can build my own kernel [...]


What do you mean by that ?

What do you want to do ? Hardening your kernel ?

Do you want a "Hybrid approach: Genkernel" ?

=> https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel#Alternative:_Genkernel

Or do you want to do a "Full manual approach" ?

=> https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel#Alternative:_Manual_configuration

In every case you must install the sources before:

https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel#Installing_the_kernel_sources

and then select one of the links above.


If you can boot your new kernel it should be safe to uninstall sys-kernel/installkernel-gentoo and sys-kernel/gentoo-kernel-bin later.

----

Attention: If you want a full manual approch I recommend to read some wiki articles before. A good start (with many links to important articles) is my:
https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Manual_kernel_configuration

+1
Why switch to genkernel when there is a better, more customizable, and easier to maintain way?
_________________
My overlay: https://github.com/stefan11111/stefan_overlay
INSTALL_MASK="/etc/systemd /lib/systemd /usr/lib/systemd /usr/lib/modules-load.d *udev* /usr/lib/tmpfiles.d *tmpfiles* /var/lib/dbus /usr/bin/gdbus /lib/udev"
Back to top
View user's profile Send private message
cornplayz256
Tux's lil' helper
Tux's lil' helper


Joined: 25 Jun 2023
Posts: 107
Location: /dev/mmcblk0

PostPosted: Wed Aug 16, 2023 10:46 pm    Post subject: Re: how to i switch from a kernel-bin to genkernel? Reply with quote

pietinger wrote:
cornplayz256 wrote:
[...] so i can build my own kernel [...]


What do you mean by that ?

What do you want to do ? Hardening your kernel ?

Do you want a "Hybrid approach: Genkernel" ?

=> https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel#Alternative:_Genkernel

Or do you want to do a "Full manual approach" ?

=> https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel#Alternative:_Manual_configuration

In every case you must install the sources before:

https://wiki.gentoo.org/wiki/Handbook:AMD64/Installation/Kernel#Installing_the_kernel_sources

and then select one of the links above.


If you can boot your new kernel it should be safe to uninstall sys-kernel/installkernel-gentoo and sys-kernel/gentoo-kernel-bin later.

----

Attention: If you want a full manual approch I recommend to read some wiki articles before. A good start (with many links to important articles) is my:
https://wiki.gentoo.org/wiki/User:Pietinger/Tutorials/Manual_kernel_configuration



I just want to toggle some things in the menu config. Thats all.
Also, thanks for the info.
Back to top
View user's profile Send private message
jburns
Veteran
Veteran


Joined: 18 Jan 2007
Posts: 1231
Location: Massachusetts USA

PostPosted: Wed Aug 16, 2023 11:51 pm    Post subject: Reply with quote

Code:
genkernel --menuconfig --kernel-config=/proc/config.gz  all
would use the config for the running kernel and allow you to modify it for the new kernel that is built from source. menuconfig can be replaced by gconfig or xconfig depending on which desktop you are using.
Back to top
View user's profile Send private message
sublogic
Guru
Guru


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

PostPosted: Thu Aug 17, 2023 1:01 am    Post subject: Re: how to i switch from a kernel-bin to genkernel? Reply with quote

cornplayz256 wrote:
im using a bin-kernel and now i want to switch to genkernel so i can build my own kernel. can anyone tell me how to switch from a bin kernel to a genkernel? any help is appreciated. :mrgreen:
Genkernel is a good (but slow) way to build a kernel from scratch, but you already have a working installation. I don't think you need genkernel.

I'll assume that you have a straightforward install with grub and a directly accessible root partition, as opposed to things like LVM or full disk encryption. If that's not the case, speak up !
Here's what I would do.
  1. emerge gentoo-sources
  2. eselect kernel list
  3. eselect kernel set choose-by-number
  4. cd /usr/src/linux
  5. make localyesconfig
  6. make -j$(nproc)
  7. make modules_install
  8. mount /boot
  9. make install
  10. grub-mkconfig -o /boot/grub/grub.cfg
  11. reboot
EDIT: changed step 5 from "localmodconfig" to "localyesconfig".

Step 5 creates a kernel .config with the drivers currently in use builtin, and no other drivers. Those builtin drivers should be sufficient to boot the new kernel without an initramfs. The kernel should build much faster than with genkernel, which compiles tons of modules you won't use.

If the new kernel does not work, reboot and choose your -bin kernel from the grub menu.

To tweak the new kernel, or repair it if broken,
Code:
# cd /usr/src/linux
# make menuconfig
# make -j$(nproc)
# make modules_install
# mount /boot && make install

You may need to add drivers at the menuconfig step. For example, if you plug in a thumb drive and it is not recognized, you need to enable CONFIG_USB_STORAGE at the menuconfig step, either builtin or modular. The driver was not in use when you did your localmodconfig because the thumb drive wasn't plugged in, so it was left out of the .config .

EDIT 2: Ah, yes, the firmware. If you get a text console but can't start X, your graphics driver needs firmware. Find it in "menuconfig" and change it from "y" to "m" (=from builtin to module). (Also you should emerge sys-kernel/linux-firmware if you haven't already.)

Disclaimer: I never used a -bin kernel so I have to make ASSumptions in the above. Just keep your working initial kernel as a fallback in case anything goes wrong.

EDIT 3: See NeddySeagoon's remark in followup post below.


Last edited by sublogic on Fri Aug 18, 2023 12:02 am; edited 1 time in total
Back to top
View user's profile Send private message
Gentoopc
Guru
Guru


Joined: 25 Dec 2017
Posts: 413

PostPosted: Thu Aug 17, 2023 2:55 am    Post subject: Re: how to i switch from a kernel-bin to genkernel? Reply with quote

cornplayz256 wrote:


the Gentoo forum no longer understands why it is necessary to build a kernel. this raises questions for them already. this place will soon need to be renamed microsoft forum.


you're good for trying to pick at the core.
Back to top
View user's profile Send private message
Hu
Administrator
Administrator


Joined: 06 Mar 2007
Posts: 23395

PostPosted: Thu Aug 17, 2023 12:00 pm    Post subject: Re: how to i switch from a kernel-bin to genkernel? Reply with quote

Gentoopc wrote:
cornplayz256 wrote:
the Gentoo forum no longer understands why it is necessary to build a kernel. this raises questions for them already. this place will soon need to be renamed microsoft forum.

you're good for trying to pick at the core.
The Gentoo forum consists of a great many people, most of whom choose to stay out of any given thread. Please quit your sniping that the whole forum is doomed because a few people do not try to use the distribution the way you think it should be done. Moreover, I do not see any replies in this thread that would even justify your snipe.
  • OP asked the question.
  • pietinger asked for elaboration, because the specific goals the OP seeks to achieve influence which answer is best. pietinger did not try to discourage OP from doing a custom kernel.
  • stefan11111 posted general agreement to pietinger's response, so this also was not discouraging a custom kernel.
  • OP acknowledged pietinger.
  • jburns posted a response directly addressing OP's original intent to use genkernel.
  • sublogic posted a detailed response on how to build a custom kernel without relying on genkernel. While not directly addressing OP's question, I think that was a well intentioned and helpful response. At worst, I would say sublogic discouraged OP from using the requested prebuilt tool (genkernel) and pushed instead for a deeper understanding of how to do the work manually - exactly the thing you seem to want people to do.
Therefore, from my perspective, every response in this thread is on-topic, well intentioned, and undeserving of your snipe.
Back to top
View user's profile Send private message
NeddySeagoon
Administrator
Administrator


Joined: 05 Jul 2003
Posts: 55212
Location: 56N 3W

PostPosted: Thu Aug 17, 2023 4:53 pm    Post subject: Reply with quote

sublogic,

Your reboot will fail because grub will use root=UUID= on the kernel command line.
Mounting root by filesystem UUID requires the user space mount command, which in turn, forces the use of an initrd.

Grub needs to be coaxed to use root=PARTUUID=, then it should boot. Note that root=/dev/... is discouraged as it in not deterministic, unless you have exactly one drive.
I'll leave the how of that to others as I use syslinux.
_________________
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Back to top
View user's profile Send private message
stefan11111
l33t
l33t


Joined: 29 Jan 2023
Posts: 954
Location: Romania

PostPosted: Thu Aug 17, 2023 7:21 pm    Post subject: Reply with quote

NeddySeagoon wrote:
sublogic,

Your reboot will fail because grub will use root=UUID= on the kernel command line.
Mounting root by filesystem UUID requires the user space mount command, which in turn, forces the use of an initrd.

Grub needs to be coaxed to use root=PARTUUID=, then it should boot. Note that root=/dev/... is discouraged as it in not deterministic, unless you have exactly one drive.
I'll leave the how of that to others as I use syslinux.

Here, grub-mkconfig does that by itself without any external config.
Does root=/dev/... actually work? How can it read from /dev before the rootfs has been mounted?
_________________
My overlay: https://github.com/stefan11111/stefan_overlay
INSTALL_MASK="/etc/systemd /lib/systemd /usr/lib/systemd /usr/lib/modules-load.d *udev* /usr/lib/tmpfiles.d *tmpfiles* /var/lib/dbus /usr/bin/gdbus /lib/udev"
Back to top
View user's profile Send private message
sublogic
Guru
Guru


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

PostPosted: Fri Aug 18, 2023 12:38 am    Post subject: Reply with quote

stefan11111 wrote:
... Does root=/dev/... actually work? How can it read from /dev before the rootfs has been mounted?
(Drifting off-topic but OK) Huh? I never thought of that.
Aha. Solution in /usr/src/linux/init/do_mounts.c . Code is moving, with added comments, to /usr/src/linux/block/early-lookup.c .

(cornplayz256, keep us posted.)
Back to top
View user's profile Send private message
sam_
Developer
Developer


Joined: 14 Aug 2020
Posts: 2307

PostPosted: Fri Aug 18, 2023 8:04 am    Post subject: Reply with quote

Just to note that you can customise your kernel with gentoo-kernel as well, so there's another option than genkernel or a manual build: https://wiki.gentoo.org/wiki/Project:Distribution_Kernel#Modifying_kernel_configuration.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware 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