Difference between modularized, semi-monolithic kernel and pure monolithic kernel

versatile 64-bit multi-user Linux distribution

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
User avatar
Duprate
Posts: 298
Joined: Sat Aug 22, 2020 8:14 pm
Location: Southern Brazil
Has thanked: 150 times
Been thanked: 102 times

Difference between modularized, semi-monolithic kernel and pure monolithic kernel

Post by Duprate »

Modularized Kernel: :|
Of general use, it is suitable for all types of machines and we can say that it is easily portable with different Linux(small code modules are inserted and removed from the running kernel.
Just as there are computers that are advanced in terms of hardware, there are computers that are less advanced.
Due to the hardware being current or not, the modularized kernel was created.
obs: If the modularized kernel did not exist, we would have to insert in the kernel all the characteristics of all the different types of
computers. This way it would make the binary kernel slow and cumbersome at the time of its tasks and make it complicated
maintenance due to programs that depend directly on the kernel.

* Below are some of the occurrences when using modularized kernel:
Uses a lot of physical space in memory;
load only modules with few bytes;
the kernel can access a module before it has initialized;
a module can be removed, even with the module still in use; and
generates unnecessary codes that provide easy access to the network and the machine's own data.

"Semi-Monolithic" kernel,(The kernel we use, vmlinuz + kernel-modules): :)

The Linux kernel has incorporated some features of a modular kernel, which makes it currently a kind of "semi-monolithic" kernel. The entire kernel, including the drivers device and other components still form a single code block (gigantic, more 30 MB compressed) but now they can be compiled separately in the form of modules.
These modules can be loaded and unloaded at any time, as would be possible in a modular kernel, but without the loss of performance or increase in complexity that would exist when use a truly modular kernel.

Pure Monolithic kernel (to be used only on the machine where it was compiled): :D

Kernel configuration improves system performance. Configuring the kernel means compiling only the necessary code.
For better performance and security, we can compile the pure monolithic kernel, generating a single file (vmlinuz) that contains only the modules needed by our PC, inside the compiled code.

* Below are some examples of the importance of compiling the Monolithic Puro kernel:
1- Kernel speed (little code execution);
2- It gives us more available memory (virtual memory will not use kernel memory);
3- Makes the system more stable;
4- The kernel becomes faster than using modules (compilation around 15 minutes); and
5- Lowers the "attack profile" to our system.

Exemplifying:
A build of kernel 6.0.8 for my PC, using FatDog64 and initrd Overlayfs, yielded a final result with a
single file (vmlinuz "with everything inside"), at the size of 9653K, 9,29% of a current (5.19.17) general purpose kernel, from
FatDog64 which contains: vmlinuz 7785K and kernel-modules + firmware 96Mb.

1- To obtain this result, each user has to make his own compilation and the size of vmlinuz varies according to the hardware;
2- The .config obtained still needs some corrections made manually;
3- I only got excellent results, with everything working, on FatDog64 (other distros, I had problems with the sound); and
4- I still haven't tested compiling in AUFS mode.

Why all this explanation? Mainly to value FatDog64, this "fertile ground" where I've been testing so many cool things and where "everything works out" facilitating learning... :thumbup2:

Attachments
Monolithic_Pure.jpg
Monolithic_Pure.jpg (45.65 KiB) Viewed 887 times
Last edited by Duprate on Sun Nov 20, 2022 6:22 pm, edited 1 time in total.
User avatar
Duprate
Posts: 298
Joined: Sat Aug 22, 2020 8:14 pm
Location: Southern Brazil
Has thanked: 150 times
Been thanked: 102 times

Re: Difference between modularized, semi-monolithic kernel and pure monolithic kernel

Post by Duprate »

Good afternoon!
Kernel 6.0.9 compiled today, took 20 minutes.
Still "tying up some loose ends", manually correcting in .config, things like "KVM", "ZRAM" on startup, "sound" for the other Puppyes.....
In the end when everything is right and if any user is interested I can make a tutorial ..... :thumbup2:

Attachments
FatDog64.jpg
FatDog64.jpg (227.7 KiB) Viewed 797 times
User avatar
rockedge
Site Admin
Posts: 5857
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2102 times
Been thanked: 2196 times
Contact:

