Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I compiled the linux kernel by downloading it from kernel.org, put it on my desktop, and opened up terminal. I changed to the linux-3.2.13 folder, typed mr proper.
Then I use "make menuconfig" to configure my .config file. After I am done with that and I save it I type "make" and terminal starts to compile the files. After 3 hours of compiling I was wondering if I did something wrong.

My questions are:

  1. Did I do something wrong?
  2. If not what should I do next?
  3. What will the output be (ex. .bin, .elf)?
  4. My ultimate goal is to make an OS that I can put on a cd, put on another computer and run (not an Ubuntu OS with a different kernel).

Any help would be greatly appreciated!

ALSO I am using ubuntu in a virtual box on a macbook pro

share|improve this question
(The fact that you're using Ubuntu on Virtual Box doesn't change anything at all.) –  Mat Mar 30 '12 at 15:17
add comment

3 Answers

up vote 5 down vote accepted

Did I do something wrong?

Doesn't look like it. Compiling a recent kernel is very resource-consuming. If your CPU isn't recent, and you don't have a lot of RAM, it can take very long.
Make sure you only select the modules/features you actually need, and if you have a multi-core/thread machine with a bit of RAM, use the -jX option to make so that it can run the build in parallel. e.g.

make -j4

will use four cores for most of the build.

What will the output be?

It will be a compressed kernel image. It is not an ELF file, nor really an executable in the ordinary sense. It is in a format appropriate for your platform's bootloader to handle.

What should I do next?

Depends on what you're up to... (See here for a simple HOWTO to install the modules and the kernel image, assuming you're using Grub. There are plenty of other ones available with a quick search, and you're better off looking in your current distribution's documentation if you plan on actually running a mainstream distribution with your new kernel - there are feature requirements, and potentially initrd specificities that need to be taken into account.)

[My goal is to build my own OS]

I'm afraid you're very far from that. Building an OS is a very, very complex task - and getting the kernel to build is one of the very easy parts.

I'd suggest you head over to Linux From Scratch and read current stable "book". Also look on distrowatch, and search the "Source-based" category of distributions, some might be of interest to you.

share|improve this answer
When you say I am very far, what else would I have to do? –  Coder404 Mar 30 '12 at 14:26
If you want to create your own OS/Linux distribution, the kernel is a very important part of it, but it is also a (relatively) small part of it. Go read the Linux From Scratch "book" to see what I mean by that. If all you want is a custom LiveCD (i.e. tweak an existing thing), there are other options (searching for "custom linux livecd" should get you started, see also stackoverflow.com/questions/33117/…, and I'm sure there are other posts about that here too). –  Mat Mar 30 '12 at 14:30
Linux From Scratch was the answer I was typing, too, when @Matt's answer posted. That's definitely the best place to start. –  Tim Kennedy Mar 30 '12 at 15:11
I was told that LFS was an operating system not a book –  Coder404 Mar 30 '12 at 15:59
@Coder404: it's a "book" that describes how to build your own linux distribution. If you follow it exactly, you end up with a Linux from Scratch distribution. If you alter some of the steps, you end up with your own (which is what most people who use that do, I guess). –  Mat Mar 30 '12 at 16:00
show 1 more comment

I was posting big comments, and thought it might be best to post things as an answer, because the box is bigger and I can waffle all I want. :) I hope you'll excuse my insane ravings.

Also, I'll warn you now: I'm a complete bastard, and I'll be clipping your wings a bit.

The first thing you need to decide on is: how good are your programming skills? You can't write your own OS without good programming skills and a good understanding of hardware.

The second thing you need to decide is:

  1. Are you making a Linux distribution? (e.g. Debian, Ubuntu, Red Hat)
  2. Are you making a Linux-based operating system with a different runtime? (e.g. Android, Maemo)
  3. Are you writing an operating system from scratch? (e.g. VMS, CP/M, RT-11, Amoeba, Plan/9)

Before you even answer these questions, you should double check to make sure you've got your terms down, so you know what you're making.

1. A Linux Distribution (e.g. Debian)

If all you want to make is Yet Another Linux Distribution, compiling the kernel is the least of your worries. The kernel practically compiles itself, given enough time and a big enough computer.

Here is an article that discusses some of the aspects of making a Linux distributions.

Why this is harder than you might think: the more functionality you want to add to your distribution, the harder it'll get to get your distribution to build properly. You'll have to choose whether to re-invent the wheel (make your own package manager), or use an existing wheel (RPM? APT? Ports?). Either case, you'll be doing months of annoying work reconciling mutually incompatible packages, compiling, verifying things work using different computers with different CPUs (not just Intel or AMD), et cetera.

Depending on the scope, you may end up having to redo the work of thousands of people on your own. Would you learn a lot from it? Absolutely! But you'd also learn a lot by running an existing distribution of Linux, and occasionally compiling some packages on your own to see how things work. Why have to build libc and hundreds of other libraries if all you want to see is how an X server is built?

