← Previous lessonFree lesson 2 of 3 · lesson 2 of 38Next lesson →

Unlock all 38 lessons of Linux Driver DevelopmentFull course ₹40,000 · paid

Price & syllabus
Free lesson · 24 min · no payment

Getting, Configuring and Building the Linux Kernel Source

A free lesson from Skill-Lync's Linux Driver Development course, on Grow by Skill-Lync · Last updated 16 Nov 2026 · Session: “Week 1 Session 2”

What will you learn in this free Linux Driver Development lesson?

The lesson lists the build tools (GCC, ld, make, binutils), then shows git clone of the kernel source, cscope for navigating it, and git branches per version. It covers the .config file, make config, defconfig and menuconfig, then building with make, parallel builds with -j, building one folder, and output directories.

  • Build tools: GCC, linker, make and binutils
  • Cloning kernel source and indexing with cscope
  • Configuring with make menuconfig and defconfig
  • Building with make -j, M= and O= options

What comes after lesson 2?

The next free lesson is lesson 3, “Installing, Updating and Saving Kernel Configurations and Build Outputs” (23 min). Later in Skill-Lync's Linux Driver Development course (paid): lesson 4, Week 2 Session 1; lesson 5, Week 2 Session 2; lesson 6, Week 2 Session 3. The full course has 38 lessons (18 h 31 min of video); see the course overview or its price and syllabus.

Lesson transcript

Machine transcript of the lesson audio (lightly cleaned). Technical terms may contain errors; the video is the reference.

So, in the last session, we discussed on the Linux history. So, in this session, we will go into steps for kernel compilation. So, what is the prerequisite for it? So, we need a Linux system, Linux laptop, which runs on any Linux kernel distribution like open to open source A, etc. And we need a kernel source. Kernel source is an open source kernel, which we have to download it. And apart from this too, then we need some of the tools. So, for building your kernel. So, these are the tools we require for building the kernel. So, the first major thing is a compiler. So, for whatever thing, so a C file has to be compiled for a hardware to run.

So, first thing we need is a compiler. So, in this case, we will be using GCC. And you can check what version of a GCC using this command GCC double hyphen version, then you will get the GCC version, whether installed or not. Next is a linker. So, once your code is compiled, it needs to be linked with each other. So, linker forms a major role in your building environment. So, this is what we will be using is a Win Utility. So, this is also open source. So, you can check whether this is installed in your system or not by using a command LD. So, LD hyphen D. If it prints it, then you can make sure it is installed in your system.

Next utility is a Make. So, this is very much important. It is a sophisticated tool. It can do many things. So, major thing what it does is, so it determines what are the files to be compiled. And invoke other tools to build it or not. So, major thing is, the first time when you build it, it will build all the files. But, if the second time what invoke a Make, what it will do is, it will not build the entire source code. Instead, it will compile only the changed files from the previous build.

So, that's the intelligence this Make file has. So, you can also check what version of your Make is installed in your system using this command make hyphen version. So, as I explained in the previous slide, Bind Utils, it is an utility, not a single, it is a package. So, it consists of many other tools inside it. So, for example, we have a tool called AS. So, AS is nothing but a GNU assembler. As we have seen in the before LD. LD is a GNU linker. Many more are there. This file are the important things said here. So, next is an OBGA copy is one of the utility. So, what it does is, it copies and translates object file.

An OBGA dump is to display the information about content of the file by reading its header file. An address tool line. So, what it does is, if you give an address, it will print the corresponding assembly and it will retrieve it from the source file. So, many more are there. So, I have listed only a few of the tools that Bind Utils provide us. So, this are, till now we have seen what are the tools or prerequisite we need for compiling the kernel. So, now we go to the actual part of the kernel compilation. First part is, we are going to get the kernel source. So, this kernel source somewhere we can download.

This Linux kernel uses, it is nothing but a version controlled system. And Linux kernel is using this tool for tracking their source code. So, how to download it? So, it is archived in this source site which is called JIT-JITKERNEL-ORG-UVSCM-Linux-Kernel-JIT-Linux-storewals. And this is a repository Linux dot JIT. So, always a repository dot JIT extension. So, what we have to do is, create a directory. So, in this case, I have created a local directory called Linux underscore source and then execute this command JIT-Clone. And this entire URL and which folder it has to be saved or stored. So, once I give this command, it takes a considerable amount of time.

So, it is a huge repository. So, it takes some times like 30 to 40 minutes for download depends upon your brand. And it will be saved into your Linux source directory. And this Linux is dated regularly. So, if you need to update your local source to the mainline. So, you can use this pull command. So, JIT pull what it will do is, it will download only the difference from our local machine to the remote repository. So, this is very helpful. So, if at all now, I am working in 5.15.0. So, after 2 months or 3 months, if a new kernel is released for 5.15.1 or 2, then I don't need to download the entire source.

