Why Compile a Linux Kernel from Source?

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
we're going to talk about how to compile a Linux kernel but why would you do that wh why there's several reasons that I can think of why you might want to compile a Linux kernel the first one is maybe you bought a new laptop like I did and the current versions of the Linux kernel that were included with your distribution didn't have the version that you needed so you can go to the source code for the Linux kernel and you can download download it and recompile it now if you're on some distributions you may be able to find that kernel already compiled for you so make sure that you that you you know you look for those first one of the other reasons is is kind of similar to that and that is maybe there's missing drivers in the current version of the kernel that your distribution is using say a Wi-Fi driver or which would be common or a sound driver that's another common one that's missing Ing and you need the newer kernel that has the driver in it that you need so it's kind of similar to the hey I have new hardware and I need support for it but yeah but also it could be just particular components on your existing Hardware that you need the third thing is you might want to optimize specific Hardware so you might want a custom kernel to allow you to tailor that to your specific Hardware potentially improving performance and resource utilization maybe you're trying to uh reduce the amount of footprint that the colel has or increase the performance now realize that there are a lot of different uh dials that you can turn in your existing kernel without having to go and generate one but there are a few that you can't and you have to go and and do that in the kernel there there's they're trying I mean the the Linux kernel folks have been trying over the years to red educe that so that you have the the uh ability to modify some of them uh through the Cy CTL or uh maybe modifying variables in your proc table uh can do that as well so it does pay to to spend some time and learn about the specific features of your kernel so you know what's going on you might need more customization and control over your kernel that is I'm enabling or I'm disabling features that uh that in the kernel that I may never use or maybe there's something I do want that's turned off so also you might want patches maybe you're you don't want to wait for your distribution to catch up with the patches and you're compiling that kernel so that you can get those specific patches which might address bugs it might add new features or it might in Implement security enhancements that are not yet available in the mainstream so one of the other ones is or is the obvious one is maybe you're just trying to learn all this stuff that's in the kernel and how to do it uh what you can change and what you can't now that's going to take a lot longer to learn because there's there is documentation all over but the best place to start is with the Linux kernel folks themselves they have some very good documents that will walk you through uh the basics of the kernel but they'll take you even a a level up they'll if you want to become a kernel developer they will take you all the way up that far so yeah you can go as far as you want and learn as much as you want about the kernel and that is really the the last reason is because you want to position yourself to contribute to the development of that kernel maybe there's something uh that you had an idea about that you want to add but you're not quite sure how to do it so this puts you on the road to understanding how the Kel works and the ways that you can you know create a change and submit it for inclusion in the next build I'm DJ wear and this is the Cyber Gizmo before we begin I would like to take a moment and thank my sponsors both my patreon members and also the members of the channel you guys make this content possible if you want to help I have a link below to join the patreons or you can join the channel let's go let's go through the steps on what we need uh and let's just kind of walk through it real quick and uh yeah you're you're going to have to set aside some time because the comp kernel is big and it will take it depends on your Hardware it can take anywhere from 20 minutes all the way up to several hours depending upon the speed of your Hardware so let's dive in let's get started okay so what we're going to do first is download the package that we need from here the latest one is right here is 679 so we can just click on that and we'll get a tar file down then we'll un we'll unar it it takes a while it's pretty big okay so the first thing we want we want to do is we want to make sure that we have all of the necessary packages we need in order to build this so uh let's get a list of those so the ones we need we need uh get fake root build essential and curses Dev XZ utils libssl-dev BC Flex lib elf ddev and bison and uh I'm on Debian doing this this is a straightup Debian 12 install so we'll go ahead and do that get these down they're already down so we'll do a uname and you can see I am on Debian it's 61018 and we're going to take this up to 679 so the next thing once we have our packages down we'll need to do a menu a make menu config now I have seen some places where they recommend that you copy over your existing config file yeah you can do that but I wouldn't recommend it the reason why I don't recommend it is it's fine if you want to do that if you're you're working on customizing your existing version of Linux but because we're going up so far there's going to be things in that old configuration in your boot directory that we don't want so yeah so we're going to we're going to start with the one that comes with the distro and unless you've made changes to your do config file um there shouldn't be any need to uh to copy it over anyway because these will have the same things in it but if you have done that hopefully you have documented what you changed and then you can make those changes here again so we get a menu up this is a curses menu uh and it's from here that you can make changes to the kernel so what kind of changes would you make well you might want to eliminate some things that maybe you don't need or or maybe you're you have maybe you're working on new code that you want to test and so yeah this will give you an opportunity to do that uh today there is really very little reason to recompile a kernel unless you just want to these are Keys you see the square braces around the option that has the asteris means that it's been selected the the square brackets means that this is as far as today I'm not changing anything I'm just going to compile this and use it on my Debian uh yeah so I'm just going to save it and it's going to create a new config file for me based on the entries in here and we should be done I should have a do config with today's date in it so at this point I am ready to do a make um there will be a problem but I'm just going to let it occur I'm going to give this uh A minus j4 which says to use four processors to do the compilation now this one this machine has six so yeah we can I'm I'm going to allocate one to uh the kernel and the other one to glances so and then that's why I'm only giving it four so well this will take some sometime so as you can see I have an air so and I can't see it I can scroll back here it's not where did it go and I and I'll hit the top and I won't know what it is so what I'm going to do is I'm just going to do the make again it should pick up right here and uh and then we'll know what the problem actually is I'm just no j4 just just to make so as you can see now I have the air up and it's saying disable config debug info BTF so the way you handle that is there is a scripts directory and in there there should be a a shell script called config see it's right there config so I can do and then we just put in a a minus D and then we have to go all the way back up I should have copied it it but it didn't so and we need to copy this right here because I'm I'm just going to disable it and when I hit paste it should put me right there okay so now this is going to start over because it's gonna yeah it's going to modify everything so okay just two more steps to do first one is we need to do a a c do make modules install this all the modules that are that go that are built by the kernel compile need to be placed into a special directory and that's what we're going to do here and there they go now the final step is to actually make the install that has added it to to our grub it has put all the necessary entries into our boot directory so the only thing left to do now is reboot and now hopefully we'll be able to uh yeah log in and check the system out let's see what we got 679 so we're up on the latest kernel and that completes as far as the actual build and of of Linux Colonel is concerned and my Debian is now converted to running 67.9 learning all the uh ins and outs of a kernel bill can take quite a bit of time to learn you can go as deep as you want to go I mean if you want to get to the point where you're writing your own device driver is great I mean that's that's wonderful but just realize take your time and there's a there's a lot of code in there a lot of cod code in there so with all of that I hope you enjoyed today's video on how to build a Linux kernel um yeah I'm not going to go in much deeper than this I mean it this video would turn into a a course so anyway hope you enjoyed it today and if you did uh please as always like And subscribe and hope to see you again in the next one and bye for now
Info
Channel: DJ Ware
Views: 25,736
Rating: undefined out of 5
Keywords: DJ Ware, djware, Debian 12, Debian, Linux Kernel Source, Building a Linux Kernel, Why Build a Linux Kernel, linux, cybergizmo
Id: s95hjvFAE5g
Channel Id: undefined
Length: 13min 38sec (818 seconds)
Published: Thu Mar 07 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.