Issue
I'm trying to implement a system call on a custom Linux kernel as described in this tutorial href="https://medium.com/@ssreehari/implementing-a-system-call-in-linux-kernel-4-7-1-6f98250a8c38" rel="nofollow noreferrer">here.
My questions are:
- Why do we have to compile a new custom kernel when implementing a new system call? Is it possible to add a system call to the original kernel when first installed?
- Why does the process of compiling Linux kernel take up a lot of space? (in my case up to 20gb)
Solution
Why do we have to compile a new custom kernel when implementing a new system call?
Because it's not possible to hot-patch a new syscall into a running kernel. The same way it's not possible to add a new feature to a piece of binary software without modifying its source code unless it was specifically designed to do so in a modular way. As it turns out, the Linux kernel can be augmented in a modular way, but not when it comes to syscalls. The only way of properly doing so is by getting the kernel source, modifying it, configuring it, and then compiling it as a brand new kernel.
Is it possible to add a system call to the original kernel when first installed?
No. Your "original kernel" comes already compiled in a package that your particular distribution automatically installs for you.
Why does the process of compiling Linux kernel take up a lot of space?
Because you are most likely compiling a lot of useless drivers. The Linux kernel comes with thousands of different drivers for all kinds of devices. If you do a complete compilation you will compile a lot of unneeded stuff. What you can do is:
- Copy the configuration from your current kernel, so that it is the same when compiling. See this post for more info.
- Or configure the kernel with
make localmodconfig
which only enables the compilation of modules that are currently loaded in your system.
Answered By - Marco Bonelli Answer Checked By - Senaida (WPSolving Volunteer)