Compiling latest kernel in Ubuntu from Source
First of all let's see what kernel is and what it is for. Kernel is basically a computer program which takes instructions or I/O (Input/Output) Signal from software and processes them into data processing instruction for CPU and other electronic devices.
Kernel code contains all set of instructions and is programmed mostly in C language. It contains all the instruction from copy & paste to reading system architecture. The Kernel code must contain all the C code and the Object files in order to be compiled successfully.
You can download kernel code from here.
'>' this states that you have to type the adjust command in terminal.
Ex: >whoami
This command will display your username.
>uname -r
This command will display current version of your kernel, to see all system details along with arch. use -a option instead of -r.
Q.Why you should update your kernel?
Ans. Kernel update is not mandatory but recommended as what all you get from the update is what all you want. Few of the benefits are mentioned below:
and many others, so now you get the basic need of updating of kernel.Kernel code contains all set of instructions and is programmed mostly in C language. It contains all the instruction from copy & paste to reading system architecture. The Kernel code must contain all the C code and the Object files in order to be compiled successfully.
You can download kernel code from here.
'>' this states that you have to type the adjust command in terminal.
Ex: >whoami
This command will display your username.
>uname -r
This command will display current version of your kernel, to see all system details along with arch. use -a option instead of -r.
Q.Why you should update your kernel?
Ans. Kernel update is not mandatory but recommended as what all you get from the update is what all you want. Few of the benefits are mentioned below:
- Security Fixes
- The reason why Linux based Operating System are more secured as in them you can update to latest kernel whenever you want whereas in Windows you cannot.
- Stability Improvements
- Regular bugs can be fixed and the processing speed can be increased as the stability increases.
- Updated Drivers
- You get the latest trending drivers pre-installed and you don't have to download drivers when you plug-in a new device.
- New Kernel Functions
- Increased Speed
It is really simple to compile kernel from Source and upgrade it.
- Download the latest kernel or whichever version you want to build from kernel.org.
- Extract the kernel version using any extraction tool or by using CLI
- use CLI command to uncompress the file
- tar -xvJf linux-4.1.1.tar.xz
- Replace name with the name of kernel file you downloaded
- This will extract the kernel to your current directory
- Moving kernel code to /usr/src/ directory
- When Extraction phase gets completed then move the extracted files to /usr/src/ directory
- As you need super user privileges so you cannot copy using the GUI.
- Use CLI command to copy files
- sudo cp -r source-file-location destination
- Ex:
- >sudo cp -r Desktop/linux-4.1.1 /usr/src/
- here -r is to perform the copy option recursively so that all the sub-directories also get copied.
- Change pwd(present working directory) to /usr/src/linux-4.1.1/
- check pwd by using the command 'pwd'.
- change directory using cd command
- Ex:
- >cd /usr/src/linux-4.1.1/
- Configure the kernel code
- >make menuconfig
- The make menuconfig, will launch a text-based user interface with default configuration options. You should have installed libncurses packages for this command to work.
- Then click on save and save the file as '.config'
- Compile the kernel
- Compile the main kernel
- >make
- It'll take a lot of time approx 2 hours depending upon processing speed.
- Compiling the modules
- >make modules
- Installing the compiled modules
- >make modules_install
- At this point, you should see a directory named /lib/modules/4.1.1/ in your system.
- Installing New Kernel
- >make install
- The make install will create files in the/boot directory so that next time you boot into your system you boot with the latest kernel.
- The command “make install” will also update the grub.cfg by default. So we don’t need to manually edit the grub.cfg file.
- Boot Linux to New Kernel
- >reboot
- Check the version of your new kernel using Terminal
- > uname -r
- This command will display the version of your system.
Next Blog will be related to hacking IDK what It'll be but we have to shift the mainstream to a different direction now !
Till then,
Adios Lactores
Happy Blogging!!!
Comments
Post a Comment