[KVM Linux] Upgrading kernel version

Giedrius
Giedrius
edited December 2017 in KVM Based Servers
Our KVM VPS has a possibility of upgrading kernel version which is one of the most common reasons why some of the customers chooses the KVM VPS over the Standard VPS. Higher version of kernel is required by some of the applications or services.

By default does not have the latest kernel version available so this article might help to resolve the case. We will provide the details on how to manually change your kernel version.

First, it is always good to know, what is the current version of your kernel, you can check that with the following command:
uname -sr
The outcome should be simple and specific:

Linux 4.14.0-041400-generic

Kernel upgrade for Ubuntu

Secondly, you need to download the required files for your chosen kernel version. All the available kernel versions can be found in this page:

http://kernel.ubuntu.com/~kernel-ppa/mainline/

Source provides all the required files for kernel to upgrade. Once you check the specific version of Kernel you may see many links to download, for example:

Build for amd64 succeeded (see BUILD.LOG.amd64):
  linux-headers-4.13.0-041300_4.13.0-041300.201709031731_all.deb
  linux-headers-4.13.0-041300-generic_4.13.0-041300.201709031731_amd64.deb
  linux-headers-4.13.0-041300-lowlatency_4.13.0-041300.201709031731_amd64.deb
  linux-image-4.13.0-041300-generic_4.13.0-041300.201709031731_amd64.deb
  linux-image-4.13.0-041300-lowlatency_4.13.0-041300.201709031731_amd64.deb


The first one is required, and then you need the rest of 2, which both has to match for example: both generic or both lowlatency.

You download all the files for example:
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14/linux-headers-4.14.0-041400-generic_4.14.0-041400.201711122031_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14/linux-image-4.14.0-041400-generic_4.14.0-041400.201711122031_amd64.deb
wget http://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14/linux-headers-4.14.0-041400_4.14.0-041400.201711122031_all.deb
Once the download is complete you need to install it with the following command:
dpkg -i *.deb
It may take up to few minutes, but once it is done you have to reboot the system for changes to become active:
reboot
After reboot you may check and make sure the kernel version is upgraded:
uname -sr
That is it. Your Kernel version is upgraded for your Ubuntu system.

Kernel upgrade for CentOS

We will be using ELRepo, a third-party repository that makes the upgrade to a recent version a kernel. To enable these repository you will need to execute the following commands:
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm 
Once you install the repositories, you will need to list the available packages:
yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
You will be presented will all the available packages, like this:

We will choose the main kernel package: kernel-ml (it is not shown in the image above since we installed it already). To upgrade your Kernel to the latest version use the following command:
yum --enablerepo=elrepo-kernel install kernel-ml
After the upgrade reboot the server:
reboot
Check the kernel version again:
uname -sr 
Kernel version may not be changed instantly, so you will have to do the last changes and set default Kernel version in GRUB. Open a GRUB configuration:
nano /etc/default/grub
You will have to change one line as in the example below and save it:
GRUB_DEFAULT=0
The following command will recreate the Kernel configuration within GRUB:
grub2-mkconfig -o /boot/grub2/grub.cfg
One final reboot is need after this, and your Kernel version will be changed.