Re: Difference between modularized, semi-monolithic kernel and pure monolithic kernel

Post by rockedge »

In the end when everything is right and if any user is interested I can make a tutorial

Definitely will be appreciated by me to look over a tutorial! Always looking to improve the ways I build kernels by looking over some shoulders.

That's how I started to learn how to program and operate a computer. 1975, 13 years old, walking 2 miles from the Junior High after school to the High School and sneaking in to the 3rd floor terminal room of the computer center and standing behind the older guys (some of the original hackers) looking over their shoulders watching how they did it. I did this almost every day of 8th grade to get time on the PDP-11/70 and it's RSTS/E time sharing operating system. Learned BASIC and Assembly that way until they got used to me and could actually sit in front one of the terminals with an actual monitor! Up to then it was using a networked Teletype 33 next to the Junior High school Principle's office after school. Then the long 5 mile walk home in the dark.

Used to play Adventure occasionally and it looked just like this.

User avatar
Duprate
Posts: 298
Joined: Sat Aug 22, 2020 8:14 pm
Location: Southern Brazil
Has thanked: 150 times
Been thanked: 102 times

Re: Difference between modularized, semi-monolithic kernel and pure monolithic kernel

Post by Duprate »

rockedge wrote: Thu Nov 17, 2022 6:02 pm

In the end when everything is right and if any user is interested I can make a tutorial

Definitely will be appreciated by me to look over a tutorial! Always looking to improve the ways I build kernels by looking over some shoulders.

Hi Rockedge! We are from the same generation! My experience with computers took a little longer....
At work, my first contact was an IBM COMPUTER XT (TM) MODEL 286, equipped with WordStar for DOS and I just looked at it... :mrgreen:
Lately, I've wanted to make some tutorials, based on what I've experienced, with the intention of helping anyone who might be interested and moving the pages of our forum a little.
I have the habit of writing down (so as not to forget) the procedures I do in my tests. So, don't expect something too professional.... But it will be based on what worked! I'm doing the tutorial and soon, I'll make it available..... :thumbup2:

Thank you for your attention!

Attachments
XT.jpg
XT.jpg (45.54 KiB) Viewed 754 times
User avatar
Duprate
Posts: 298
Joined: Sat Aug 22, 2020 8:14 pm
Location: Southern Brazil
Has thanked: 150 times
Been thanked: 102 times

Re: Difference between modularized, semi-monolithic kernel and pure monolithic kernel

Post by Duprate »

.... I was thinking, trying to remember where the root of all this lies.... After all, who taught me about the Custom Kernel? .... For a duty of justice and recognition, I remembered that I finally hit the spot on December 1, 2020, thanks to the explanations given by the late friend "Rufwoff", in his post "Pugdog - a simplified version of the Bulldog"! :o
(Of course I did a forum search to help remember!) :mrgreen:

User avatar
Duprate
Posts: 298
Joined: Sat Aug 22, 2020 8:14 pm
Location: Southern Brazil
Has thanked: 150 times
Been thanked: 102 times

Re: Difference between modularized, semi-monolithic kernel and pure monolithic kernel

Post by Duprate »

rockedge wrote: Thu Nov 17, 2022 6:02 pm

Definitely will be appreciated by me to look over a tutorial! Always looking to improve the ways I build kernels by looking over some shoulders.

THE METHOD DESCRIBED HERE IS ONLY FOR COMPILE MONOLITHIC PURE KERNEL:

FOR AN OVERLAYFS SYSTEM: :geek:
1- Download the desired kernel tarball from Kernel.org (in this example, linux-5.19.17.tar.xz);
2- In a place of your choice on the HD, with UExtract, unzip the file;
3- The folder "linux-5.19.17.tar.xz.extracted", rename to "linux-5.19.17";
4- Inside the renamed folder, you will also have a folder with the same name, just rename it to "linux";
5- Create a symbolic "link" of the "linux" folder in /usr/src/;
6- Inside this "linux" folder, there is no file named ".config", in this case it will automatically be used the same one found on the machine
in /proc/config.gz belonging to the kernel currently in use. The older the kernel in use, the more questions the program will ask to update the kernel.
".config" which will be used in the new build, of the most modern kernel;
7- It is also possible to borrow the .config from another kernel of the same level, developed by one of the masters here on the forum;
8- In this exercise, to facilitate the explanation, I am using the normal version of FatDog64-813 and its kernel 5.19.17 and the version of "Kernel.org" the
5.19.17 (no AUFS support). the objective is to analyze the new ".config";
9- Open the terminal and type: "cd /usr/src/linux" then type "make localyesconfig";
10- After a few minutes, we will have a new ".config" redone over the previous one (.config.old). Some questions will be asked. Just answer y (yes) or if you don't know or the question at the end
is accompanied by a (NEW) you can just click "enter";
11- Now, some manual corrections are still needed....;
12- Open the ".config" (in Geany). Click "Search", "Find", and in the search window type "KVM", "Next", and what you will find is:

CONFIG_HAVE_KVM=y
CONFIG_VIRTUALIZATION=y
# CONFIG_KVM is not set
CONFIG_AS_AVX512=y
CONFIG_AS_SHA1_NI=y
CONFIG_AS_SHA256_NI=y

To get the necessary mitigation "itlb_multihit KVM:Mitigation: VMX unsupported", replace with:

Code: Select all

CONFIG_HAVE_KVM=y
CONFIG_HAVE_KVM_PFNCACHE=y
CONFIG_HAVE_KVM_IRQCHIP=y
CONFIG_HAVE_KVM_IRQFD=y
CONFIG_HAVE_KVM_IRQ_ROUTING=y
CONFIG_HAVE_KVM_DIRTY_RING=y
CONFIG_HAVE_KVM_EVENTFD=y
CONFIG_KVM_MMIO=y
CONFIG_KVM_ASYNC_PF=y
CONFIG_HAVE_KVM_MSI=y
CONFIG_HAVE_KVM_CPU_RELAX_INTERCEPT=y
CONFIG_KVM_VFIO=y
CONFIG_KVM_GENERIC_DIRTYLOG_READ_PROTECT=y
CONFIG_KVM_COMPAT=y
CONFIG_HAVE_KVM_IRQ_BYPASS=y
CONFIG_HAVE_KVM_NO_POLL=y
CONFIG_KVM_XFER_TO_GUEST_WORK=y
CONFIG_HAVE_KVM_PM_NOTIFIER=y
CONFIG_VIRTUALIZATION=y
CONFIG_KVM=y
CONFIG_KVM_WERROR=y
CONFIG_KVM_INTEL=y
CONFIG_KVM_AMD=y
# CONFIG_KVM_XEN is not set
CONFIG_AS_AVX512=y
CONFIG_AS_SHA1_NI=y
CONFIG_AS_SHA256_NI=y

13- In the same search window, looking for "zram", the following values ​​must be changed, as shown below:

CONFIG_ZRAM=y
CONFIG_ZRAM_DEF_COMP_LZORLE=y
# CONFIG_ZRAM_DEF_COMP_ZSTD is not set
CONFIG_ZRAM_DEF_COMP="lzo-rle"
# CONFIG_ZRAM_DEF_COMP is not set
CONFIG_ZRAM_MEMORY_TRACKING=y

14- Searching for "overlay", you will find: # CONFIG_OVERLAY_FS is not set

Change to: CONFIG_OVERLAY_FS=y

15- Ready for the next step! Now in the terminal type: "cd /usr/src/linux" then type "make -j2" (where 2 is the number of processor cores and
changes from one machine to another); and

16- After about 15 to 20 minutes, the new kernel (bzImage) will be in /linux/arch/x86/boot/. Rename to "vmlinuz" Copy paste where the system is.

Notes:
1- The custom ".config", if done correctly, in each line there is only the answer "=y" or "is not set". Answers like "=m", generate modules,
which is not our aim.
2- The kernel from the exercise above was left with 9413K.
Linux kernel x86 boot executable bzImage, version 5.19.17 (root@GNU/Linux) #1 SMP PREEMPT_DYNAMIC Sun Nov 20 11:41:31 UTC 2022, RO-
rootFS, swap_dev 0x9, Normal VGA

