Skip to content

Instantly share code, notes, and snippets.

@aculich
Created April 10, 2025 16:25
Show Gist options
  • Save aculich/7d1aa6c537fc61f101743728bfae05e8 to your computer and use it in GitHub Desktop.
Save aculich/7d1aa6c537fc61f101743728bfae05e8 to your computer and use it in GitHub Desktop.

Revisions

  1. aculich created this gist Apr 10, 2025.
    33 changes: 33 additions & 0 deletions CentOS7-bootfix.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    1. **Current Situation**:
    - The system has multiple kernel versions installed:
    - 4.9.127-32.el7.x86_64 (newest)
    - 3.10.0-1160.11.1.el7.x86_64 (currently booting)
    - 3.10.0-957.21.3.el7.x86_64 (your preferred version)
    - Several debug kernels

    2. **The Issue**:
    - The `grubenv` file shows that the system is set to boot into the debug version of 3.10.0-1160.11.1
    - This is likely happening because of the `savedefault` option in each menu entry, which saves the last booted entry as the default

    3. **Why It Changes**:
    - When security updates install new kernels, they typically become the default boot option
    - The `savedefault` feature then remembers whatever kernel was last booted
    - If the system was ever booted into the debug kernel, it would remember that choice

    4. **To Fix This**, you would need to run these commands on the remote system:

    ```bash
    # To set the preferred kernel as default (957.21.3):
    grub2-set-default "CentOS Linux (3.10.0-957.21.3.el7.x86_64) 7 (Core)"

    # Verify the setting:
    grub2-editenv list

    # Regenerate the grub config:
    grub2-mkconfig -o /boot/grub2/grub.cfg
    ```

    5. **To Prevent Future Issues**:
    - Edit `/etc/default/grub` to set `GRUB_SAVEDEFAULT=false`
    - This will prevent the system from automatically changing the default kernel
    - Then regenerate the grub config again