17 C
Jaipur
Sunday, December 6, 2020

How To Upgrade Linux Kernel On Various Distributions [Tutorial]

Must read

Spence vs Garcia live stream: how to watch the fight online anywhere and for free

Having survived a near fatal car crash, Errol Spence Jr returns to the ring on Saturday to defend his unified Welterweight titles against two-weight...

Top Christmas gifts for PlayStation gamers: from the PS5 to cool merchandise

Struggling to think of the best Christmas gifts for PlayStation gamers? When you eventually get a wish list from your family or friends that...

mobile Internet: US House Democrats adopt mobile internet voting for leadership contests – Latest News

US lawmakers used a mobile phone app over the last two weeks to remotely cast votes for the first time, according to technologists and...

Thanks PS5 and Xbox Series X for making ray tracing cool

When the Nvidia GeForce RTX 2080 and RTX 2080 Ti made their debut way back at Gamescom 2018, the way Nvidia CEO Jensen Huang...

A kernel is the core of any operating system. Before you start calling Linux an operating system, you need to know the basic concept and Linux’s birth history. Linux is not an operating system; mainly, Linux is a kernel. Now, Let’s get to know about what a Kernel is! A kernel is a program that interacts between your hardware and software. When you insert any flash drive into your system, the Kernel detects that you have plugged in a pen drive. As Linux is an open-source kernel, you can update, upgrade and replace the Linux kernel if you know what you’re doing.

What is the Linux Kernel?


Your CPU, memory, and devices communicate with the operating system through the Kernel. As we are talking about the Linux Kernel, I must mention that there are two user modes in every Linux distributions. You get a user mode and a Kernel-mode in Linux distributions. Typically, you can’t access the Kernel mode from the standard user mode interface.

It would help if you got the root privileges to access the Kernel mode. When you start your Pc, no software runs in the thread; the Kernel decides what to do and what not to do. The Kernel decides which application will get how much RAM and CPU.

Upgrade Kernel on Linux Distributions


Upgrading the Linux kernel is not easy; you must do this only if you find security errors or hardware interaction issues. If your system crashes, you might have to recover the whole system. Mostly, Linux distributions come with the most upgraded kernel. Upgrading the Linux kernel doesn’t delete or remove the previous kernel; it is kept inside the system.

You can roll back to the older kernel from the recovery menu of your Linux system. However, you may need to upgrade the kernel for hardware issues or security issues. In this post, we will see how you can upgrade the kernel on various Linux distributions.

Know the Current Kernel Version


Before you start upgrading your Linux kernel, you must know the Kernel’s current version running inside your PC. This step will use the Neofetch tool to check the Linux kernel details and other system information.

If you don’t have the Neofetch installed inside your system, I’ll guide you to install the Neofetch on your Linux distribution. Use the following command-line given below on your Linux terminal according to your distribution.

  • Install Neofetch on Debian / Ubuntu
sudo apt-get update
sudo apt-get install neofetch
  • Install Neofetch on Fedora
sudo dnf install neofetch
  • Install Neofetch on Red Hat / CentOS
sudo yum install neofetch
  • Install Neofetch on Arch and Arch-based Linux
pacman -S neofetch

After the installation is done, you can now check the Kernel version by running the Neofetch tool.

$ neofetch

Upgrade Linux Kernel neofetch

1. Upgrade Kernel on Ubuntu and Debian Linux


Various Linux distributions have different methods to upgrade the Linux kernel. Debian and Ubuntu-based Linux distributions have a few ways that you can follow to update and upgrade the kernel. Here, I will show five methods that you can follow to upgrade the kernel on your Debian Linux.

Method 1: Use dist upgrade to Upgrade the Kernel


You may have familiar with the update and upgrade commands of Linux. You can update your system repository through your system updater and apt-update command from the terminal shell. But the Dist upgrade is a bit more than upgrading the system and packages. It upgrades the Kernel, software, and other package dependencies. You can run the following dist-upgrade command to upgrade your Linux kernel.

sudo apt-get dist-upgrade

Running a full-upgrade command is always thoughtful to finish the upgrading process.

sudo apt full-upgrade

Method 2: Force the System Update Manager


Every Linux system has a built-in Update Manager inside the OS. You might have used the updater for a million times to update your system. But, did you know that you can force the Update Manager to upgrade your Linux kernel? You can run the following command-line on your terminal shell to force your updater to download and install the upgraded Linux kernel. It may download a few additional packages.

update-manager –d

Upgrade Linux Kernel update

