How to compile kernel in ubuntu 20.04

STEP 1: FIRST TYPE IN TERMINAL : sudo nano /etc/default/grub

where nano is your TEXT editor

STEP2: INCREASE GRUB_TIMEOUT TO 10 WHICH DETERMINES YOUR BOOTING TIME

press ctrl+o and enter to save the file and then ctrl+x to exit.

STEP 3. type: sudo update-grub to update the changes.

STEP 4: TYPE: uname -r to show the kernel version installed in your computer . OR uname -a all about it

STEP 5: GO TO www.kernel.org and download the stable or longterm release (tarball version) it is highly recommanded to download the stable or longterm versions .

STEP6.GO TO your downloaded KERNEL FOLDER( WE ASSUME THAT THE FOLDER IS IN /Downloads/)

STEP7. type: cd ~/Downloads/ in terminal and type mkdir linux_kernel

STEP8. EXTRACT THE .tar file there (in the linux_kernel folder )

STEP9. TYPE : sudo apt-get install build-essential gcc bc bison flex libssl-dev libncurses5-dev libelf-dev

to install dependencies gcc is the c compiler flebx is lexical analyzer and bison is parser.

STEP10. type: cp /boot/config-$(uname -r) ./. config to provide support a wide range of hardware by copying the .config file.

STEP 11. type make localmodconfig it will ask u questions about the new drivers and support of kernel keep pressing enter to set all the answers of the questions to default or u may search google for answering this.you have to type this command in /Downloads/linux_kernel folder otherwise the method will not work…

IF U KNOW WHAT THE KERNEL MODULE IS ABOUT THEN U MAY ANSWER THIS …

or…

The Linux kernel build-system provide many build targets, the best way to know about it is probably to do a make help:

Configuration targets:

config - Update current config utilising a line-oriented program

nconfig - Update current config utilising a ncurses menu based program

menuconfig - Update current config utilising a menu based program

xconfig - Update current config utilising a QT based front-end

gconfig - Update current config utilising a GTK based front-end

oldconfig - Update current config utilising a provided .config as base

localmodconfig - Update current config disabling modules not loaded

localyesconfig - Update current config converting local mods to core

silentoldconfig - Same as oldconfig, but quietly, additionally update deps

defconfig - New config with default from ARCH supplied defconfig

savedefconfig - Save current config as ./defconfig (minimal config)

allnoconfig - New config where all options are answered with no

allyesconfig - New config where all options are accepted with yes

allmodconfig - New config selecting modules when possible

alldefconfig - New config with all symbols set to default

randconfig - New config with random answer to all options

listnewconfig - List new options

olddefconfig - Same as silentoldconfig but sets new symbols to their default value

kvmconfig - Enable additional options for guest kernel support

tinyconfig - Configure the tiniest possible kernel

what i have written above is a list of all kernel compiling policies .

STEP 12:TYPE: make -j4 deb-pkg where 4 is the number of cores/thread of your processor u want to give the kernel compiling process … now take a cofee mug in your hand wait for half of an hour or 40-50 mins acconding to your proceesors quality. the command will make a .deb file of your compiled kernel.

STEP 13: Type: sudo dpkg -i linux-*.deb it will install the compiled .deb package in your system.

STEP15: NOW REBOOT AND YOU WILL SEE YOUR COMPILED KERNEL IN GRUB MENU. ENJOY YOUR OWN KERNEL.