We have already addressed this topic in the past, in this article, in this other the topic will be explained in more depth.
What is the kernel?
As mentioned last time, the kernel is a software that manages hardware resources, the processes of an operating system, and is the first program to be launched after the bootloader and ramdisk; takes care of starting the init system, the services and also takes care of loading the drivers.
The kernel can be of different types: microkernel (Mach), hybrid kernel (MS-DOS systems), monolithic (BSD, Linux), etc. Each one can be used for different purposes. For more info ... Google!
Is it correct to define Linux an operating system (OS / SO)?
No, and NO!
Linux is a kernel, which is an integral part of the operating system, one of the operating system software, in fact, Linux is an integral part of GNU, created by Richard Stallman.
It is correct to say that GNU is an operating system, and that it integrates with various kernels, the most widespread is Linux (GNU / Linux), but it can also integrate with other kernels such as Hurd, kFreeBSD, Darwin.
GNU is a Unix-like operating system (GNU's Not Unix) and consists of various software:
- Text editor: GNU Emacs
- Photo editing: GIMP
- Desktop Environment, Window Manager: GNOME
- Display Manager: GDM
- Photo viewer, music player: gThumb, Rhythmbox
- A kernel: in our case Linux
- A shell: Bash, zsh, sh etc ...
- Init system: systemd, upstart ...
So it would be correct to say that Debian (or Fedora, Ubuntu, RedHat, Arch Linux, Slackware, etc.) are operating systems based on the GNU operating system with Linux kernel, even if there are distributions using Hurd kernels like the Debian GNU / HURD project .
After this explanation, we move on to the second point
Linux from who is developed, and how?
Linux was developed by Linus Torvalds, towards the end of the 80 years (if I remember correctly), and takes its name from its main developer. In the 1991-1992 the GNU operating system was almost ready, one component was missing: the kernel. Here comes Linux, which was quickly integrated with GNU.
Here comes GNU / Linux (the merger of GNU and Linux), Linux increasingly begins to attract attention thanks to RedHat (RHEL), the development continues exponentially thanks to mailing list by various developers around the world, hobbyists and employees of large companies (many RHEL, Debian, Arch developers still contribute to the development of Linux). GNU / Linux spread in the Server environment thanks to its stability and responsiveness, unfortunately, in the desktop environment, Windows still "reigns" but loses ground level slowly, thanks to the spread of distributions like Ubuntu or Linux Mint 🙂
In what programming language is Linux developed?
Linux is developed in C, a language derived from B and developed by Dennis Ritchie, a physicist and mathematician who also developed UNIX, along with Ken Thompson. Without them BSD, GNU, and the various UNIX operating systems (including MacOS (based in turn on FreeBSD) would not exist, probably even Windows would not exist (it is developed in C).
Dennis Ritchie died in October of the 2011, shortly after the death of Steve Jobs, despite this IT IS NOT REMEMBERED AS STEVE JOBS, WHICH ON THE CONTRARY IS REMEMBERED AS A REVOLUTIONARY. Dennis must be reminded how Steve, without him, I'm sorry Apple fans, but now you wouldn't have your iPhones, iPads, iPods, iMacs, MacBooks, etc ...now, as I write, I don't know how many people will read my article but I hope they will read it as much as possible, not to get more visibility, but to invite them to know who really made it possible
I think that's enough.
Today, how do the various developers interact?
Never heard of Git?
Git is a VCS, developed by Linus Torvalds (used by Google, Facebook, AOSP, CyanogenMod and many other open source projects) or a Version Control System, it allows you to create a repository, say a container, that " contains "pieces of the Linux kernel. It contains the Linux kernel source code (Distributed under the GNU General Public License [GPL]), which we will use to compile the kernel.
More users all over the world, download the source code, make changes to the kernel code (divided into various headers and source in C) and then "pushano" changes to the Git repository of Linux commenting and motivating the changes to the source code (a bug fix for example).
However it is possible to get the Linux source code directly by downloading a tarball from here
There are many git-hosting sites: GitHub, BitBucket and others ..
Besides Git there are other VCS like Mercurial.
We will use ...?
- grub-mkconfig or update-grub
Why compile your own kernel?
If you know your hardware thoroughly, it's a good idea to compile the kernel yourself, because the kernel that comes with the distribution loads modules, firmware, drivers that you probably don't need. Furthermore, you have the freedom to update the kernel whenever you want and how you want, especially in distributions like Debian, you will gradually get used to it.
Curiosity: here you can read Linus Torvalds' degree thesis - Linux: a portable operating system
Where do we find the Linux source code?
You find it right here, I recommend you download the latest stable version, if you are more curious, download the 4.0-rcX (the one I use 🙂), download the tarball (tar.xz).
How much does the source code (compressed) weigh, as I understand the version I'm downloading
The source code of a kernel weighs more or less 70 MB in a tarball (compressed).
Let's consider a version of Linux and see how to read the version, which is very simple
-linux = default
-4.0-rc7 = xy-rcZ: Major version. Minor release-releaseCandidate (RC number)
- * 3.19.3 = xyz: Major version. Minor release. Still minor release
- Major version = the 'series' of the kernel - that is: 4, 3, 2, 1, 0: addition of remarkable functions, addition of many drivers, performance improvement.
-release minor = An update of the Major version, we usually add support for new hardware, and additional functions of little importance.
-releaseCandidate = a 'beta' of the kernel, unstable version, probability of finding remarkable bugs.
-release still less = bugfix of a stable kernel
-tar. * = source compression algorithm
longterm, stable, mainline
-longterm: kernel with additional support, old, but with minimal probability of instability and bugs
-stable: "current" kernel ready to be used and tested
-mainline: latest version of the kernel
Ever heard of modprobe?
is a program that allows you to load, remove, show the dependencies of a kernel module, the nice thing is that it allows you to "unmount" the kernel to your liking in real time.
For example, I want to load the module that contains the code block that allows my webcam to work (uvcvideo, Acer CrystalEye Webcam), I run
# modprobe uvcvideo
if for any reason I want to stop making it work
# modprobe -r uvcvideo
which removes the module from the kernel
Or I want to see the modules needed to load my webcam module:
# modprobe -D uvcvideo
for all the options that modprobe allows you to use you can use
$ modprobe -h
DKMS - Dynamic Kernel Module Support and linux-headers
are two software that allow the compilation of modules / drivers that the kernel does not have in its source code, a common example are the VirtualBox drivers for virtual machine emulation (vboxdrv).
They are usually not included in distributions and it is sufficient to download them from your package manager
linux-headers - $ (uname -r)
We will use GNU Make to compile the kernel and its drivers, it is a tool that through instructions, contained in a file called "Makefile" allows us to compile a program from source, is a modern version of the old make, and there are various , like BSD Make (bmake) or Microsoft Make (nmake)
Let's now proceed to the compilation
We extract the files and navigate to the destination folder
We extract the downloaded tarball
tar -xf <package.tar. *>
and we navigate with cd (change directory)
Environment preparation and cleaning of useless files
Inside the folder we execute
$ make mrproper
We write a configuration file
The kernel needs to know which modules / drivers to enable by default, which to modulate, which ones do not load (ignore) etc ...
To do this you can use 3 tools
-make menuconfig (ncurses semi-graphical interface program) [Recommended]
-make gconfig (Gtk GUI program)
-make xconfig (Qt GUI program)
I recommend menuconfig, as it doesn't crash and is much faster than the other two, also in gconfig you are often subject to sudden crashes that force the user to reopen a new config file.
- Key: modularize a module / driver (<>)
- Key: enable a module / driver ()
-Tasro: disable a module / driver (<>; )
if we want to use the config of our kernel we have to copy
in the directory of a level above the current one (..), unpack the archive change the owner of the file and copy the file to the kernel subdirectory
# cp /proc/config.gz ~
# chown config.gz
$ gzip -d config.gz
$ cp .config
* Beware of deselecting 64-bit kernel type if your OS is not on 64 bit architecture
Starting the compilation
To start compiling the kernel simply run make, which will read the Makefile, and the .config to configure the kernel.
Start compiling using only one CPU core
Start compiling using two CPU cores
Start compiling using X CPU cores
Normally, depending on the modules, with 2 core it uses 15 minutes (necessary modules, custom configuration)
Installing headers and modules in the / lib / modules folder
We execute the following commands to install the modules (* .ko) and the kernel headers in / lib / modules / XYZ
# make modules_install
# make headers_install
Kernel and System.map copy in / boot
It is necessary to copy the kernel to / boot and System.map, where the ramdisks, kernels images, and GRUB bootloader configuration are contained.
Copy the kernel
# cp arch / x86 / bzImage /boot/vmlinuz-kernel.ver.sion
# cp System.map /boot/System.map
Ramdisk image generation
It is generally used update-initramfs in Debian systems and also RedHat, mkinitcpio for systems based on Arch Linux.
# update-initramfs -k <version_of_kernel_in_ / lib / modules> -c
# mkinitcpio -k <kernel_ version____ / lib / modules> -g / boot / initramfs- <kernel_ version___ / lib / modules> -c /etc/mkinitcpio.conf
GRUB configuration update
To update the GRUB bootloader:
# grub-mkconfig -o /boot/grub/grub.cfg
Now just restart and you can use your homemade kernel!
You can perform the same operations using LinuxCleaner
I am also developing a graphical interface version (GTK +), certainly more pleasant and with a simple installation script. Who the source code.