Method 3: Use the Ukuu Tool


The Ukuu is a tool for Linux distributions that can download and install the latest Linux kernel from the official repository of your Linux distribution. For Ubuntu, it downloads kernel from https://kernel.ubuntu.com/.

To upgrade your Linux Kernel through the Ukuu tool, you first need to install the Ukuu tool on your Linux system. Use the PPA command to add the Ukuu packages inside your system repository.

sudo apt-add-repository ppa:teejee2008/ppa

Now update your system and install the Ukuu tool.

sudo apt-get update
sudo apt-get install ukuu

Once the Ukuu is installed inside your machine, you can run the Ukuu tool from your terminal shell with root access. After launching the Ukuu tool, you will find a list of available Linux kernels for your operating system. You have to select the kernel to install it inside your system.

sudo ukuu-gtk

Ukku

Once your kernel is upgraded, you can remove the Ukuu tool from your system. I may note that, if you find any problem to install the Ukuu tool, there is a chance that the Ukuu team no longer supports your version of Ukuu. However, a paid version of Ukuu is available for Linux; you can use the paid version to upgrade the kernel on Ubuntu Linux.

Method 4: Download and Install Kernels Manually


In this method, we will download the Linux kernel manually from the official store of Ubuntu kernel. Later we will install the kernel packages on our system. This method is the most dangerous method among all the methods that I have shown previously. Please make a backup of all your system and data before you initialize this method.

To download your desired Linux kernel, you have to go to the Ubuntu Kernel archive. Download the following kernel packages from Kernel mainline. You need to download the kernel header and kernel version to make a complete package. For better understanding, you can see the following dummy package lists that you need to download.

linux-headers-VERSION-NUMBER_all.deb
linux-headers-VERSION-NUMBER_amd64.deb
linux-image-VERSION-NUMBER_amd64.deb
linux-image-extra-VERSION-NUMBER_amd64.deb

Once the download is finished, you can now open your directory to install the packages. As all the packages are in .deb format, you can use the dpkg tool to install the packages. To install the packages, use the following command-lines.

cd /path/to/directory/destination_path

Now, install the .deb Kernel packages on your Debian system.

sudo dpkg -i *.deb

Method 5: Upgrade Linux Kernel Via the Mainline Tool


This method will see how you can upgrade your Linux kernel through the Mainline tool on Ubuntu and other Debian distributions. First, you have to install the Mainline tool on your system. Use the following command lines to add the mainline repository to your system. Then install the Mainline tool.

sudo apt-add-repository -y ppa:cappelikan/ppa
sudo apt update
sudo apt install mainline

Upgrade Linux Kernel install mainline

Now use the following wget command to download the kernel from the Ubuntu mainline kernel directory.

wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh

The download won’t take much longer. After the download is finished, run the following command-lines on your terminal shell to install the latest kernel on your Ubuntu Linux.

sudo install ubuntu-mainline-kernel.sh /usr/local/bin/
ubuntu-mainline-kernel.sh -i

Wget download mainline

Now, reboot your system and check the available kernel versions for your Linux distribution. You can install your desired Linux kernel from the kernel installer. To install a new kernel, select the kernel and click on the install button. Once the installation is done, reboot your device to load the new kernel. You can check the kernel version to make sure that your kernel is upgraded.

Upgrade Linux Kernel ML

You can remove the mainline tool from your Ubuntu system after your kernel installation is done. Use the following command-lines given below to remove the mainline tool from Ubuntu Linux.

sudo add-apt-repository --remove ppa:cappelikan/ppa
sudo apt remove mainline

2. Upgrade kernel on Red Hat and Fedora Linux


Fedora, Red Hat, and Red Hat-based Linux distribution users can upgrade their Linux kernel manually by downloading the kernel from the repository. Here, I will show the general method of upgrading the kernel. Red Hat Linux and CentOS users can use the yum command; on the other hand, Fedora users have to replace the yum with the DNF command. The rest of the command-lines are the same for both distributions.

Method 1. Install a Specific version of Kernel


Fedora and Red Hat Linux users can install a specific version of Kernel on their system. You can run the following command-line on your Linux terminal to install any specific version kernel on your Linux system. After the installation is done, reboot your system to get the desired kernel on your Linux system.

yum update kernel
yum install kernel-{version}

Method 2. Upgrade Kernel on RHEL and Fedora Linux


First, you have to install the SysLinux tool on your system. Mostly the SysLinux comes pre-installed on Fedora and Red Hat Linux distributions. If you can’t find the tool on your machine, you can use the following command to install it.

