Friday, September 12, 2025

How to Fix a Linux Kernel Freeze on Boot

How to Fix a Linux Kernel Freeze on Boot: A Universal Guide

Have you ever installed a new Linux update, only for your system to freeze right after you select a kernel from the boot menu? It's a frustrating problem that points to an incompatibility between the new kernel and your specific hardware. The good news is, there's a simple, universal fix that works across most Linux distributions, including Oracle Linux, Ubuntu, Fedora, and more.

This guide will walk you through the steps to get your system back up and running smoothly.

The Root Cause: Why It's Not GRUB

Before we dive into the fix, let's understand the problem. A freeze during the boot process, after you've selected a kernel, isn't a problem with GRUB (your bootloader). Instead, it’s almost always a kernel-related issue.

The new kernel version likely contains a bug or a driver regression that conflicts with a piece of your hardware, such as your graphics card, Wi-Fi adapter, or a storage controller. The proof is in the pudding: your older kernel still boots perfectly.


Step 1: Find and Boot the Working Kernel

Your first priority is to get your system into a functional state.

  1. Access the GRUB Menu: When your computer starts, use the arrow keys to stop the automatic boot timer.

  2. Locate the Stable Kernel: Use the arrow keys to navigate the list of boot options. The entries are numbered starting from 0. The problematic kernel is usually the first option. Look for the older kernel version, which might be in a submenu called "Advanced options".

  3. Boot the System: Select the working kernel and press Enter. Your system should now boot without any issues.

Pro Tip: Make a note of the working kernel's name and its position in the list (e.g., the third entry is index 2). This will be important for the next step.


Step 2: Choose the Right Method for Your Distribution

Modern Linux distributions have moved away from a single method for managing boot entries. We'll cover the two most common approaches.

If you're using...Use This MethodExamples
A newer enterprise or desktop distributionThe BLS Method (Boot Loader Specification)Oracle Linux, RHEL 8+, Fedora, CentOS 7+
A traditional or older systemThe Traditional MethodUbuntu, Debian, Pop!_OS, Linux Mint

Step 3: Fix Your Boot Order (The BLS Method)

The BLS method is the modern and robust way to set the default kernel. It works by using the kernel's unique name rather than a potentially changing index number.

A. Find the Kernel's Configuration File

The bootloader configuration files are located in /boot/loader/entries/. You need to find the file that corresponds to your working kernel.

Open a terminal and run this command:

Bash
ls -l /boot/loader/entries/

This will list files with long names like b26b3848149e4d0cb5a90d40523f46f4-5.14.0-570.41.1.0.1.el9_6.x86_64.conf. Find the one that matches the version number of your working kernel.

B. Set the Default Flag

Use the grub2-set-bootflag command, providing the full filename of your working kernel's configuration file (without the .conf extension).

Bash
sudo grub2-set-bootflag default <Kernel_Filename_Base>

Example:

Bash
sudo grub2-set-bootflag default b26b3848149e4d0cb5a90d40523f46f4-5.14.0-570.41.1.0.1.el9_6.x86_64

This command permanently updates your system's boot configuration to favor the stable kernel.


Step 4: Fix Your Boot Order (The Traditional Method)

If you're on a distribution that doesn't use the BLS method (like Ubuntu), you'll likely use the grub-set-default command.

  1. Use grub-set-default:

    Use the index number of the working kernel you noted in Step 1.

    Bash
    sudo grub-set-default <Index_Number>
    

    Example: sudo grub-set-default 2

  2. Manually Edit (If grub-set-default fails):

    If the command doesn't work, you can edit the main GRUB configuration file.

    Bash
    sudo nano /etc/default/grub
    

    Find the line GRUB_DEFAULT=... and change it to the index number of your working kernel.

    # Change this line:
    GRUB_DEFAULT=saved
    # TO this line:
    GRUB_DEFAULT=2
    

    Finally, you must update the GRUB configuration to apply your changes:

    • For Ubuntu/Debian: sudo update-grub

    • For RHEL/Fedora/Oracle: sudo grub2-mkconfig -o /boot/grub2/grub.cfg


Step 5: Reboot and Enjoy!

After running the correct command for your system, reboot. You'll find that your computer now automatically boots into the stable, working kernel without any further issues.

You can safely keep the problematic kernel installed and simply wait for a future update from your distribution. Often, a subsequent version will contain the necessary fixes for the bug that was causing your problem.


If problem still persist you can try following:

Based on the grub2-mkconfig and cat /boot/grub2/grub.cfg output you provided, the GRUB configuration is set up to use the Boot Loader Specification (BLS). This is the modern and recommended approach for managing boot entries on many Linux distributions, including RHEL, CentOS Stream, and Fedora.

The key line that confirms this is blscfg within the 10_linux section of the grub.cfg file. This command instructs GRUB to read boot entries from the BLS files located in /boot/loader/entries/, instead of hard-coding them directly into grub.cfg.


How BLS Works

Instead of a single, monolithic grub.cfg file, the Boot Loader Specification uses individual .conf files for each bootable kernel or operating system. These files are typically stored in the /boot/loader/entries/ directory.

  • File Naming: Each file is named using a unique identifier, usually in the format <machine-id>-<kernel-version>.conf.

  • File Content: Each .conf file contains a simple key-value pair for the kernel's title, version, command-line arguments, and initial ramdisk.

This design makes it easier to manage boot entries because:

  1. Atomicity: Installing or removing a kernel simply involves adding or removing a single file. You don't need to regenerate the entire grub.cfg.

  2. Centralized Control: The /etc/default/grub file and the grub2-mkconfig tool are still used to set global GRUB options (like GRUB_DEFAULT, GRUB_TIMEOUT), but the individual boot entries are managed separately.


Implications for Your System

Since your system is using the Boot Loader Specification, you should not manually edit the grub.cfg file. Instead, you need to use the grubby tool to manage your default boot entry.

  • To list the available boot entries:

    Bash
    sudo grubby --info=ALL
    
  • To set a new default boot entry:

    Bash
    sudo grubby --set-default /boot/vmlinuz-<your-new-kernel-version>
    
  • Example: To set the kernel with the ID ba1effc5dd9e4578a78c5f9730dba361-5.14.0-570.41.1.0.1.el9_6.x86_64.conf as the default, you would use a command similar to:

    Bash
    sudo grubby --set-default-index=1 
    

    or, more specifically, using the kernel's path:

    Bash
    sudo grubby --set-default /boot/vmlinuz-5.14.0-570.41.1.0.1.el9_6.x86_64
    

Using grubby is the correct and supported method for managing GRUB boot entries on your system. It automatically updates the necessary BLS files and the GRUB environment.

How to Fix a Linux Kernel Freeze on Boot

How to Fix a Linux Kernel Freeze on Boot: A Universal Guide Have you ever installed a new Linux update, only for your system to freeze right...