Today, we will see about a similar tool called “Linux Kernel Utilities”. It is a set of BASH shell scripts that can be used to compile and / or update latest Linux kernels for Debian and derivatives.
Linux Kernel Utilities contains the following three scripts.
- compile_linux_kernel.sh – Compile and install the latest Linux Kernel from source,
- update_ubuntu_kernel.sh – Download and install or update the precompiled Ubuntu Kernel,
- remove_old_kernels.sh – Remove all inactive/unused Linux Kernels.
In this brief guide, I will explain how to install and use Linux Kernel Utilities in Ubuntu 16.04 LTS.
Scripts To Compile And Update Latest Linux Kernel
Install Linux Kernel Utilities
We can install Linux Kernel Utilities in two ways.
The recommended way to do this is git clone the repository using command:
git clone https://github.com/mtompkins/linux-kernel-utilities.git
The above command will clone the contents of the repository in a folder called “linux-kernel-utilities” in your current working directory.
Go that directory:
Make the scripts executable using command:
chmod 750 *.sh
Scripts will prompt to update when necessary. To update them, just run:
Another way to install this script is download the DEB packages and install it manually.
Go to the Releases page and download the latest version. As of writing this guide, the latest version was 1.1.6.
Then, install it as shown below.
sudo dpkg -i linux-kernel-utilities*.deb
All scripts will be installed under /opt location. You can execute the scripts from here.
To remove it, run:
sudo dpkg -r linux-kernel-utilities
Compile Linux Kernel
As I mentioned in the introduction section, Linux Kernel Utilities consists of three scripts. compile_linux_kernel.sh script is used to download and compile the latest Kernel from http://www.kernel.org website. This script will display the list available Linux Kernels in that site, so you can pick one from the list.
Run the following command to list the available Kernel. You don’t need to run these scripts as sudo or root user. You will be prompted to enter the root password or sudo password if necessary.
Click OK to continue.
The first time this script will install missing dependencies if there are any.
Next, select a Kernel from the list to download.
Just follow the onscreen instructions to compile and install the selected Linux Kernel.
To compile and install the latest available Linux Kernel, run:
Also, you can compile and install a Kernel from local archive file.
Download and install precompiled Linux Kernel
update_ubuntu_kernel.sh script will allow you to download and install or update the list of available Linux Kernels from https://kernel.ubuntu.com website.
To install precompiled Kernel from, run:
It will list all available precombiled Linux Kernels from Kernel.ubuntu.com website. Just enter any number from the list to install the required Kernel.
[...] [+] Retrieving available kernel choices . . . \_ Precompiled kernels available from kernel.ubuntu.com: 1) Linux v4.11 2) Linux v4.11.6 3) Linux v4.11.5 4) Linux v4.11.4 5) Linux v4.11.3 6) Linux v4.11.2 7) Linux v4.11.1 8) Linux v4.10 9) Linux v4.10.17 10) Linux v4.10.16 . . . . 253) Linux v4.0.9-wily 254) Linux v4.0.8-wily 255) Linux v4.0.7-wily 256) Linux v4.0.6-wily 257) Linux v4.0.5-wily 258) Linux v4.0.4-wily 259) Linux v4.0.3-wily 260) Linux v4.0.2-wily 261) Linux v4.0.1-wily 262) Linux v4.0-vivid Select your desired kernel:1
After installing the new Kernel, reboot and log in to newly installed Kernel.
To install latest available Linux Kernel, run:
The above command directly pick the latest available from the Kernel.ubuntu.com website and install it.
Remove inactive Linux Kernels
remove_old_kernels.sh script will remove inactive and unused Kernels from your Ubuntu system. Please be careful while using this script. It will only leave the currently loaded Linux Kernel. All old Kernels will be removed. It is highly recommended that a reboot is required before executing this script.
Type ‘y’ and hit Enter to remove the old kernels. You’ll be asked to enter your sudo user password to uninstall old kernels.
A reboot is recommended before running this script to ensure the current kernel tagged as the boot kernel is indeed registered and old kernels properly marked for removal. If you have just installed or modified your existing kernel and do not reboot before running this script it may render you system INOPERABLE and that would indeed suck. You have been warned. ~the Mgmt [?]Continue to automatically remove ALL old kernels? (y/N)y
Now, the old kernels have been removed from your Ubuntu system.
And, that’s all. Hope this helps. If you find this guide useful, please share it on your social, professional networks and support Linux Masters Wiki. I will be soon here with another interesting guide. Till then, stay tuned!