So, I can just give a JIT pull. So, it retrieves only the differences, which will save our time in downloading it. The kernel source is very big. And we have N number of architecture supported, N number of kernel subsystem software, device drivers, everything is there. So, traversing files, this will be difficult. So, what we need to do is, we need to have a setup. So, first thing is, we can have an editor. So, we can use Emac or something like Visual Studio, open sources are there.

So, we have to select one editor for it. So, Vim or Emac. So, in my case, I am going to use Vim. And next is, there is a tool called a C-Scope. So, C-Scope is a source code traversing tool. So, what we have to do is, we have to download this tool. And in Linux, we will be using this app to install C-Scope for downloading this tool. And once it is downloaded, we have to go to the Linux source directory. In our case, it is Linux underscore source.

Then, we have to index it. So, first time. So, we have to index it using the C-Scope-R command. When we view this command, what this tool will do is, it will travels to every source and it will index in a .c-scope files. So, once this .c-scope file is generated, we can search anything to it. So, this is a snapshot of this tool. How it will look like. So, it has two parts. So, this is an upper part. So, this upper part is the search results. And lower part is the variable QVD, text to be searched or file name to be searched, whatever it is.

So, we have this many number of options out there. So, first is, we can find a symbol. It is a function. So, we can give the name to it. And if it is a global definitions, then we can have to view here. And we have to find what are the called by this function. What are the function calling this function. If you want to search a string. If you want to find a file. So, many things are there. We can explore it. So, once you, we enter the symbol. So, in this case, I am just entered a KMLock. Once you enter this KMLock in the C symbol and press enter, it will print the search result here.

So, it will be from 0 to G, it will give. And if we give, press space bar. So, it will move to the next 18 results. So, if you press 0, then the corresponding size will be opened. So, I am navigating to the next source. So, I already installed C scope. I am just indexing it. So, I already indexed. So, command window comes up. And this is a kernel top level directory. So, I went into inside this folder and I am pressing, giving it ls command. So, this is a top level directory.

It has main thing called as an arc. Arc is an important directory. And drivers, as a device driver. So, we will be focusing more on this drivers folder. So, we have a lot of documentation for it. So, we can go to this documentation directory. And the cscope. So, since I already indexed this is my source code, I will be having this file. This is not a folder cscope.out. And the kernel subsystems, all will be in there as kernel folder. And licenses, licenses related documents will be there.

And we will be having some sample codes and if there are scripts for automation. And many things are there. As a device driver, developer. And we will be focusing on this driver folder. And this is a top level directory folder structure for your Linux kernel. One more thing, we will be having a make file also. So, which we will be seeing in this next slide. So, how to identify a kernel version? So, since we will be updating it regularly using a git pull command. So, if you want to check what is the current source we have, we can retrieve it using this make file.

So, you can give this a header. So, you can give this a header and one of the command which is used to print the content of the file. And we are limiting to five lines. So, hyphen in five means print just five lines of a content from this file make. So, this is the content of your make file. So, in this it gives a version 5, patch level 9, double level 0, extra version 1. So, which means it is in 5.9.0. And it is using our GPL version v2 licensing. You can check yours also. And choosing the kernel version. And each kernel version. So, we have releases every now and then. So, each kernel version will have its own branches.

So, jit provides this feature. So, branching. So, which means we can go to that particular branch. So, we will get the source of the particular version 5.13 or if you want to go for 5.14. There is a branch for each versioning. And what the usual procedure for this kernel compilation is. What you have to do is you have to create a new branch and we can edit or we can add our drivers to it or modules to it. First, what you have to do is create your local folder name. Local branch name. So, which is hyphen b jit. Check out hyphen b and your branch name. And the kernel branch. So, kernel branches. In this case, what I am doing is I am using v5.13.

So, this is an example command jit. Check out hyphen b which means create a new branch. Branch name is development source and from which is a reference to it. So, take from this reference v5.13. So, you can after checking out you can check the version using the make file also. So, I am in the kernel source folder. So, what I am going to do is I am going to type. So next thing we will be focusing on is kernel configuration. What we have now is a kernel source for this we are going to configure it. So kernel source is huge. So it is for all the architectures, all the modules it present but we don't need everything. We need to configure the kernel for our requirements, for our project, for our board kind of a thing.

So what the kernel provides to us is we can configure it. Configurations are stored in a file called .config. So .config is a file which will store what are the configurations we are choosing for this particular kernel build. It is always located in the top level directory. So when you download the kernel source, it will be present in the top level directory. It will not be present by default. So when you download the source, the file will be present. But we need to create this .config file for our project.

