Linux – How to start compiling Linux in a KVM virtual machine

kernellinux

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?

Best Answer

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:

http://www.cyberciti.biz/tips/compiling-linux-kernel-26.html

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