Comments

  • fedotovs
    fedotovs
    Member
    Why not just in Ubuntu to do something like
    apt update 
    apt dist-upgrade

    or something similar?

    It is more safe, isn't it?

  • Giedrius
    Giedrius
    Moderator
    Hello fedotovs,

    in general your suggested option upgrades the kernel version to the newest version. While our suggested option lets you to download files for specific kernel version if needed.

    Also, here is more information about apt-dist update, which actually not only upgrade kernel version but does more, which is some cases is not needed:

    http://manpages.ubuntu.com/manpages/zesty/en/man8/apt-get.8.html

    We believe our option is safer because it is only upgrading kernel and not other packages as well.
     

  • TomasD
    TomasD
    Member
    Have created a new VPS, followed this tutorial without any success, it was failing to install one of .deb with exit code 1 and 2. 
    Also then tried to do what fedotovs suggested, kernel is still in 2.6.

    After that tried to install  kernel manually, there was no errors, but after reboot kernel version is still 2.6. 

    here is the errors that I was getting when have followed this guide just after reinstalling OS. 

    [email protected]:~/kernel# sudo dpkg -i *.deb 
    Selecting previously unselected package linux-headers-4.14.0-041400-generic.
    (Reading database ... 67934 files and directories currently installed.)
    Preparing to unpack linux-headers-4.14.0-041400-generic_4.14.0-041400.201711122031_amd64.deb ...
    Unpacking linux-headers-4.14.0-041400-generic (4.14.0-041400.201711122031) ...
    Selecting previously unselected package linux-headers-4.14.0-041400.
    Preparing to unpack linux-headers-4.14.0-041400_4.14.0-041400.201711122031_all.deb ...
    Unpacking linux-headers-4.14.0-041400 (4.14.0-041400.201711122031) ...
    Selecting previously unselected package linux-image-4.14.0-041400-generic.
    Preparing to unpack linux-image-4.14.0-041400-generic_4.14.0-041400.201711122031_amd64.deb ...
    locale: Cannot set LC_CTYPE to default locale: No such file or directory
    locale: Cannot set LC_MESSAGES to default locale: No such file or directory
    locale: Cannot set LC_ALL to default locale: No such file or directory
    Done.
    Unpacking linux-image-4.14.0-041400-generic (4.14.0-041400.201711122031) ...
    Setting up linux-headers-4.14.0-041400 (4.14.0-041400.201711122031) ...
    Setting up linux-image-4.14.0-041400-generic (4.14.0-041400.201711122031) ...
    Running depmod.
    update-initramfs: deferring update (hook will be called later)
    The link /initrd.img is a dangling linkto /boot/initrd.img-4.13.16-041316-generic
    Examining /etc/kernel/postinst.d.
    run-parts: executing /etc/kernel/postinst.d/apt-auto-removal 4.14.0-041400-generic /boot/vmlinuz-4.14.0-041400-generic
    run-parts: executing /etc/kernel/postinst.d/initramfs-tools 4.14.0-041400-generic /boot/vmlinuz-4.14.0-041400-generic
    update-initramfs: Generating /boot/initrd.img-4.14.0-041400-generic
    E: /usr/share/initramfs-tools/hooks/fixrtc failed with return 1.
    update-initramfs: failed for /boot/initrd.img-4.14.0-041400-generic with 1.
    run-parts: /etc/kernel/postinst.d/initramfs-tools exited with return code 1
    Failed to process /etc/kernel/postinst.d at /var/lib/dpkg/info/linux-image-4.14.0-041400-generic.postinst line 1052.
    dpkg: error processing package linux-image-4.14.0-041400-generic (--install):
     subprocess installed post-installation script returned error exit status 2
    Setting up linux-headers-4.14.0-041400-generic (4.14.0-041400.201711122031) ...
    Errors were encountered while processing:
     linux-image-4.14.0-041400-generic





    Not being able to run new Kernel, prevents me from being able to use Docker for my containers. 

    Why not just allow to choose kernel as you allow to choose OS to install on control panel?

  • Giedrius
    Giedrius
    Moderator
    Hey TomasD,

    it seems you have a standard VPS, which runs on OpenVZ virtualization. It uses the latest stable kernel for this virtualization - 2.6.32 and it can't be upgraded. Therefore, Docker is not supported in our Standard VPS.

    I would suggest you look into our KVM VPS, which allows kernel upgrade and supports Docker:

    https://www.time4vps.eu/kvm-linux-vps/

  • TomasD
    TomasD
    Member
    Opps, my mistake. Glad that I just bought it for 1 month to test it out. 
    Thanks, will try KVM.

    Giedrius said:
    Hey TomasD,

    it seems you have a standard VPS, which runs on OpenVZ virtualization. It uses the latest stable kernel for this virtualization - 2.6.32 and it can't be upgraded. Therefore, Docker is not supported in our Standard VPS.

    I would suggest you look into our KVM VPS, which allows kernel upgrade and supports Docker:

    https://www.time4vps.eu/kvm-linux-vps/


Sign In or Register to comment.
© 2013 - 2018 Time4VPS. All rights reserved. Powered by Vanilla
The opinions or views of users on the forum are those of the author and not of Time4VPS.