Andrei Pall

Linux Software Engineering

How to compile and install the Linux Kernel

This step by step how to covers compiling the Linux kernel version 5.4.7 under Ubuntu 18.04 or Linux Mint 19. The following instructions were successfully tested on Linux Mint 19.3, however, instructions remain the same for any other Linux distribution.

  1. Get the latest Linux kernel source code
  2. wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.4.7.tar.xz
  3. Extract the tar.xz file
  4. unxz -v linux-5.4.7.tar.xz
    tar xvf linux-5.4.7.tar
  5. Install the required compilers and other tools
  6. sudo apt-get install build-essential libncurses-dev bison flex libssl-dev libelf-dev
  7. Configure the Linux kernel features and modules
  8. cd linux-5.4.7
    make localmodconfig
  9. Compile the kernel
  10. make -j4
  11. Install the Linux kernel modules
  12. sudo make modules_install
  13. Install the Linux kernel
  14. sudo make install
  15. Update Grub config
  16. sudo update-initramfs -c -k 5.4.7
    sudo update-grub
  17. Verify the new Linux kernel version after reboot
  18. uname -mrs

Congratulations! You have completed various steps to build the Linux kernel from source code and the compiled kernel should be running on your system.