Vanilla kernel traditional compilation kernel panic in Arch Linux

Hi I am Rupesh from India and I have brought a new system with AMD Ryzen zen3 5500GT and Asus prime b450 motherboard. I installed Arch Linux Operating System five months back updating, and using it without any problem. I thought to compile vanilla kernel source code optimized for my hardware but failed.

Actually yesterday I have updated my system and installed base-devel meta package and other packages like xmlto, kmod, inetutils, bc, libelf, git, cpio, perl, tar, xz.

I studied Arch Linux traditional kernel compilation and other guidelines to compile kernel. I tried to follow those steps.

At first I have downloaded kernel source code and from kernel.org

wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.13.3.tar.xz

After that I have downloaded sign file from kernel.org

wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.13.3.tar.sign

I tried to verify integrity of the kernel through the following commands.

unxz linux-6.13.3.tar.xz
gpg --verify linux-6.13.3.tar.sign linux-6.13.3.tar

I received error as public key not found.

I unpacked kernel source code

tar -xvf linux-6.13.3.tar.xz

After that I changed ownership of the directory recursively through the following command.

chown -R $USER:$USER linux-6.13.3

Then I have entered into the extracted directory.

cd linux-6.13.3

Before configuration I have updated cflags as follows

export KCPFLAGS=" -march=znver3 -O2 pipe"
export KCLAGS=" -march=znver3 -O2 pipe"
export CFLAGS=" -march=znver3 -O2 pipe"
export CPFLAGS=" -march=znver3 -O2 pipe"

After that I have created a configuration file which consists of only the modules loaded by old kernel through the following command.

make localmodconfig

I received some questions related to kernel configuration and I have selected default values by entering ENTER key.

After that I entered the following command.

make xconfig

In this gui configuration I done the following changes.

  1. I selected amdgpu option to compile as module

  2. I have selected the option DISABLE_DEBUG_INFO to Yes

  3. I have added the string _Rupesh to Local_Version

  4. I have selected append Local_Version to version to yes

  5. I have disabled support for other processors like intel etc except AMD.

  6. I have selected powersave in frequency scaling rather than performance.

I have saved and exited the configuration.

After that I issued the following command to make the kernel and modules.

make bzImage modules 

After that I issued the following command to install modules

make modules_install 

After that I have tried to install kernel to /boot through the following command.

make install.

Unfortunately I got the error as

Lilo not found.

So I have copied the bzImage to /boot directory manually through the following command.

cp  arch/x86/boot/bzImage /boot/vmlinuz-linux-6.13.2_Rupesh

After that I have created initramfs image through the following command.

mkinitcpio -k 6.13.2 -g /boot/initramfs-linux-6.13.2_Rupesh.img

I have even copied the System.map file to the boot directory manually through the following commands.

cp System.map /boot/System.map-linux-6.13.2_Rupesh
ln -sf /boot/System.map-6.13.2_Rupesh /boot/System.map

After that I have updated my grub configuration through the following command.

grub-mkconfig -o /boot/grub/grub.cfg

After that I have installed the grub boot loader through the following command.

grub install /dev/nvmen101

I thought everything was done properly but when I tried to boot into the latest kernel I got kernel panic with blue screen.

I am using other Linux Operating Systems like Fedora 41, Debian Linux, Gentoo Linux. I made same things to configure and install the vanilla kernel and succeeded but in Arch Linux I failed.

In other Linux Operating Systems when I issue the command "make install" another tool like dracut is invoked and it takes the responsibility of installation of kernel compiled but in Arch Linux there's no way.

Kindly try to suggest what's wrong I have done and how to compile and install the vanilla kernel.

Regards,
Rupesh.

Can I use directly vannila kernel instead of distribution kernel.

Someone suggested not because distribution kernels consists of a number of patches.

But unfortunately distribution kernels are too old I mean latest one's are not released.

I've usually been able to compile a vanilla kernel and use it in place of the distribution's kernel.

If you can, get the kernel config file from the distribution. Check to see if /proc/config.gz is available when booting the kernel. I think there are tools to extract it from a kernel on disk, but I'm not sure.

Most distributions also offer their config files with the kernel package.

