I want to learn about compiling a kernel from scratch. How can I download the latest stable Linux kernel from http://kernel.org/, compile it, and install it in a VMware virtual machine? This is just for educational purposes.
-
could you just clarify if you want to do exactly what you ask, or just run linux in a vm? because linux is more than a kernel, and you don't need to compile a kernel, and, even if you want to do that, there are easier ways than compiling on windows (for example, install a linux distro and then update the kernel). so it's probably best to clarify up front the details... – andrew cooke Mar 11 '12 at 20:56
-
@andrewcooke I just want to learn. May be one day I want to have my own linux distirbute :) – Mar 11 '12 at 21:00
-
I'm going to change this to just talk about compiling a kernel, and get rid of the "no use a distro" answers – Michael Mrozek Mar 13 '12 at 14:48
-
Before starting to compile, I'd read a lot of the kernel sources, starting at the arch directory, followed by the kernel, lib, fs. If your hair still isn't grey after that, sneak thru the Makefiles. – ott-- Dec 29 '12 at 18:16
3 Answers
Your question is too vague for anyone to give you a thoughtful answer, but here's the gist.
Compiling a kernel requires sources, so you'll need to get those. Most Linux distros have a package for downloading the latest sources, or you can go manual and just download the latest tarball from kernel.org
Then, once you have the sources, un-tar them somewhere (usually /usr/src
) cd
into it and use menuconfig
to compile it for your environment. When that's finished, you'll run make && make modules_install
and after a whole lot of output, you'll find a compiled kernel in arch/x86/boot/bzImage
-- assuming you're using an x86 architecture and you setup the kernel to use bz2 compression in menuconfig
.
For a more long-winded and useful howto, you should check out the Gentoo handbook.

- 614
You can compile the linux-0.11 edition first and install it on the "bochs" to learn about the linux kernel. The latest distribution of Linux is too complicated to handle with.
Are you currently using a Linux distribution? Most if not all allow you to boot from different Kernels
Download, the Kernel from kernel.org (As of Writing its 3.7.1)
The instructions within the readme file make it incredibly simple, just about all the configuration options are documented and a lot of times it will say 'If you don't know what 'x' is, then it can be N' or 'It's a good idea to say Y to this'
If you mess up, reboot into the previous system and use make menuconfig and change whatever value is missing and recompile (It won't recompile the whole Kernel again don't worry)
My first compile I personally disabled anything I didn't need the only hiccup for me was I didn't enable a virtual file system needed for the terminal.

- 41