How To Update a DigitalOcean Server's Kernel
Introduction
Updating the kernel on your DigitalOcean Droplet is a straight forward process that differs slightly based on the Droplet's operating system. In this guide, we'll walk you through the process of updating your kernels for DigitalOcean Droplets.
Understanding DigitalOcean Kernel Management
DigitalOcean uses two different methods of managing kernels depending on the operating system and when the Droplet was created.
In the past, kernels for DigitalOcean Droplets were managed outside of the Droplets themselves inside the DigitalOcean control panel. This process involved updating the Droplet's kernel on the server and then selecting the matching kernel from the DigitalOcean control panel. This was a quick and easy process, but required users to use the control panel for the actual kernel swap.
Modern DigitalOcean Kernel Management
Changes in DigitalOcean's backend infrastructure have lead to a more modern process that allows users to manage kernels within the Droplet. This provides a more simplified kernel upgrade process for users and integration with the server's software management processes. Users can manage their kernels using the server's regular package updating procedures.
For Droplets that use the in-control panel legacy system, a special kernel called DigitalOcean GrubLoader is now available and recommended. This allows Droplets with the legacy management system to boot into internally installed kernels.
Setting Up the Droplet for Internal Kernel Management
The easiest way to find out whether your Droplet natively uses internal kernels or whether it must leverage the GrubLoader kernel is to check in the DigitalOcean control panel.
On your Droplet's page, Click on the Kernel item in the navigation:

You will be taken to the kernel management page.
If your page has a message about internal kernel management like this, your Droplet is set to use internal kernels natively:

If instead, you see a drop down menu allowing you to change your kernel, your Droplet is using legacy external kernel management:

If your Droplet uses external kernel management, switch to the GrubLoader by searching for "grub" in the search box. Select one of the resulting kernels and click the Change button:

Next, log into your Droplet as root or a sudo user. You must completely power off the Droplet to change to the GrubLoader kernel:
- sudo poweroff
When the Droplet is powered down, return to the control panel. Click on the Power menu item on the Droplet's page:

On the next page, click the Power On button:

Your Droplet should now boot, using the new GrubLoader kernel. You can now use kernels installed from within the operating system itself.
Check Which Kernel is Currently in Use
Before upgrading your kernel, you should check the version of the kernel that you are currently using.
To display both the kernel version and your system's architecture (32-bit or 64-bit), type:
- uname -ir
This will display something similar to this:
Output3.13.0-43-generic x86_64
The first part represents your kernel version (in this case 3.13.0-43-generic) and the second item tells you the architecture (in this example, the system is 64-bit). The kernel displayed is the one currently being used to operate your Droplet.
Upgrading All Packages and Using the Newest Kernel
One way to change the kernel to the most recent version is to apply all available package upgrades to your server. This will pull in the latest stable kernel if available.
Ubuntu and Debian
To update all of the packages on your Ubuntu or Debian Droplet, including the kernel, type:
- sudo apt-get update
- sudo apt-get dist-upgrade
Reboot to implement the changes:
- sudo reboot
CentOS and Fedora
To update all of the packages on your CentOS or Fedora Droplet, including the kernel, type:
yum with dnf to avoid a few warnings.- sudo yum update
Reboot to implement the changes:
- sudo reboot
Upgrading Only the Latest Kernel
If you do not wish to update other packages on your system, you can target the kernel for updating specifically.
Ubuntu
If you only wish to update the kernel itself, in Ubuntu, type:
- sudo apt-get update
- sudo apt-get install linux-virtual
Reboot the Droplet to implement the changes:
- sudo reboot
Debian
If you are using a 64-bit distribution of Debian, you can update just the kernel related packages by typing:
- sudo apt-get update
- sudo apt-get install linux-image-amd64 linux-headers-amd64
If you are using a 32-bit distribution of Debian, you can update just the kernel related packages by typing:
- sudo apt-get update
- sudo apt-get install linux-image-686-pae linux-headers-686-pae
Reboot the Droplet to implement the changes:
- sudo reboot
CentOS and Fedora
To upgrade just the kernel, type:
yum with dnf to avoid a few warnings.- sudo yum update kernel
Reboot to implement the changes:
- sudo reboot
Installing an Arbitrary Kernel on a Droplet
The process for switching to a kernel other than the latest is a bit more complicated. The
first step is to locate the kernel package you wish to use and install it.
Ubuntu and Debian
You can search the apt repositories for available kernels by typing:
- sudo apt-get update
- apt-cache search --names-only linux-image
You should see a list of the available kernels, which may look like this:
Outputlinux-image-4.4.0-21-generic - Linux kernel image for version 4.4.0 on 64 bit x86 SMP
linux-image-4.4.0-21-lowlatency - Linux kernel image for version 4.4.0 on 64 bit x86 SMP
linux-image-extra-4.4.0-21-generic - Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
linux-image-extra-virtual - Transitional package.
linux-image-extra-virtual-lts-utopic - Transitional package. (dummy transitional package)
linux-image-extra-virtual-lts-vivid - Transitional package. (dummy transitional package)
linux-image-extra-virtual-lts-wily - Transitional package. (dummy transitional package)
. . .
Find the package name for the kernel you wish to install.
Install the exact package name you find. It is also usually a good idea to install the associated headers file. You can do this by using the same package name, substituting only the image component in the package name with headers:
- sudo apt-get install linux-image-4.4.0-21-generic linux-headers-4.4.0-21-generic
Now that the kernel is installed, skip ahead to the section on finding which boot loader is being used to learn how to boot into the kernel.
CentOS and Fedora
To search for available kernels in RHEL-based distros, type:
- yum list --showduplicates kernel
You will see a list of the installed and available kernels:
Output. . .
Installed Packages
kernel.x86_64 3.10.0-327.22.2.el7 @updates
Available Packages
kernel.x86_64 3.10.0-327.el7 base
kernel.x86_64 3.10.0-327.3.1.el7 updates
kernel.x86_64 3.10.0-327.4.4.el7 updates
kernel.x86_64 3.10.0-327.4.5.el7 updates
kernel.x86_64 3.10.0-327.10.1.el7 updates
kernel.x86_64 3.10.0-327.13.1.el7 updates
kernel.x86_64 3.10.0-327.18.2.el7 updates
kernel.x86_64 3.10.0-327.22.2.el7 updates
The package name can be constructed by combining kernel- with the version from the second column.
Install the kernel by typing:
- sudo yum install kernel-3.10.0-327-18.3.el7
Now that the kernel is installed, we need to make some modifications to boot into it. Find out which boot loader you are using below.
Discovering Which Bootloader the Droplet Uses
By default, your Droplet will boot to the highest versioned kernel. To override this and select a different kernel, you'll have to modify the kernel that the boot loader will load by default. The exact procedure necessary depends heavily on the type of boot loader installed on your Droplet.
Here are the distributions broken down by boot loader:
- Grub 2:
- Debian 8
- Debian 7
- Ubuntu 16.04
- Ubuntu 14.04
- Ubuntu 12.04
- CentOS 7
- Fedora 23
- Grub 1:
- CentOS 6
- CentOS 5
- Syslinux:
- Fedora 24
Choose the procedure that matches the boot loader installed on your Droplet.
Booting to a Non-Default Kernel on Grub 2 Distributions
Once again, the following distributions use the Grub 2 boot loader:
- Debian 8
- Debian 7
- Ubuntu 16.04
- Ubuntu 14.04
- Ubuntu 12.04
- CentOS 7
- Fedora 23
The appropriate procedure will depend on whether your image uses native internal kernels, or whether you are leveraging the GrubLoader kernel from within the DigitalOcean control panel.
For Droplets with Native Internal Kernel Management
If your Droplet uses internal kernels natively, there is quite a bit of flexibility in selecting new kernels.
Edit Grub Settings to Allow Dynamic Management
The first step will be to adjust a few settings that dictate how Grub will choose the default kernel.
Open the /etc/default/grub file with your editor:
- sudo nano /etc/default/grub
Find and modify the following settings. If the settings are not present in your version of the file, add them:
. . .
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
GRUB_DISABLE_SUBMENU=y
. . .
The GRUB_DEFAULT setting will allow Grub to use whatever value we save as the default kernel instead of hard-coding a default. The GRUB_SAVEDEFAULT tells Grub to set the default kernel to anything we explicitly select in a menu. The GRUB_DISABLE_SUBMENU option flattens the menu structure so that we can more easily parse it. Grub 2 does not include a utility to display its menu on the command line, so you must manually parse the configuration.
Make sure there is only one occurrence of each setting in the file. Save and close the file when you are finished.
Next, if you are running a Debian or Ubuntu Droplet, you will need to make a quick edit to a DigitalOcean-specific Grub file:
- sudo nano /etc/default/grub.d/50-cloudimg-settings.cfg
This file is necessary for the DigitalOcean to boot the image properly. However, it contains a default selection that will override our settings in /etc/default/grub. Comment out the GRUB_DEFAULT line if one is present:
#GRUB_DEFAULT=0
Save and close the file when you are finished.
Regenerate the grub.cfg File
Next, we need to find out where the grub.cfg file is located on the Droplet. This will vary depending on which distribution you are using. We will set an environmental variable called GRUB_CONFIG that we can use in the procedures to follow:
- export GRUB_CONFIG=`sudo find /boot -name "grub.cfg"`
Next, rebuild the grub.cfg file with the changes we've made.
On Ubuntu and Debian, rebuild the file by typing:
- sudo update-grub
On CentOS and Fedora, rebuild the file using the environmental variable by typing:
- sudo grub2-mkconfig -o $GRUB_CONFIG
Display Available Kernels
Now that the configuration is rebuilt, and the menu is flattened, we can parse the file for the available entries. The following command will display the entry index number and title. Either of these can be used to refer to a specific entry:
- sudo grep 'menuentry ' $GRUB_CONFIG | cut -f 2 -d "'" | nl -v 0
You should see all of your available boot options:
Output 0 CentOS Linux (3.10.0-327.22.2.el7.x86_64) 7 (Core)
1 CentOS Linux (3.10.0-327.18.2.el7.x86_64) 7 (Core)
2 CentOS Linux (0-rescue-d4c27651599f460481bc723aafe36177) 7 (Core)
3 CentOS Linux (0-rescue-ce700ac27e6f4161b0730bad2182e0b1) 7 (Core)
Take a note of the index number or title of the entry you wish to boot.
Set a New Default Kernel
Grub includes commands to set a new default kernel from the command line. You can use either the index number or the entry title to specify a boot option.
For Ubuntu and Debian users, a new kernel can be set by index like this:
- sudo grub-set-default 2
Or by entry title like this:
- sudo grub-set-default 'Ubuntu, with Linux 4.4.0-24-generic'
For CentOS and Fedora Droplets, the following can be used to set a new default by index:
- sudo grub2-set-default 1
You can set the entry by title by typing:
- sudo grub2-set-default 'CentOS Linux (3.10.0-327.18.2.el7.x86_64) 7 (Core)'
Set a Temporary Kernel
You can also choose a temporary boot option. This will apply to the next boot only. You can use either the index number of the entry title to specify a boot option.
For Ubuntu and Debian users, a new kernel can be set by index like this:
- sudo grub-reboot 2
Or by entry title like this:
- sudo grub-reboot 'Ubuntu, with Linux 4.4.0-24-generic'
For CentOS and Fedora Droplets, a temporary kernel can be selected by index by typing:
- sudo grub2-reboot 1
Or by entry title like this:
- sudo grub2-reboot 'CentOS Linux (3.10.0-327.18.2.el7.x86_64) 7 (Core)'
Reboot the Droplet
Once you've selected the kernel to use, reboot the Droplet:
- sudo reboot
Your Droplet should now boot into the kernel you selected.
For Droplets Using the GrubLoader Kernel
If your Droplet uses the GrubLoader kernel in the control panel to implement internal kernels, you will have to follow a different procedure.
Flatten the Grub Menu
Open the /etc/default/grub file with your editor:
- sudo nano /etc/default/grub
Find and modify the following setting. If the setting is not present in your version of the file, add it:
. . .
GRUB_DISABLE_SUBMENU=y
. . .
The GRUB_DISABLE_SUBMENU option flattens the menu structure so that we can more easily parse it. Grub 2 does not include a utility to display its menu on the command line, so you must manually parse the configuration.
Make sure there is only one occurrence of this setting. Save and close the file when you are finished.
Regenerate the grub.cfg File
Next, let's find out where the grub.cfg file is located on the image. This will vary depending on which distribution you are using. We will set an environmental variable called GRUB_CONFIG that we can use in the procedures to follow:
- export GRUB_CONFIG=`sudo find /boot -name "grub.cfg"`
Next, rebuild the grub.cfg file with the changes we've made.
On Ubuntu and Debian, rebuild the file by typing:
- sudo update-grub
On CentOS and Fedora, rebuild the file using the environmental variable we set:
- sudo grub2-mkconfig -o $GRUB_CONFIG
Now that the configuration is rebuilt and the menu is flattened, we can parse the file for the available entries.
Display Available Kernels
The following command will display the entry index number and title. Either of these can be used to refer to a specific entry:
- sudo grep 'menuentry ' $GRUB_CONFIG | cut -f 2 -d "'" | nl -v 0
You should see all of your available boot options:
Output 0 CentOS Linux (3.10.0-327.22.2.el7.x86_64) 7 (Core)
1 CentOS Linux (3.10.0-327.18.2.el7.x86_64) 7 (Core)
2 CentOS Linux (0-rescue-d4c27651599f460481bc723aafe36177) 7 (Core)
3 CentOS Linux (0-rescue-ce700ac27e6f4161b0730bad2182e0b1) 7 (Core)
Note the index number or the title of the entry you wish to select.
Set the New Default Kernel
Now, you can select an entry to boot.
Open up the /etc/default/grub file again:
- sudo nano /etc/default/grub
Look for the GRUB_DEFAULT setting. Set this to either the numerical index of the entry you discovered, or the title of the entry:
. . .
GRUB_DEFAULT=1
. . .
Save and close the file when you are finished.
Next, if you are running a Debian or Ubuntu Droplet, you will need to make a quick edit to a DigitalOcean-specific Grub file:
- sudo nano /etc/default/grub.d/50-cloudimg-settings.cfg
This file is necessary for the DigitalOcean to boot the image properly. However, it contains a default selection that will override our settings in /etc/default/grub. Comment out the GRUB_DEFAULT line in this file:
#GRUB_DEFAULT=0
Save and close the file.
Regenerate the grub.cfg File a Second Time
Next, regenerate the grub.cfg file using the same procedure as before. This will apply our default selection.
On Ubuntu and Debian, rebuild the file by typing:
- sudo update-grub
On CentOS and Fedora, rebuild the file using the environmental variable we set:
- sudo grub2-mkconfig -o $GRUB_CONFIG
Reboot the Droplet
When you're ready, reboot the Droplet:
- sudo reboot
Your Droplet should now boot into the kernel you selected.
Booting to a Non-Default Kernel on Grub 1 Distributions
The following distributions use the Grub 1 boot loader:
- CentOS 6
- CentOS 5
These distributions only have internal kernel management available with the GrubLoader kernel from the DigitalOcean control panel. The GrubLoader kernel can only boot to the highest available kernel when dealing with the Grub 1 boot loader.
To boot to a different kernel, you must remove other entries. While this is generally not a problem, we recommend that you take a snapshot of your Droplet before proceeding.
Display Installed Kernels
The yum tool actually does not let you uninstall the currently running kernel. Because of this, we'll have to use the rpm package manager to work around this.
To display the list of currently installed kernels, type:
- rpm -q kernel
You should see a list of the kernel packages currently installed:
Outputkernel-2.6.18-410.el5
kernel-2.6.18-409.el5
Remove Other Kernels
Next, remove all of the kernels but the one you wish to boot into:
- sudo rpm -e kernel-2.6.18-410.el5
Repeat this procedure until you only have a single kernel installed.
Reboot the Droplet
To boot into the kernel, reboot your Droplet:
- sudo reboot
Your Droplet should now boot into the remaining kernel.
Booting to a Non-Default Kernel on Syslinux Distributions
The following distributions use the Syslinux boot loader:
- Fedora 24
The Syslinux boot loader makes it quite easy to change the default kernel that will be used during boot.
Edit the extlinux.conf Configuration File
To change the default kernel used to boot, open the /boot/extlinux/extlinux.conf file:
- sudo nano /boot/extlinux/extlinux.conf
Among other items, inside you should see a default directive, followed by entries for each kernel installed on the system:
. . .
default Fedora (4.6.4-301.fc24.x86_64) 24 (Cloud Edition)
label Fedora (4.6.4-301.fc24.x86_64) 24 (Cloud Edition)
. . .
label Fedora(4.5.5-300.fc24.x86_64)
. . .
To boot to a different selection, simply modify the default directive to use a different entry title:
. . .
#default Fedora (4.6.4-301.fc24.x86_64) 24 (Cloud Edition)
default Fedora(4.5.5-300.fc24.x86_64)
label Fedora (4.6.4-301.fc24.x86_64) 24 (Cloud Edition)
. . .
label Fedora(4.5.5-300.fc24.x86_64)
. . .
Save and close the file when you are finished.
Reboot the Droplet
To boot into the kernel, reboot your Droplet:
- sudo reboot
Your Droplet should now boot into the new default kernel.
Conclusion
By following along with this guide, you should be able to manage your kernels with ease. If you need additional assistance, please leave a comment below or open a support ticket in the control panel.

33 Comments