Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] USE dist-kernel and auto nivida rebuild
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
Schievel
n00b
n00b


Joined: 13 Sep 2021
Posts: 31

PostPosted: Wed Apr 20, 2022 10:03 am    Post subject: [SOLVED] USE dist-kernel and auto nivida rebuild Reply with quote

Hi,

I have a question regarding the package sys-kernel/gentoo-kernel and the global USEflag dist-kernel.
So according to the wiki this USEflag should make portage trigger a rebuild of the out of tree kernel modules. Namely that is the nvidia graphic card driver for me. Also the handbook talks about this.

First of all, what my way of building a kernel was for me before gentoo-kernel:
When I felt like updating the kernel, I emerged the newest sys-kernel/gentoo-sources. I then changed the /usr/src/linux symlink to that new version of gentoo-sources via eselect kernel set x. Then I changed into /usr/src/linux, did a make oldconfig, maybe make menuconfig. Then make, make install, make modules_install. Then i reemerged the nvidia-drivers and then made a new initramfs with dracut -f -H --lz4 --kver x.xx.x-gentoo-nvidia. (gentoo-nvidia is just my custom name for that kernel)

So what I hope for was that I can automate this process with sys-kernel/gentoo-kernel and let portage manage the kernel. I enabled the USEflag dist-kernel in /etc/portage/make.conf, I reemerged =x11-drivers/nvidia-driver-510.60.02 to install it with that USEflag. I also enable the USEflags initramfs and savedconfig for sys-kernel/gentoo-kernel. I copied my old .config into /etc/portage/savedconfig/sys-kernel/gentoo-kernel.
Then I emerge virtual/dist-kernel, and gentoo-kernel-5.17.3 gets built. Also a new initramfs for that kernel is built and installed, but dracut complains already, that it can not find the module nvidia-modeset.
And indeed, if I search for \*nvidia*\ in /lib/modules I only get
Code:

/lib/modules/5.17.3-nvidia/kernel/drivers/i2c/busses/i2c-nvidia-gpu.ko
/lib/modules/5.17.3-nvidia/kernel/drivers/usb/typec/altmodes/typec_nvidia.ko

as modules with nvidia in the name for that kernel.
(Results for the old kernel I built manually being this:
Code:
/lib/modules/5.16.9-gentoo-nvidia/video/nvidia.ko
/lib/modules/5.16.9-gentoo-nvidia/video/nvidia-drm.ko
/lib/modules/5.16.9-gentoo-nvidia/video/nvidia-modeset.ko
/lib/modules/5.16.9-gentoo-nvidia/video/nvidia-peermem.ko
/lib/modules/5.16.9-gentoo-nvidia/video/nvidia-uvm.ko
/lib/modules/5.16.9-gentoo-nvidia/kernel/drivers/i2c/busses/i2c-nvidia-gpu.ko
/lib/modules/5.16.9-gentoo-nvidia/kernel/drivers/usb/typec/altmodes/typec_nvidia.ko

When I now do emerge @module-rebuild it builds a new nvidia-driver, then the modules show up in /lib/modules/5.17.3 and then I have to make a new initramfs with dracut to include nvidia-modeset in it.

Am I missing something here? Should I have to build the nvidia module manually? But wouldn't that defeat the purpose of that USEflag dist-kernel?

What also puzzles me is that I had a look at the ebuild of the nvidia driver (510.60.02) and the USEflag dist-kernel does not seem to do anything in it. Although I have not figured out how gentoo pulls off that magic with dist-kernel yet.


Last edited by Schievel on Wed Apr 20, 2022 11:51 am; edited 1 time in total
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2892

PostPosted: Wed Apr 20, 2022 10:11 am    Post subject: Reply with quote

Ideally you shouldn't have nvidia drivers on the initramfs at all, I can't think of any real use for it in the early boot process (esp. since it can't handle the console and you have to use efifb/simplefb or the like instead). It'll just be loaded after filesystems are mounted.

Edit: Usually it goes more like kernel is built (no nvidia modules for that kernel yet), initramfs is made, then dist-kernel cause nvidia-drivers rebuild. Not that I'm familiar with dracut beside letting it do its thing on a few test systems (I don't use it on my main system).
Back to top
View user's profile Send private message
Schievel
n00b
n00b


Joined: 13 Sep 2021
Posts: 31

PostPosted: Wed Apr 20, 2022 10:33 am    Post subject: Reply with quote

I can hardly remember why I did this, I think it was neccesary to set the resolution of my monitors during boot. If I don't have dracut pack that into the initramfs, the xserver wont start.

Anyway, I could probably drop that, and it would be ok with some fiddling around.
Still dist-kernel doesn't cause nvidia-drivers to be rebuild, that is the main issue for me here.
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2892

PostPosted: Wed Apr 20, 2022 10:37 am    Post subject: Reply with quote

Schievel wrote:
Still dist-kernel doesn't cause nvidia-drivers to be rebuild, that is the main issue for me here.
If you mean on same-version, then it's because the subslot didn't change. It wasn't intended for this purpose so it's an unfortunate limitation for this "hack" to cause rebuilds given portage doesn't have a proper mechanism for that.

e.g. 5.17.3 -> 5.17.3 = no rebuild, but a normal @world update that does 5.17.3 -> 5.17.4 will rebuild

Personally rather rare that I rebuild same kernel, so these updates just go smoothly and I don't have to worry about it (no manual action, and /etc/kernel/postinst.d updates my non-grub bootloader stuff).
Back to top
View user's profile Send private message
Schievel
n00b
n00b


Joined: 13 Sep 2021
Posts: 31

PostPosted: Wed Apr 20, 2022 10:45 am    Post subject: Reply with quote

So when I do
Code:
emerge --unmerge =sys-kernel/gentoo-kernel-5.17.3
then
Code:
emerge gentoo-kernel
should it rebuild nvidia?

/ to emulate that update I unmerged gentoo-kernel and dist-kernel from my system. I am now emerging gentoo-kernel-5.16.20, emerge dist-kernel and then im going to do a world set update.
// you are right, it does indeed trigger the nvidia rebuild when updating @world. Thanks for your help.
Maybe we should write a few sentences on that in the wiki?
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