How to fetch rocky linux kernel source code

I am a green hand of rocky linux.
I need to rebuild the kernel of rocky linux 8.5 to make it work better on my workstation,the source code is not found in the iso.
So where can I download the kernel source code?

The following command will download the latest kernel src.rpm:

$ dnf download --source kernel

Thanks a lot for your reply.
Inspired by your advice, I have fetched the source code package I need.

I am trying to install the Nvidia drivers for my K4000, but the driver says it cannot find my source files. I installed the devel files ok, the downloaded the rpm for the kernel.

dnf download --source kernel

and got the kernel-5.14…src.rpm
for my kernel (thus the …)
but when I try to yum or dnf the rpm file it says it cannot install the source files. How can I fix this?
thanks

“Source” in the dnf download --source context is the source for building the kernel RPMs, not for building kernel modules. If kernel-devel and kernel-headers aren’t satisfying your driver installer, you should check that they are the same version as your running kernel (uname -r).

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.