Skip to content

Instantly share code, notes, and snippets.

@chaiyujin
Created December 8, 2020 12:42
Show Gist options
  • Save chaiyujin/c08e59752c3e238ff3b1a5098322b363 to your computer and use it in GitHub Desktop.
Save chaiyujin/c08e59752c3e238ff3b1a5098322b363 to your computer and use it in GitHub Desktop.
Ubuntu: Install Kernel and Set GRUB Default Kernel

Ubuntu: Install Kernel and Set GRUB Default Kernel

Install Kernel

Install the default kernel:

sudo apt install linux-generic

Set GRUB Default Kernel

  1. Find entrance from /boot/grub/grub.cfg
    • Get the $menuentry_id_option:
      grep submenu /boot/grub/grub.cfg
      Example output:
      submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-4591a659-55e2-4bec-8dbe-d98bd9e489cf' {
      'gnulinux-advanced-4591a659-55e2-4bec-8dbe-d98bd9e489cf' is what we need.
    • Get the specific kernel option:
      grep gnulinux-4.15.0 /boot/grub/grub.cfg
      Example output:
      menuentry 'Ubuntu, with Linux 4.15.0-126-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-126-generic-advanced-4591a659-55e2-4bec-8dbe-d98bd9e489cf' {
      'gnulinux-4.15.0-126-generic-advanced-4591a659-55e2-4bec-8dbe-d98bd9e489cf' is what we need.
  2. Set GRUB_DEFAULT in /etc/default/grub
    • Join two entry strings obtained above by '>', set to GRUB_DEFAULT.
      GRUB_DEFAULT='gnulinux-advanced-4591a659-55e2-4bec-8dbe-d98bd9e489cf>gnulinux-4.15.0-126-generic-advanced-4591a659-55e2-4bec-8dbe-d98bd9e489cf'
  3. Update grub
    sudo update-grub
  4. Reboot the machine
@sebalastra
Copy link

you can use this to get the specific kernel you need, assuming is currently in use:

grep gnulinux-$(uname -r) /boot/grub/grub.cfg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment