Nội dung
This guide only applies to SSD KVM VPS service.
By default, Ubuntu 16.04 now comes with a kernel version 4.4.0-21-generic
. You can manually check the kernel version on the VPS using the following command:
uname -r
To change another kernel version for Ubuntu 16.04 operating system, you can follow the following instructions.
Find kernel version
First, we will find the kernel version available in the apt package with the following two commands:
sudo apt-get update apt-cache search --names-only linux-image
A list of kernel versions will appear, you just need to find the version you need to install and change the version number in the installation command below:
sudo apt-get install linux-image-4.4.0-75-generic linux-headers-4.4.0-75-generic
If the system asks you to create the file /boot/grub/menu.lst
, please choose Y
.
For kernel version not in library
If you need to install a kernel version that is unavailable in the library, find the kernel version at http://kernel.ubuntu.com/~kernel-ppa/mainline/. You choose the folder for the version you want to download and download the two filesgeneric
and all
for amd64. For example:
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9.24/linux-headers-4.9.24-040924-generic_4.9.24-040924.201704210431_amd64.deb wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9.24/linux-image-4.9.24-040924-generic_4.9.24-040924.201704210431_amd64.deb wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.9.24/linux-headers-4.9.24-040924_4.9.24-040924.201704210431_all.deb
Then install all the downloaded files:
sudo dpkg -i *.deb
Now you can follow the steps below to finish.
Set kernel version at boot
Edit the /etc/default/grub
file
nano /etc/default/grub
Find GRUB_DEFAULT=0
and change to GRUB_DEFAULT=saved
. Then add the following 2 sentences below:
GRUB_SAVEDEFAULT=true GRUB_DISABLE_SUBMENU=y
Then recreate the grub.cfg
file:
export GRUB_CONFIG=sudo find /boot -name "grub.cfg"
And rebuild this file:
sudo update-grub
Next, we will use the following command to display the list of installed kernel versions:
grep 'menuentry ' $GRUB_CONFIG | cut -f 2 -d "'" | nl -v 0
Now, if you need to use which kernel version, you just need to use the grub-set-default command to set it up. For example, if you want to use the kernel version with the ordinal number 0, use the command:
grub-set-default 0
Note that we do not use recovery mode versions.
And reboot the VPS.
reboot
After the VPS reboot is complete, log in to VPS again and check the kernel version with the uname -r
command.