I want to learn more about the Linux kernel, which means I want to start compiling and testing my own kernel. I'm running Ubuntu 10.04 on my box, so I'll be using QEMU/KVM for virtualization.

I was hoping for something minimal at first, since for educational purposes extras aren't very helpful. I installed Ubuntu Server on the VM I created, and started following some instructions I found online for building the kernel.

That seemed like a mistake, because the instructions didn't do anything with make menuconfig and I know that's one of the steps. Plus, there's no /boot/grub/menu.lst on Ubuntu Server by default -- another problem for learning. Finally, when I tried doing make menuconfig on my own, I somehow asked for a metric s**t-ton of modules to be compiled, even though I tried to go through and un-check unecessary things.

So, can someone recommend a better way to go about building my own kernel in KVM for learning purposes?

  • If you really want to learn how to build a linux system from the ground up - I give you LFS. – EEAA Mar 6 '12 at 2:51

The directions you found were probably for building the kernel The Debian Way, which is quite a bit different from the basic process. Building a kernel is pretty straightforward.

Here is a good, simple description:


The executive summary:

  1. wget https://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.9.tar.bz2
  2. tar xjf linux-3.2.9.tar.bz2
  3. cd linux-3.2.9
  4. make menuconfig
  5. make all
  6. make install
  7. make modules_install

If you're running a recent version of Ubuntu, the grub config file is now /boot/grub/grub.cfg and has shiny new format. Ubuntu has a nice article on configuring the modern version of grub: https://help.ubuntu.com/community/Grub2

  • In my opinion GRUB2 does not have a shiny new configuration file format, I would call it brown. I hate the complexity of GRUB2 compared to original GRUB. – Janne Pikkarainen Mar 6 '12 at 9:13
  • Thanks for this! These are more the instructions I was expecting to find... The only thing is, it doesn't solve my hairy experience with step 4. When I do this, I end up compiling wayyyyyy too many modules. Is there a tutorial on cutting the cruft out of my config? – Robert Martin Mar 6 '12 at 16:54
  • The Gentoo guide seems to have a pretty decent set of guidelines. Primarily, though, you just need to start digging through menuconfig and reading the description of everything. gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=7 – Insyte Mar 6 '12 at 19:06
  • Since your goal is to use this as a learning experience, I would strongly suggest spending a couple of hours of quality time reading through the help text for each of the modules. You can skip some of the obviously irrelevant stuff (weird special purpose modules, filesystems you don't intend to use, hardware you don't have, etc.). – Insyte Mar 6 '12 at 19:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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