Please give an example. Most distributions are relatively recent or at

1 Like

Ok I can understand what you are saying.

Using or compiling distribution kernel source code is preferred than vannila kernel.

I have rectified the error in Arch Linux ie., After compiling and installation of kernel the grub failed to add correct parameters for root initramfs in grub.cfg.

I added manually and at present I am able to boot into the latest kernel.

2 Likes

Hi @rupeshforu3

FYI ONLY

ChatGPT 4o Replies toYour Question:

Note: Alway Be Super Careful with ChatGPT Admin Solutions!


You’ve done a great job detailing the steps you followed, which helps in diagnosing the issue. Given that you successfully built and booted custom kernels on other distros but faced kernel panic on Arch Linux, there are a few things that might have gone wrong:


Potential Issues and Fixes

1. Kernel Version Mismatch in Commands

You downloaded linux-6.13.3, but in some of your commands, you referenced 6.13.2 (e.g., mkinitcpio -k 6.13.2 -g /boot/initramfs-linux-6.13.2_Rupesh.img). Ensure you are consistently using 6.13.3 in all steps.


2. Missing or Incorrect Initramfs Generation

Arch Linux relies on mkinitcpio to generate the initramfs (while Fedora and Debian use dracut). Your command:

mkinitcpio -k 6.13.2 -g /boot/initramfs-linux-6.13.2_Rupesh.img

Possible issues:

  • You might have skipped installing kernel modules (make modules_install).
  • The kernel version in your mkinitcpio command does not match the compiled kernel.
  • mkinitcpio might require additional hooks.

Fix: Ensure Correct Initramfs Generation

Try regenerating the initramfs with the correct version:

mkinitcpio -p linux

Or manually specify the correct version:

mkinitcpio -k 6.13.3 -g /boot/initramfs-linux-6.13.3_Rupesh.img

Check that the initramfs file exists in /boot before rebooting.

ls -lh /boot/initramfs-linux-6.13.3_Rupesh.img

3. Incorrect Bootloader Installation

Your grub-install command contains an issue:

grub install /dev/nvmen101

This should be:

grub-install /dev/nvme0n1

Make sure you install GRUB to the correct disk (nvme0n1, sda, etc.). Find the correct device:

lsblk -o NAME,MOUNTPOINT

Then install GRUB properly:

grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg

4. Incorrect Manual Kernel Copy

You manually copied the kernel image:

cp arch/x86/boot/bzImage /boot/vmlinuz-linux-6.13.2_Rupesh

Try using the following instead:

cp arch/x86/boot/bzImage /boot/vmlinuz-linux-6.13.3_Rupesh

Ensure the copied file exists in /boot:

ls -lh /boot/vmlinuz-linux-6.13.3_Rupesh

5. Ensure localmodconfig Did Not Disable Critical Features

Using make localmodconfig is useful, but it might have disabled essential drivers (e.g., NVMe support, filesystem support).

Fix: Manually check .config to ensure essential modules are enabled:

grep -i 'nvme' .config
grep -i 'ext4' .config
grep -i 'btrfs' .config

Ensure that these options are enabled (either as =y or =m):

  • CONFIG_BLK_DEV_NVME
  • CONFIG_EXT4_FS
  • CONFIG_BTRFS_FS (if using Btrfs)
  • CONFIG_XFS_FS (if using XFS)

If any are missing, enable them using:

make menuconfig

Then recompile the kernel.


6. Debugging Kernel Panic

If you still get a kernel panic, try booting the old kernel and collecting logs:

journalctl -k -b -1

Also, boot with these kernel parameters:

loglevel=7 earlyprintk=efi debug

This might help diagnose the issue.


Summary of Fixes

  1. Ensure consistent kernel version references (6.13.3).
  2. Regenerate initramfs using mkinitcpio -p linux.
  3. Fix GRUB installation by using grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB.
  4. Manually copy the kernel properly (cp arch/x86/boot/bzImage /boot/vmlinuz-linux-6.13.3_Rupesh).
  5. Ensure essential modules are enabled in .config (NVMe, EXT4, etc.).
  6. Enable debugging logs if kernel panic persists.

Try these fixes and let me know if you need further help. :rocket:

1 Like