yum install syslinux

When you add a kernel to your system, it enlists the kernel name and version to the boot menu. Now, configure the SysLinux for your boot loader directory. Use the following syslinux command to configure the boot loader directory. In my case, the boot directory is sdb2; you must replace the directory with yours.

syslinux /dev/sdb2

Now, create a directory and a mount point to store the kernel. Don’t forget to mount the boot.iso file on the USB disk.

mkdir /mnt/isoboot /mnt/diskboot
mount -o loop boot.iso /mnt/isoboot
mount /dev/sdb2 /mnt/diskboot

Then use the following cp command to copy the files on the USB disk and mount the partition.

cp /mnt/isoboot/isolinux/* /mnt/diskboot

In this stage, we will run the following grep command to run the boot loader files from the isolinux configuration script. Then, we will mount the isoboot file inside the diskboot directory. Here, we are using the SysLinux tool to load the kernel along with the bootloader menu.

grep -v local /mnt/isoboot/isolinux/isolinux.cfg > /mnt/diskboot/syslinux.cfg
umount /mnt/isoboot /mnt/diskboot

Before you reboot your system, you can check all the installed kernel lists on your Red Hat Linux system.

yum list installed "kernel-*"

Now, use the following rpm command to download your desired version of the Linux kernel. As we are not removing the old kernel, so we will use the -i syntax at the command-line. If you want to delete and install the new kernel, you may use the -u instead of the -i argument.

rpm -ivh kernel-kernel_version.arch.rpm

Now, check whether the new kernel is enlisted on the boot menu or not.

ls /boot

Here, we will use the most popular Dracut boot package installer for Red Hat and Fedora Linux. The Dracut will create the kernel image.

dracut "initramfs-$(uname -r).img" $(uname -r)

Now load the previously downloaded kernel file on the system memory. Use the following lsinitrd command to call the initramfs image.

lsinitrd /boot/initramfs-3.10.0-78.el7.x86_64.img

Now, run the following grep command to initialize the GRUB loading process. Please handle this step carefully to avoid grub loading errors.

grep initramfs /boot/grub2/grub.cfg

Now, check the boot loader list.

ls -l /boot/

Then, use the Dracut tool to select the kernel version after rebooting the system. You can force your system to call the new updated kernel. The following command can help you to reconfigure the kernel and boot settings.

dracut --kver kernel_version --force

Now, use the following command-lines given below to create a shortlist of the kernel packages and the kernel versions.

lsinitrd
lsinitrd | grep etc/
lsinitrd -f /etc/sysctl.conf

Then run the following command-line on your terminal shell to define the kernel version.

lsinitrd --kver 3.10.0-327.10.1.el7.x86_64 -f /etc/sysctl.conf

Finally, you have to do a little script configuring to complete the kernel upgrading process. You have to make the default_kernel value as kernel and the update_default as true from the sysconfig directory. Use the /etc/sysconfig/kernel  path on your filesystem to find the configuration file. Now change the values as shown below.

DEFAULTKERNEL=kernel
UPDATEDEFAULT=yes

After everything is done correctly, you can now reboot your Linux system to get started with the upgraded kernel.

3. Upgrade the Kernel on Arch and Arch-based Linux


Arch and Arch-based Linux distributions have a dynamic variety of Linux kernel. Arch Linux updates its security patch regularly; that’s why you will see notable kernel and patch updates are available on Arch Linux. Here, I will describe two methods to upgrade the kernel on Arch Linux. First, I will go with the update and upgrade method; later, I’ll explain the manual method to upgrade the kernel on Arch Linux.

Method 1: Update and Upgrade the Kernel


Manjaro and other Arch Linux distributions often offer kernel updates and upgrades via the conventional update manager. When you run the system updater on the Linux system, it checks for the latest kernels. You can use the following pacman command to check for the latest kernel on Arch Linux distributions.

sudo pacman -Syu

If it finds a new kernel, it will notify you to download and install it. You can choose whether you want to get the latest kernel or not. Once you agree to install, reboot your system after the installation is finished. Then, you can check the kernel version to ensure whether the kernel is upgraded or not.

sudo reboot

Method 2: Manually Upgrade the Kernel on Arch Linux


In this method, we will see how you can manually download and install the latest kernel from the Linux kernel’s official website. In this method, you can install any available and supported kernel on your Arch Linux.

First, you have to download your desired version of the kernel from the Kernel.org website. The file will be downloaded as a compressed file. By default, the file will be stored inside the Downloads directory on your filesystem.

Now, use the following command-lines to open the Download directory and get the list of downloaded files. Then use the tar command to extract the compressed file. After the file is extracted, it will automatically create a folder; you can find kernel files inside the folder.

cd Downloads/
ls
tar xvf linux-4.15.2.tar.xz

Now, use the following command-line to enter the kernel directory. In my case, the kernel directory is named as linux-4.15.2, you may have a different name based on which version you have downloaded.

cd linux-4.15.2

Run the following command-line to get the ncurses library tool inside the GNU compiler collection. It will help you later to edit the configuration scripts of the Linux kernel.

sudo pacman -S ncurses make gcc bc openssl

Now, use the following zcat command to duplicate the configuration script from your running Linux kernel to the newly created kernel.

zcat /proc/config.gz > .config

You can now initialize the installation process of the new kernel inside your Linux system.

make menuconfig

Run the following command-lines given below to install the loadable kernel modules on your Arch Linux.

make
sudo make modules_install

Now, use the cp command to copy the vmlinuz file from your current kernel to the new kernel. You will need the vmlinuz file to load the kernel on the system boot. There are two commands given below, the first one is for 32-bit or 86-bit system users, and the last one is for 64-bit Linux users.

sudo cp -v arch/x86/boot/bzImage /boot/vmlinuz-4.15.2
sudo cp -v arch/x86_64/boot/bzImage /boot/vmlinuz-4.15.2

Run the following mkinitcpio bash command on your Arch Linux to create a temporary directory on the RAM to store the initramfs image file.

sudo mkinitcpio -k 4.15.2-ARCH -g /boot/initramfs-4.15.2.img

Now, use the following cp command to copy the kernel table to the new kernel’s directory.

sudo cp -v System.map /boot/System.map-4.15.2

Now you need to create a kernel map inside the boot directory.

sudo ln -sf /boot/System.map-4.15.2 /boot/System.map

Now, use the following command-line given below to install the GRUB on the boot directory and finish the kernel upgrading process.

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

After you have done everything correctly, reboot your Arch Linux. From the boot loader menu, open the ‘Advanced options for Arch Linux’. You will find that a new bootloader is created for the new kernel. You can also check your kernel version to ensure that the kernel is upgraded on your Arch Linux.

sudo reboot
uname -r

Sometimes updating the default kernel can solve your minor issues on Linux. However, you can also check your generic kernel version from the boot menu. If you only need to upgrade the Linux kernel on your systems, you can run the following commands on your Linux terminal shell.

sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get upgrade linux-image-generic

generic update default

Ending Words


If you make any mess and damage your kernel, no worries, you can remove your current kernel and re-install the Kernel and GRUB though the Boot Repair tool. In this entire post, I have described the fundamentals of the Linux kernel. I have also illustrated the methods of how you can upgrade the kernel on your Debian, Fedora, Arch, and Red Hat Linux.

Upgrading the kernel on Linux is not recommended if you are don’t have enough knowledge on booting, grub, and other root partition filesystems. We have used a few tools and command-lines to complete the process of upgrading the Linux kernel. It would be best to have the basic idea of those command-lines to build your customized kernel. Some experimental and beta versions of kernels are also available for various Linux distributions. Install those third-party kernels at your own risk.

Please share it with your friends and the Linux community if you find this post useful and informative. You let us know which version of kernel currently you’re using on your system. Write your opinions regarding this post in the comment section.

Source link

- Advertisement -

More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

Spence vs Garcia live stream: how to watch the fight online anywhere and for free

Having survived a near fatal car crash, Errol Spence Jr returns to the ring on Saturday to defend his unified Welterweight titles against two-weight...

Top Christmas gifts for PlayStation gamers: from the PS5 to cool merchandise

Struggling to think of the best Christmas gifts for PlayStation gamers? When you eventually get a wish list from your family or friends that...

mobile Internet: US House Democrats adopt mobile internet voting for leadership contests – Latest News

US lawmakers used a mobile phone app over the last two weeks to remotely cast votes for the first time, according to technologists and...

Thanks PS5 and Xbox Series X for making ray tracing cool

When the Nvidia GeForce RTX 2080 and RTX 2080 Ti made their debut way back at Gamescom 2018, the way Nvidia CEO Jensen Huang...

Spider-Man: Miles Morales has the most authentic character of 2020

Earth-616 is at peak Spidey fandom. After the successful integration of bringing Spider-Man into the ever-expanding MCU, the character was then reinvigorated in video...