How to build a vanilla kernel RPM package Fedora 37
I currently have an Intel Arc A770 LE 16GB and out of the box Fedora 37 does not support it. There are some workarounds but the best option (at the time of writing) is to use kernel 6.2.7 as that has native Intel Arc support.
This is a quick guide I made for myself, it will build a linux-6.2.7 *.rpm package in Fedora 37. As with anything in Linux, there is usually more than one way to do things or a better way to do something. If you have a suggestion leave a comment below.
Open a terminal
sudo dnf install ncurses-devel flex bison rpm-build elfutils-libelf-devel rpmdevtools openssl-devel dwarves perl
This should install required packages to build and compile the kernel.
rpmdev-setuptree
This will setup your home directory for building the *.rpm package.
cd ~/rpmbuild/SOURCES/
We are going to go into the SOURCES directory in our rpmbuild tree.
wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.2.7.tar.xz
This will download linux-6.2.7.tar.xz into the SOURCES directory.
tar -xf linux-6.2.7.tar.xz
This will extract the compressed archive files into a folder call linux-6.2.7 within the SOURCES directory.
cd linux-6.2.7
Go into the linux-6.2.7 directory.
make menuconfig
This will bring up a console based menu configuration where you can configure your kernel options. Once you have configured your kernel options, save and exit.
You can at this stage (read on to see why I would not) build your kernel *.rpm package by issuing either make binrpm-pkg or make rpm-pkg depending on whether you want the binary package only or source and binary *.rpm.
time make -j`nproc` binrpm-pkg
To speed up the build, I am using the -j option to run a number of jobs in parallel, i.e. multi threading with the argument nproc to automatically obtain my processor count and use that number for the amount of jobs to run. With my current processor, an AMD Ryzen 5600G, nproc results in a count of 12.
However, if you start compiling your kernel rpm now, it will whizz through the compiling process but then choke at the point it starts to write the *.rpm file. The reason for this is because the makefile scripts are configured to only use 1 processing thread during the package file write and compression stage. To speed it up we need to edit the scripts before issuing the make command and enable multi threaded package compression.
gnome-text-editor ~/rpmbuild/SOURCES/linux-6.2.7/scripts/Makefile.package
# binrpm-pkg
# ---------------------------------------------------------------------------
PHONY += binrpm-pkg
binrpm-pkg:
$(MAKE) -f $(srctree)/Makefile
$(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
+rpmbuild $(RPMOPTS) --define "_builddir $(objtree)" --target \
$(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec
And add the following --define "_binary_payload w7T0.zstdio" as shown below.
# binrpm-pkg
# ---------------------------------------------------------------------------
PHONY += binrpm-pkg
binrpm-pkg:
$(MAKE) -f $(srctree)/Makefile
$(CONFIG_SHELL) $(MKSPEC) prebuilt > $(objtree)/binkernel.spec
+rpmbuild $(RPMOPTS) --define "_binary_payload w7T0.zstdio" --define "_builddir $(objtree)" --target \
$(UTS_MACHINE)-linux -bb $(objtree)/binkernel.spec
Comments
Post a Comment
If you enjoyed this article please let me know!