So there are various provisions for it. So there are various provisions for it. It is given by the kernel. So what we have options are there, we can create from this graph. So we can do it manually or we have a procedure for doing it using a default configuration which is already available and we will see one by one. So configuring from this graph. So there is a command provided by the make file system, make build system. So it is called make config. So when we type this make config command, then what provides this, it will go through every configurations available in this kernel. And it will ask for whether we need to include it. Like we want to build it directly into a kernel, then you have to press Y. If you don't want that particular feature, then we can do it as a don't build using N.

There is also another option called module. So what this module is, it will not be a part of a kernel, which is part of our built environment, but not a part of our kernel. We can load it if needed during runtime. So it is not loaded in boot up time. So if the system is running, and in case we need that particular feature, then we can load it. So we will be seeing this modules in detail in the next week. So as of now, we can also select there is an option provided is here.

And if you need a help message for it, what each configuration is done, then we can press a question mark to it. So ideally, there are thousands of different configurations of operators. So answering each and every configuration is a very tedious task. So usually we will not go with this approach. So configuring from the scratch. So make config, provision is there, but mostly we will not be using it. And next thing is the default configuration. So kernel is maintained by a maintainer. So what he will do is, he has some system in which he is building the kernel.

And he considers these are the features will be good for his system and good for others too. And he will configure it and he will make it as a default one. So if I press make def config, so default configuration what a kernel maintainer has, their configuration file will be created for us. So make def config, or it will be different for each architecture to architecture. So it will differ. But this make def config may or may not be applicable to our system. So in which PC we are working on.

So it is the configuration we need to get from the Linux distributor. So Linux distributor in the sense Ubuntu. So this make def config is good to start and it will compile 100%. If that is, if you make def config configuration and if you compile it using make command, 100% So if you find any errors or warnings, you can report to the kernel component key. So apart from this, so one is from the scratch we are enabling each configuration. And next is we have provision for using default configuration from the maintainer. And that is also option for modifying the configuration using GUI tools.

So there are many things out there. So one is menu config, which is a normal terminal based form, which is a widely used configuration tool. And next is gconfig. So what is the framework they are underlying they are using. So that is the difference between them. So gconfig they use in GTK is a graphical tool. Xconfig is 2T based graphical tool. But what is the major role of these three things is they will get the input from the user using GUI. And finally, they will generate a .config file. Using the .config file, we will be compiling the kernel.

So first you will see make menu config. So this make menu config is based upon the library end cursor. So if this end cursor's library is installed in your system, then this make menu config will work seamless. So if it doesn't install, you can use command sudo apt install lib and cursus by hyphen dev. So this is a very widely used and it's also simple to use configuration. You have to go into your Linux top level directory and then type make menu config. So once you type make menu config, then you will get window like this.

So this is make menu config window. So you will be having, this is a top level things. So you can press enter to go inside it. So similarly, what we have seen in make config, we will have having three options for it. So whether you have to go select it using Y. If you don't want the particular module or driver, you can press N. If you want to build it as a module, not as a part of a kernel, then you can go for MR. And if you want to, since it is a huge number of configuration, so you can search for a particular configuration using slash, forward slash.

Then you can type what configuration is, then it will print, then which location it is. And the question mark, similarly, same thing. So if you want a message and you can use escape, you are going to navigate your current. So in the end, it will ask for your question, whether you need to save the configuration file or not. So press enter, then the configuration what you have selected will be saved in your config file. So this is an example screenshot of how your make menu config will look like.

And this is a make G config. If you press in make G config, this is one more options provided by. So we will be having a two pane, a right and left pane. So when we select each and every RQ subsystems or this is our high level modules, we can be able to select using this checkbox. So what we want, what we don't want. So we can explore each and everything and what best fit for us, we can use it. So usually make menu config is simple to use and it is widely used.

If you want advanced feature, we can go for make G config, X config and so on. So in this session, we will be looking into kernel building procedure. In the past session, how to get the kernel source and how to configure it using make menu config or make G config procedures. So once we have configured a kernel, so next is we are going to build the kernel. Kernel building can be done using this make command. So we have to give make and no arguments. So if you just give the make, what it does is it takes .config file as our input.

So it takes .config file which we created used by make menu config and then start compiling the code. So it has to be part of a kernel or which has to be built as a part of a module. So it takes the .config file as input and it starts building the kernel. So during the build process, so it prints what are the files it is being compiled and it prints if at all any errors or warnings up there. If we have any errors, build will stop.

So you have to make changes to a source file and you have to rebuild it using the make. So if the build is successful, we will get kernel images to generate that successfully. So build takes a lot of time. It goes for 30 minutes to one hour or more depends upon our PC capacity. If our PC is very slow and the single core or dual core, it takes much time. If it is a high capable machines or servers, it will time reduce. So there is a possibility like make gives us the feature to build the kernel faster by compiling it in the multiple processes.

