Managing the Kernel on a Linode

Traducciones al Español
Estamos traduciendo nuestros guías y tutoriales al Español. Es posible que usted esté viendo una traducción generada automáticamente. Estamos trabajando con traductores profesionales para verificar las traducciones de nuestro sitio web. Este proyecto es un trabajo en curso.
Create a Linode account to try this guide with a $100 credit.
This credit will be applied to any valid services used during your first 60 days.

The primary component of every Linux system is the Linux kernel. The kernel interfaces with the system’s hardware and it controls the operating system’s core functionality. This guide covers the types of kernels that can be assigned to a Linode and how to view, update, or change the kernel.

Types of Kernels

Your Linode is capable of running one of three kinds of kernels:

  • Upstream kernel (or distribution-supplied kernel): This kernel is maintained and provided by your Linux distribution. A major benefit of this kernel is that the distribution was designed with this kernel in mind and all updates are managed through the distributions package management system. It also may support features not present in the Linode kernel (for example, SELinux).

  • Linode kernel: Linode also maintains kernels that can be used on a Linode. If selected, these kernels are provided to your Linode at boot (not directly installed on your system). The Current Kernels page displays a list of all the available Linode kernels.

  • Custom-compiled kernel: A kernel that you compile from source. Compiling a kernel can let you use features not available in the upstream or Linode kernels, but it takes longer to compile the kernel from source than to download it from your package manager. For more information on custom compiled kernels, review our guides for Debian, Ubuntu, and CentOS.

Most of the distribution images available on Linode use the upstream distribution-supplied kernel by default.

Determining Which Kernel Is Installed

There are may ways you can determine which kernel version is installed on your Linux system. The following instructions cover the most common methods:

  1. Log in to the Linode through either SSH or Lish.

  2. Run one of the following commands to display the kernel version:

    • uname -r: Outputs a single line with just the kernel version.
    • hostnamectl: Outputs an organized list of system details, including the kernel version. Can only be used on distributions with systemd (Debian, Ubuntu, CentOS, openSUSE, and more).
    • cat /proc/version: Outputs a string that contains the kernel version and release details.

The kernel version should be a string that’s similar to 5.4.0-80-generic. In this example, the kernel ends with generic, which is common in Ubuntu systems to designate that this is an upstream kernel. If the kernel ends with something similar to linode123, a Linode kernel is being used and the string matches the precise Linode kernel release.

Viewing and Modifying the Kernel in the Cloud Manager

You can use the Cloud Manager to view the type of kernel you are using. If you are using a Linode kernel (not an upstream kernel), you can also view the kernel version.

Note
These instructions may not accurately reflect the actual kernel version installed. This is especially true if the Linode hasn’t been rebooted in a while or wasn’t rebooted after a change to the Linode’s Configuration. To determine the actual kernel version installed on your system, see Determining Which Kernel Is Installed.
  1. Navigate to your Linode in the Cloud Manager and click the Configuration tab.

  2. Find your current Configuration and click the corresponding Edit link. This may be located within the More Options Ellipses dropdown menu.

  3. Scroll to the Boot Settings section.

  4. Review the Kernel dropdown menu selection.

    • Latest 64 bit: Uses the latest 64-bit Linode kernel at the time the Linode boots/reboots. This was the default for most 64-bit distributions prior to August 2018.
    • Latest 32 bit: Uses the latest 32-bit Linode kernel at the time the Linode boots/reboots. This was the default for most 32-bit distributions prior to August 2018.
    • Direct Disk: Instead of a Linux Kernel, this uses the MBE (Master Boot Record) of the primary disk*.
    • GRUB 2: Uses the upstream distribution-supplied kernel that’s installed on the primary disk. If a custom kernel has been installed instead, that is used instead. This is the most common option and has been the default for most new Linodes created after August 2018.
    • GRUB (Legacy): Uses the upstream distribution-supplied kernel that’s installed on the primary disk*. This should only be used on older Linux distributions that have Grub (not Grub 2) installed, like CentOS 6.
    • Specific Linode Kernel: Allows you to specify the exact Linode kernel to use. Since this kernel is maintained regardless of reboots or system updates, it may be preferred in some use cases.

    *Primary disk: the disk assigned as the “Root Device” within the Linode’s Configuration Profile.

  5. Make any desired changes and click the Save Changes button. Otherwise, if no changes were made, click Cancel.

  6. If any changes were made, reboot your Linode for the new kernel to take affect.

Updating the Kernel

Provided a newer kernel is available, you should be able to either manually (or automatically) update the kernel. The exact steps vary depending on the type of kernel and, for upstream kernels, the Linux distribution you are using.

Updating the Linode Kernel

Follow these steps if the Linode is using a Linode kernel:

  • Latest 64-bit or 32-bit kernel: Rebooting the Linode automatically updates the kernel used within your system to the latest Linode kernel release.
  • Specific kernel version (ex: 5.12.2-x86_64-linode144): To update your kernel, follow the instructions within the Viewing and Modifying the Kernel in the Cloud Manager section. When selecting the kernel in the Linode’s Configuration Profile, chose your desired kernel version (or select Latest 64 bit), save the changes, and reboot your Linode.

Updating the Upstream Kernel

