linux install kernel - Forest0923/memo GitHub Wiki

System

  • OS: Ubuntu 18.04 (64bit)
  • Current kernel: 5.3.0-42-generic

Compile

  • Change directory to /usr/src.
  • Get kernel source code with the following command (ver.5.4.1).
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v5.x/linux-5.4.1.tar.gz
  • Decompress with tar.
tar -xvf linux-5.4.1.tar.gz
  • Change directory to linux-5.4.1.
  • Before compiling you have to install some packages via apt. Run the following command.
sudo apt install flex bison libssl-dev libelf-dev
  • Make .config with the following command.
make olddefconfig
  • Compile with the following command. 4 indicate how many thread do you use.
make -j 4

Install

  • Install modules and kernel image with the following command.
make modules_install && make install

Boot

  • Setting bootloader (grub).
grub-mkconfig
  • Reboot.

Change kernel version

  • You can choose kernel by selecting Advanced options for Ubuntu.
  • You can also change default kernel by editing /etc/default/grub.
GRUB_DEFAULT="Advanced options for Ubuntu>Ubuntu, with Linux x.x.x"