Objective of This Guide
Step-by-step creation of the 6.16.4 kernel patched with Oscar Maes’ fix, ensuring fully functional internet connectivity.
This is by no means a “guide” in the strict sense, as there are many ways to prepare, compile, and install a kernel. Rather, it’s a step-by-step walkthrough of the method that works for me—one I’ve learned and refined over time. It has been tested and works well on my system, which is a 10th-generation i5 with a dedicated NVIDIA 4060 GPU. On hybrid or different hardware setups, or with different bootloaders, some specific steps may vary.
If anyone identify any issues with this method on a specific system, please report them!
Warning / Disclaimer
This guide is provided for educational purposes only. Although this process is generally safe if followed correctly, every system is different, and each user’s experience may vary.
Use this guide at your own risk. Make sure to backup important data and understand each step before proceeding.
Mistakes during kernel/modules installation or final steps, can make your system unbootable if precautions are not taken.
Following this guide carefully minimizes risks, but responsibility ultimately lies with the user.
CHAPTER 1: Prerequisites
Before compiling your own patched kernel, make sure you have the following:
1-Working Internet Connection
You must have a reliable internet connection before starting, since downloading sources and dependencies requires it.
Note: this may not be straightforward if your current kernel has the IPv4 bug. If possible, it’s recommended to work with a kernel that allows a stable internet connection. If your connection is not fully stable, you can still attempt the process, but pay close attention to any download error messages and repeat the step until it completes successfully.
2-Disk Space
You’ll need at least ~40 GB of free space (just to be safe), as the compilation process itself takes around 26 GB.
3-Install Required Tools
Run:
sudo pacman -S bc rust rust-bindgen rust-src graphviz python-sphinx texlive-latexextra
These tools are necessary to successfully compile the kernel and generate its documentation.
4-NVIDIA Users
If you have an NVIDIA GPU, I recommend to install nvidia-dkms beforehand. This makes building the NVIDIA kernel modules for your new kernel much easier. There are surely other ways to do it, but I suggest this one.
sudo pacman -S nvidia-dkms
This package conflicts with the regular nvidia package, which will be uninstalled and replaced. Pay special attention to this step if your internet connection is unstable, and watch for any download errors.
CHAPTER 2: Downloading the Source and Applying the Fix
Clone the Arch Linux kernel repository
You can choose a custom directory to keep things organized. For example, to clone into ~/custom-kernel:
git clone https://gitlab.archlinux.org/archlinux/packaging/packages/linux.git ~/custom-kernel
Navigate to the repository
cd ~/custom-kernel
Preparing the Sources for Direct Modification
makepkg --nobuild
Once the sources are prepared, navigate to the kernel source directory:
cd src/linux-6.16.4
Now we have to modify the file net/ipv4/route.c
I use Kate:
kate net/ipv4/route.c
and apply the diff as showed here: 7 insertions(+), 3 deletions(-)
(If you’re not sure how to modify route.c yourself, just let me know, and I can share a pre-patched version of the file with the fix already applied. You can then replace the original ~/custom-kernel/src/linux-6.16.4/net/ipv4/route.c with this version before compiling)
This is the if block already modified with the fix applied, including a couple of lines before and after.
!netif_is_l3_master(dev_out))
return ERR_PTR(-EINVAL);
if (ipv4_is_lbcast(fl4->daddr)) {
type = RTN_BROADCAST;
/* reset fi to prevent gateway resolution */
fi = NULL;
} else if (ipv4_is_multicast(fl4->daddr)) {
type = RTN_MULTICAST;
} else if (ipv4_is_zeronet(fl4->daddr)) {
return ERR_PTR(-EINVAL);
}
if (dev_out->flags & IFF_LOOPBACK)
flags |= RTCF_LOCAL;
CHAPTER 3: Compiling the Kernel and Modules
1-Make sure you are in the source directory (you should already be there)
(cd ~/custom-kernel/src/linux-6.16.4)
2-Compile the kernel and modules
Use the LOCALVERSION option to append a custom suffix to your kernel version (e.g., -fix):
make LOCALVERSION=-fix -j$(nproc)
Note: -j$(nproc) automatically sets the number of parallel jobs to the number of CPU cores on your system. If your system tends to overheat or has poor cooling, you can reduce the number of jobs (e.g., -j4) to limit CPU usage. This will make the compilation slower but can help prevent thermal issues.
Now wait for the compilation to finish; it may take some time.
This entire compilation process takes place only inside the ~/custom-kernel directory, without modifying any system directories at this stage. The final build will take up approximately 26 GB of disk space.
In the next step, the final kernel version will be 6.16.4-arch1-1-fix and the modules will be installed under /lib/modules/6.16.4-arch1-1-fix
This ensures that your custom kernel and modules do not conflict with the official Arch kernel.
3-Installing the Modules
sudo make modules_install INSTALL_MOD_STRIP=1
This will place all modules in the directory we mentioned earlier (/lib/modules/6.16.4-arch1-1-fix). The INSTALL_MOD_STRIP=1 option strips debug symbols, reducing the size of the modules.
4-Installing the Kernel
After installing the modules, install the kernel itself with:
sudo make install
This will create two files in /boot:
vmlinuz (the compressed kernel image)
System.map (contains the kernel’s symbol table)
(you can ignore the LILO error if it appears)
After installing the kernel, rename the files in /boot
sudo mv /boot/vmlinuz /boot/vmlinuz-linux-6.16.4-arch1-1-fix
sudo mv /boot/System.map /boot/System.map-linux-6.16.4-arch1-1-fix
CHAPTER 4: FINAL STEPS
1-Installing NVIDIA Modules for the New Kernel (if you have nvidia drivers installed)
If you have an NVIDIA GPU and installed nvidia-dkms, you need to build the NVIDIA kernel modules for your new kernel. Replace 580.76.05 with the version of your installed NVIDIA driver:
sudo dkms install --no-depmod nvidia/580.76.05 -k 6.16.4-arch1-1-fix
sudo depmod 6.16.4-arch1-1-fix
2.Generating the Initramfs
Finally, generate the initramfs for your custom kernel using dracut:
sudo dracut --force --hostonly --no-hostonly-cmdline /boot/initramfs-linux-6.16.4-arch1-1-fix.img 6.16.4-arch1-1-fix
(it’s just one line)
The output file will be placed in /boot and named /boot/initramfs-linux-6.16.4-arch1-1-fix.img
This initramfs is required for booting your custom kernel and loading necessary modules at startup.
3-Updating the Bootloader and Rebooting
Finally, update your bootloader as you normally do. I use GRUB:
sudo grub-mkconfig -o /boot/grub/grub.cfg
This will detect your new kernel (6.16.4-arch1-1-fix) and add it to the boot menu.
Once this is done, you can reboot your system and select your new custom kernel from the boot menu to test it!
With this, this little guide is now complete, covering everything from prerequisites to booting your patched kernel.