So each in the codes are independent of each other. There is no dependency. It will be compiled in the multiple processes concurrently. So there is a parameter hyphen j can be used for it and with a number associated with n. If this n depends upon the number of core we have in our. For example, if your PC is 2 core, then you have to give make hyphen j 4. So n into 2. So 2 into 2 is 4. For example, if you have a 4 core machine, then you have to give 8.

4 into 2. So what it does is, it will compile our kernel source in 8 in all the 4 cores. So that compile time is reduced. So this is one of the features given by the make build system. So next is a case. So we are not concerned about the entire source file. So only we are concerned about a particular portion of a kernel and we want to compile or we want to build only that particular portion of a kernel. Then make gives one of the parameter like m.

So m equal to which folder we are going to compile. So in this case, what I am given is, I am giving the drivers slash net slash ethernet. So what it does is, it will go and compile only source files present in this particular folder and its subfolder. So ethernet net ethernet will have many subfolders. So it will just compile that particular folder. And this makes what it does is, it just compiles it. But it doesn't do any linking between them. So even if you do make m equal to driver, so compilation is done.

But it has. So this has to be linked with the final image which has to be installed. So for this we have to give make final step. So we have to execute this command make. So this is also one of the features given by our channel. So just give folder path or to be compiled and then give make for generating the final image. Next is considering that you have downloaded the kernel to your path. So in our case it is Linux under source. But I don't want outputs or the compiled image to be stored in the same directory location. Instead I want to save in different locations.

It can be network path or different locations. I want to keep my kernel source as a clean one. So in that case the make gives one more option. Make o equal. So what this o means is it is an output directory. So where the compiled code or generated kernel image to be stored. So first you go into your CD, into your path of kernel source. So in this case I can go into Linux underscore source. Then I can give make o equal to a path to our output location.

So this output location can be flash drive or network folder. So what it makes is it keeps our life simple. So I don't want to copy the generated image local system to the external devices like flash or network folder. So make itself will do that for us. So you can make use of it. So if it is an automatic build generation for you. We might be able to do it. In that case it's all and all. So we can make use of this provision given by the make.

So till now what we have done is we have built our kernel successfully. So we took .config file as our input and kernel source. And we built using the make utility to generate our final image. So next we will see how to install our kernel. So we have our images ready. So we need to see how we can install the kernel. So for installing this kernel. So what we have done is we have used our PC for compiling it. And we have got our images ready. So we need to install it.

So for installing this we need our root access. You need to have root privilege in your system to install it. So there are two commands that are available. So one is first we will be seeing modules installed. So in the make menu config we have seen. So we can have a module or a source of code or future can be compiled as a module. By using by selecting m in the make menu config. Or we can compile it as part of a kernel using while. So first what we have to do is we have to install the modules. For this we have a command called make modules install.

So once we give this command. But for installing this we need to have a sudo make modules underscore install. Once we give this command what it does is we will install what are the modules we compiled into the path lib module and kernel version. So which kernel version we are building. So if we compile for a version 5 underscore 15 underscore 0 then the kernel directory will be created for each version. Inside this modules will be installed first. So once the module is installed then the main kernel image has to be installed.

So for this we will be using the command called make install. So once we give this install command. What it does is it will install the static portion of our kernel image into this slash boot directory. In this we will be installing our static portion of our kernel. And then bootloader has to be notified of the process of a new kernel. So the major bootloader used in our PC environment is. So Grub is mainly used bootloader. So when you boot our Ubuntu OS opens to save thing.

So we will get Ubuntu OS. We will get options to choose which kernel version we have to use. If I compile for the 5.15.0 then I will get options which are 5.15.0 or if Ubuntu comes with a inbuilt version like 4.8.5 then I can move back to the original kernel versions comes with or go to by selecting that there will be a drop down list. We can select it. Subtitle. We use a black patch. We 5. podemos store it. Naos, we also put a kcer.

Want the rest of Linux Driver Development?

Get the full course syllabus and fees.

The full course is paid (₹40,000). We'll send the syllabus and call you back within one working day.

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.

Full course · paid

Unlock the full Linux Driver Development course

The remaining 35 lessons, mentor-reviewed projects and a certificate come with the paid course (₹40,000). Leave your details: we'll send the syllabus and fees and call you back.

Get the syllabus and fees

A counsellor calls you back within one working day.

By submitting you agree to our Terms and Privacy Policy.

Grow by Skill-Lync · free lesson

Start watching

Free, no payment. Leave your details once and every free lesson on Grow plays straight away. A Skill-Lync counsellor may call you about the full Linux Driver Development course.

By submitting you agree to our Terms and Privacy Policy.

Talk to a career counsellor

Talk to a career counsellor

Free 20-minute call. We'll map the right course to where you want to work.

By submitting you agree to our Terms and Privacy Policy.