Follow these steps if the Linode is using an upstream kernel (the default for most new Linodes created after August 2018):

  1. Log in to the Linode through either SSH or Lish.

  2. Upgrade any system packages related to the kernel:

    • Ubuntu

      sudo apt-get update && sudo apt-get upgrade linux-generic
      
    • Debian

      sudo apt-get update && sudo apt-get upgrade linux-base
      
    • CentOS Stream, CentOS 8, AlmaLinux 8, Rocky Linux 8, and Fedora

      sudo dnf upgrade kernel
      
    • CentOS 7

      sudo yum update kernel
      

    Alternatively, you can upgrade all packages on your system. For specific commands, review the Update/Upgrade sections in the guides for your package manager. See APT (for Ubuntu and Debian), DNF (for CentOS Stream, CentOS 8, AlmaLinux 8, Rocky Linux 8, and Fedora), and YUM (for CentOS 7).

  3. Reboot the Linode.

Considerations When Switching From a Linode Kernel to GRUB 2

If you wish to switch from a Linode kernel to GRUB 2, there are a few issues you may encounter in older systems created prior to August 2018.

SELinux

CentOS 7 and Fedora ship with SELinux running in enforcing mode by default. When switching from the Linode kernel to the upstream kernel, SELinux may need to relabel your filesystem at boot. When the relabeling completes, the Linode will shut down. If you have Lassie enabled, the Linode will automatically boot back up following the shut down. If you do not have Lassie enabled, you will need to manually reboot from the Cloud Manager.

SELinux filesystem relabel

You can trigger the relabel process by creating an empty /.autorelabel file and then rebooting:

touch /.autorelabel

No Upstream Kernel Installed

If your system does not boot and instead shows a GRUB command line prompt in Lish like shown below, then you need to install the kernel and configure GRUB. This should only be necessary on Linodes which were created before February 2017. If this is the case, switch back to the Linode kernel in your configuration profile, reboot your Linode, and then follow this guide’s instructions for installing the kernel.

Installing the Upstream Kernel and Configuring GRUB

For new Linodes, an upstream kernel is already installed on your system and you do not need to follow these steps. In the case of older Linodes, this section outlines how to get both an upstream kernel (and GRUB) installed and configured on your system.

  1. Log in to the Linode through either SSH or Lish.

  2. Update your package management system and install the Linux kernel and GRUB 2. Choose /dev/sda if you’re asked which disk to install to during installation. Linode provides the GRUB bootloader, so your system only needs to provide a grub.cfg file.

    • Ubuntu

      sudo apt update && sudo apt install linux-generic grub2
      
    • Debian

      sudo apt update && sudo apt install linux-image-amd64 grub2
      
    • CentOS Stream, CentOS 8, AlmaLinux 8, Rocky Linux 8, Fedora

      sudo dnf upgrade && sudo dnf install kernel grub2
      
    • CentOS 7

      sudo yum update && sudo yum install kernel grub2
      
    • Arch Linux

      sudo pacman -Syu && sudo pacman -S linux grub
      
    • Gentoo

      emerge -avDuN world
      

      There are two main ways to install Gentoo’s kernel: Manual configuration and using the genkernel tool. Which you use and how you configure the kernel will depend on your preferences, so see the Gentoo Handbook for instructions.

    When the installation finishes, the kernel and other components are located in the /boot directory. For example:

    [root@archlinux ~]# ls /boot
        grub  initramfs-linux-fallback.img  initramfs-linux.img  vmlinuz-linux
  3. Next, configure the serial console and other GRUB settings so you can use Lish and Glish. This is outlined in the following steps.

  4. Open /etc/default/grub in a text editor and go to the line beginning with GRUB_CMDLINE_LINUX. Remove the word quiet if present, and add console=ttyS0,19200n8 net.ifnames=0. Leave the other entries in the line. For example, on CentOS 7 you should have something similar to:

    GRUB_CMDLINE_LINUX="crashkernel=auto rhgb console=ttyS0,19200n8 net.ifnames=0"
    
  5. Add or change the options in /etc/default/grub to match the following snippet. There are other variables in this file, but the current changes are only focused on these lines.

    File: /etc/default/grub
    1
    2
    3
    4
    5
    
    GRUB_TERMINAL=serial
    GRUB_DISABLE_OS_PROBER=true
    GRUB_SERIAL_COMMAND="serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1"
    GRUB_DISABLE_LINUX_UUID=true
    GRUB_GFXPAYLOAD_LINUX=text
  6. Prepare and update the bootloader:

    • Debian and Ubuntu

      sudo update-grub
      
    • CentOS

      The .autorelabel file is necessary to queue the SELinux file system relabeling process when rebooting from the Linode kernel to the CentOS kernel.

      mkdir /boot/grub
      ln -s /boot/grub2/grub.cfg /boot/grub/grub.cfg
      grub2-mkconfig -o /boot/grub/grub.cfg
      touch /.autorelabel
      
    • Arch and Gentoo

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

This page was originally published on


Your Feedback Is Important

Let us know if this guide made it easy to get the answer you needed.


Join the conversation.
Read other comments or post your own below. Comments must be respectful, constructive, and relevant to the topic of the guide. Do not post external links or advertisements. Before posting, consider if your comment would be better addressed by contacting our Support team or asking on our Community Site.