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've read many tutorials about how to build custom kernels and boot Ubuntu using those kernels, and successfully followed the guides and booted custom kernels, but I have no understanding about what each of the command in the guides do and what is actually happening with each command.

The procedure described on Ubuntu's site does a lot of work with fakeroot, dpkg, make-kpkg, some initramfs, and other horrible stuff that works but simply does not help me understand what is going on.

  • What is the output of make in a linux kernel directory?
  • Does it create a "compressed kernel image"?
  • What is the name of the "compressed kernel image" file and where is it placed?
  • What does make modules do?
  • Should make modules be done before or after make?
  • Doesn't make build my modules automatically?
  • What is the process (in English, not just the list of commands) of adding newly built kernels to the list of bootable kernels?
  • What does make install do?
  • Will make install add it to my list of bootable kernels so that I don't have to do anything more?
  • Is there an equivalent make modules_install?
share|improve this question

migrated from stackoverflow.com Sep 16 '11 at 14:17

This question came from our site for professional and enthusiast programmers.

This should be split into multiple questions. –  Ciro Santilli 六四事件 法轮功 纳米比亚 威视 Aug 12 at 16:04

1 Answer 1

up vote 18 down vote accepted

From the top...

  • make compiles and links the kernel image. This is a single file named vmlinuz.
  • make modules compiles individual files for each question you answered M during kernel config. The object code is linked against your freshly built kernel. (For questions answered Y, these are already part of vmlinuz, and for questions answered N they are skipped).
  • make install installs your built kernel to /vmlinuz.
  • make modules_install installs your kernel modules to /lib/modules or /lib/modules/<version>.

As for adding it to the list of available kernels, that's taken care of by the boot loader. It's different for each boot loader, but grub is the most common on x86 and amd64 so I'll describe that. It's actually quite simple. Grub looks in /, /boot and /lib/modules for any thing that looks like it might be a working kernel and adds it. And yes, this is an oversimplified description.

That extra "horrible stuff" in the Ubuntu documentation is extra stuff to create a deb package. When you're doing it for more than yourself it's far better to package it. You'll switch in time.

Building the kernel and modules is kept separate because for the people who need to (i.e., kernel developers) they are often making changes to only a module. They can apply their changes, rebuild and install just the modules. This saves a lot of time when it has to be done 20 times a day. It will never be updated to have a single make everything command. You instead, run make && make modules && make install && make modules_install just like the documentation says to do. The build process favors kernel developers, not you. And that's the way it should be.

In reality there's almost no reason for anybody except kernel developers or distro packagers to compile a kernel. In almost any circumstance the kernel feature you want has already been built for you and is available in one of the pre-packaged kernels. There are exceptions, but they are exceedingly rare these days.

Not that I'm discouraging you from doing building your own kernel, I actually encourage you to do it. I think building your kernel from scratch is an invaluable practice for learning about how it all works down there. In part, because maybe one day you will be the exception that needs to. But it also teaches you a lot about the kernel & boot process in general. You will be a better person for having done it.

share|improve this answer
Thankyou very much for the human-readable description of the process. I have a few doubts. My kernel compilation produced vmlinux and not vmlinuz. I think the difference is compression. Should I compress the image manually ? Is /vmlinuz a directory in the root folder ? when I do a make install will this directory be created and new kernel be placed there ? Will make modules_install replace my currently installed modules ? Suppose I place my vmlinux in /boot directory, do I need to do something else (like edit grub configuration files and do grub-update or something after that ?) –  AnkurVj Sep 16 '11 at 15:18
You're right, the difference is compression. The command make bzimage is what does that. /vmlinuz is a binary file, not a directory. I have been making only packaged kernels for about the last 5 years, so I don't remember exactly the behavior of modules_install for a directly installed kernel. Grub will find your kernel in /boot without help. Yes you should always run grub-update after installing a new kernel. –  bahamat Sep 16 '11 at 15:25
so I should have done make bzimage instead of make ? DO I need to do a make clean and make bzimage again ? By /vmlinuz do you mean the file will be created in the root directory or in the linux kernel source directory ? –  AnkurVj Sep 16 '11 at 15:34
It doesn't really matter wether your kernel is compressed or not. Uncompressed it just takes up a little more disk space. Anything prefixed with / is an absolute path, so yes that's a file in the root. –  bahamat Sep 16 '11 at 17:54
Slight addendum: The initramfs part isn't "horrible" compared to what'll happen if you configured a kernel that requires an initrd but didn't actually create one to go with it. –  Shadur Mar 16 '14 at 12:06

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.