1

I'd like to get the answer in LOC.

I know that most of the modules/drivers, virtualization enhancements, android patches etc. can be excluded from kernel right away. But my question is more a call for verbose and theoretic answer, so it can be used as a reference by others.

So, what of Linux do I not need as a regular user? Better yet, let us imagine a casual computer user browsing web sites, doing some office processing etc. Nothing special or development/hacking.

In this stance, I'd like to know what parts of kernel and corresponding count of code can be removed from Linux.

And by this an outsider can know how really "monolithic" Linux is.

UPD: @MatthewRock I understand what you said in your answer and that's a reasonable piece of advice. I don't advocate for custom kernels if you read me that way. It's more about the status of usefulness of the parts of the default kernel. I think I better provide an example of what I think would be my perfect answer without answering myself, like:

You don't need these:

  • STM32's SPI code = XXXLOC

  • KVM Support = YYYLOC

  • "Hur Hur I'm a sheep" mark = ZZZLOC

closed as too broad by Jenny D, John WH Smith, Archemar, cuonglm, Anthon Sep 18 '15 at 13:24

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • You mean, you want us to tell you which modules/drivers/options you can unselect, and how many lines of code smaller will your kernel be? – MatthewRock Sep 18 '15 at 11:55
  • @MatthewRock almost, yes. I don't need that information actually, I'm just asking that because I think it'd be an interesting question. So what I need is to know how much of the LOC spare is occupied by the parts of the kernel that are more or less unneeded to a user.Yep. – rostamn739 Sep 18 '15 at 11:58
  • I'd argue that it's zero - there's no such thing as "spare LOC." All these LOC disappear the moment you compile kernel. Also, kernel is only ~150K LOC - the great deal of LOC is covered by drivers. And as I said, drivers depend on the hardware, and you may need some kernel features depending on what you are planning to do. Therefore, I'd suggest to reformat the question - otherwise I find it too broad, as the answers could literally take more than a half of kernel features. – MatthewRock Sep 18 '15 at 12:09
  • @MatthewRock your last comment is exactly the kind of answer I was waiting for. I don't know how to reformat the question though, so if it gains more votes maybe someone will find it interesting and do the edits you suggest/mark it as CW – rostamn739 Sep 18 '15 at 12:12
3

The simple answer is: it depends on your hardware and requirements.

Most Distributions provide you with kernel that's already compiled. These kernels are created so that they work on as many machines as possible - therefore, they contain many things that aren't really necessary for you.

Kernel contains a lot of things. You want to compile certain drivers - unfortunately I can't tell you which drivers - these depend on your hardware. You can skip the rest - you don't need the drivers you won't use anyway.

Kernel also supports some filesystems - if you know that you won't use certain filesystems, you may not compile these drivers too - you can always recompile kernel when need to use some filesystem arises.

So let's say that you are a casual Linux user. What should you do?

My advice would be: leave kernel as it is. Usually the kernel is just fine, and you won't gain anything noticeable from tweaking around. If you are inexperienced, this can also get messy if you get something wrong, so just to be on safe side - leave it be.

Same goes if you're "hacker" or "programmer". You don't need to tweak your kernel to be better programmer/make programming easier - after all, the programs should run on a kernel which isn't tweaked too(or what would be the point of the program?). Kernel configuration is mostly for enthusiasts, or people who need to do so(e.g. kernel for embedded devices). Funtoo - new project from creator of Gentoo - is using pre-compiled kernel too.

Compiling kernel by yourself, however, can be interesting experience. You can see (a bit) how it works, and what's "under the hood". You can make sure some things you want are turned on/off. You can learn more about Linux.

But honestly, if you don't need it - you're fine with your default kernel. If you want more, you can always look for pre-compiled hardened or otherwise customized kernels, and you'll be fine.

Not the answer you're looking for? Browse other questions tagged or ask your own question.