FOR AN AUFS SYSTEM: :geek:
1- Download a "kernel_sources" with AUFS support (in this case, as an example, kernel_sources-6.0.6-64oz-ao.sfs from Ozsouth, at viewtopic.php?t=7218 ) ;
2- Click on the .sfs file, in /usr/src/ copy the "linux" folder to a place of your choice in HD;
3- Create a symbolic "link" of the "linux" folder in /usr/src/;
4- In this case there is already a ".config" file, so open the terminal and type: "cd /usr/src/linux" and then "make localyesconfig";
5- The procedures described above from number 11 to number 16 are the same.

Comments:
After the completion of the new pure monolithic kernel, one can test in the terminal if everything went correctly. Just type in the terminal "make modules" and
a few minutes later, "make modules_install". So, if /lib/modules/6.0.6/kernel is empty, it's because the ".config" was edited correctly. This procedure
will not have the desired effect, if the kernel installed with modules in /lib/modules/ is the same as just compiled.

Well this is my way of doing it and it has worked for me for years. It may not be very orthodox. Fast results, without having to read tons of handouts. I hope it's useful to someone! Many users of this forum have a good knowledge of linux and programming. This tutorial is intended to help those who don't have it and, like me, learn "in pain" and in the "try hit / miss" method .....
The doors to learning are always open and criticism is :welcome:

Attachments
config_personalizado.jpg
config_personalizado.jpg (81.69 KiB) Viewed 677 times
User avatar
Duprate
Posts: 298
Joined: Sat Aug 22, 2020 8:14 pm
Location: Southern Brazil
Has thanked: 150 times
Been thanked: 102 times

Re: Difference between modularized, semi-monolithic kernel and pure monolithic kernel

Post by Duprate »

My last build with 9783K, Kernel 6.1.0, maybe new LTS.

Attachments
Kernel.jpg
Kernel.jpg (134.82 KiB) Viewed 544 times
User avatar
Duprate
Posts: 298
Joined: Sat Aug 22, 2020 8:14 pm
Location: Southern Brazil
Has thanked: 150 times
Been thanked: 102 times

Re: Difference between modularized, semi-monolithic kernel and pure monolithic kernel

Post by Duprate »

New kernel, released about 3 hours ago .....

Attachments
kernel.png
kernel.png (40.5 KiB) Viewed 497 times
chrabak
Posts: 2
Joined: Wed Nov 02, 2022 12:52 am
Has thanked: 1 time

Re: Difference between modularized, semi-monolithic kernel and pure monolithic kernel

Post by chrabak »

thank you duprate.

i followed your recipe for kernel compile and it worked on my acer vx-15 FD813 first time. i have never attempted a kernel compile before so thank you for the encouragement
on compiling a monolithic kernel.

however! where is the firmware loaded? dmesg reported "ath10k_pci 0000:02:00.0: Failed to find firmware-N.bin (N between 2 and 6) from ath10k/QCA6174/hw3.0: -2"
yet i have "/lib/firmware/ath10k/QCA6174/hw3.0/firmware-6.bin". same problem for i915 and others.

my research says the environment variable FIRMWARE_DIR controls the location. where is that set? not in the .config options.

i am compiling kernel 6.1.7 from kernel.org.

User avatar
Duprate
Posts: 298
Joined: Sat Aug 22, 2020 8:14 pm
Location: Southern Brazil
Has thanked: 150 times
Been thanked: 102 times

Re: Difference between modularized, semi-monolithic kernel and pure monolithic kernel

Post by Duprate »

Yeah ..... This has worked for me since 2020 on my PC with FatDog64 but, it is noted that the "make localyesconfig" command does not perfectly select the optimal configuration for the kernel in some cases. When I do this same process using some version of puppy, it compiles the kernel but there is no sound. I've tried to solve the problem in several ways, but without success! I also encountered some problems using another PC or notebook with a different configuration. My latest builds were 5.4.229 LTS which I use on a mini PC and 6.1.7 for my PC, both with FatDog64.
The goal is that everything needed for the PC where the compilation is done, is inside the monolithic kernel, without modules or extra firmware. So there is something left to learn.... :?:

When we make a topic like this, we provoke and hope that other people will read it and that someone who knows more than us will respond and "turn on a light", taking us out of "eternal darkness and absolute silence"!
Now, there are two of us waiting for the light........ :idea:

Thank you for trying! :thumbup2:

Attachments
kernel.png
kernel.png (36.3 KiB) Viewed 295 times
Post Reply

Return to “FatDog64”