Think of it this way: if you want to learn how to assemble a PC, would you start with a bucket of transistors and a soldering iron, or get PC components and some documentation?

2. A Linux-based OS (e.g. Android)

There are quite a few Linux-based operating systems with runtimes fairly-to-drastically different from POSIX. Maemo, Meego, Android and other (most often embedded) operating systems come to mind.

The advantage of this is that you don't need to write your own kernel. The disadvantage of this is that you not only need to design your own distribution, but you'll also have to make most of the packages yourself. You thought compiling gcc and libc was a pain? Try writing your own ANSI-C-compatible C compiler and a full software stack from the ground up. Man years of writing annoying little functions (probably in Assembly) that provide tiny, tiny amounts of satisfaction. You'd also need to learn most of the internals of the Linux kernel, and how it talks to userspace, because that interface is what you'll be building on. You should know most syscall numbers by heart by the end of this. :)

Would you learn lots? Absolutely! More than you ever thought possible. Will it be frustrating and annoying? Oh yes. There's a reason Android wasn't built by a lone guy with a laptop in his spare time. Even gcc wasn't built that way.

3. An Operating System from scratch

This is where you start with an Assembler and C compiler and write your own kernel — if your OS even has a kernel. It's not universally the case. Download all the datasheets you can find for your hardware, and off you go. Once you have a basic kernel running, you can see about a runtime. You could write your own runtime, or you could make sure your kernel is partially or fully POSIX compatible, and then you'll have a full GNU runtime at your disposal. You'll ‘just’ have to make the first layer of libraries and get gcc running on your new OS.

Is this rewarding? Amazingly so. Will it be hard? If the names Donald Knuth, Andrew Tanenbaum mean nothing to you, you should probably reconsider. There'll be lots of studying theoretical computer science. There's an incredible amount of theory that goes into making an operating system truly from scratch. Unfortunately, there's also an amazing amount of tedium with modern systems.

It used to be, you just burned a ROM with a JMP instruction in the right place, socketed it, powered up, and you were done. Modern systems need serious amounts of work just to get a CPU core up and running, memory setup, an input device enumerated, and an output device started. There are entire books on each of these tasks (I have a book on the original VGA that's over 1,000 pages — growing up with 8-bit machines I'd assumed programming the 1987 VGA would have been simple, and I was seriously annoyed, but I learned a lot of stuff in the process!)

So, should you?

You absolutely should try. Don't have misconceptions about ‘succeeding’, unless your goals are set from the beginning. Maintaining an OS/distribution is an open-ended task that's usually done by large groups of people. But even attempting to do this will hone your skills and teach you new ones.

Btw, I'm speaking from (often painful) experience with respect to most of these things. I've (co-)written embedded low-level runtimes for a few CPUs (studies/work/fun), and I'm writing an toy OS for a toy CPU at the moment (that's all for fun).

share|improve this answer
Woah. That was intense. My goal that I had in mind was #2. A few years ago I had started to make a kernel. It was a total disaster. So I started to look toward linux. Are there any documents or references that you could suggest that for #2? –  Coder404 Mar 31 '12 at 14:13
If you can get hold of the Maemo SDK, it's a good example, and most of it is open source (barring necessarily closed-source applications like the GSM phone). Maemo only runs on ARM (the SDK emulates a Nokia tablet via qemu). It's Debian-based, makes heavy use of DBus, SQLite and has an X11+GTK GUI (you may not be able to use that — licensing). OpenWRT has no GUI, is more bare-bones. OpenWRT is a good choice too. It runs on many architectures and is made for routers so it's network-heavy and very light, which means it's simple to read the code. It still has a simple package manager though! –  Alexios Apr 1 '12 at 7:14
As the excellent rant above says, look around for something one lone guy can acomplish in a reasonable time. Most probably helping out on some distribution or hacking around on one project will keep you busy. –  vonbrand Jan 18 '13 at 1:22
add comment

Follow the steps given in the following tutorial to compile a kernel in Ubuntu:

How to compile a kernel: The Ubuntu Way"

share|improve this answer
but I dont want to make an os that runs ubuntu. I am trying to create a stand-alone os that runs its own system. The link that you shared describes how to take the linux kernel and update the kernel in ubuntu. Can the same methods be used for a stand-alone os? –  Coder404 Mar 30 '12 at 14:20
Philosophical question: is a distribution based on Linux a separate OS? If you start with the Linux (or any nix) kernel, you're going to be building something in a very particular direction. If you're making your own OS from *scratch (and not a Linux distribution), I recommend installing a virtual machine hypervisor like qemu or virtualbox and learning your preferred platform's low-level particulars: machine details, assembly language, etc. Start from that, not from an immense, ready-made system with all the decisions already made. –  Alexios Mar 30 '12 at 14:26
I did exactly that with VBox. I am trying to make the os with the kernel from kernel.org –  Coder404 Mar 30 '12 at 14:36
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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