I'm getting into Linux kernel programming and I have successfully built my own kernel several times now. However, I have done it using step by step guides found from the internet and I don't really understand what happens in the build process. So far I've found several different ways to build the kernel. One is:

make-kpkg -j5 --initrd kernel-image kernel-headers

As I understand it, make-kpkg is a Debian program designed for building and packaging kernel related stuff. --initrd is used to generate initrd image automatically. What are the last two arguments (kernel-image and kernel-headers) for?

Another way to build the kernel is just

make deb-pkg

What does this command do as compared to the first command?

Also, in this guide, building the kernel is done by:

fakeroot debian/rules clean
fakeroot debian/rules binary-headers binary-generic

Which is the recommended way to build the kernel on Ubuntu? What exactly happens when I execute one of the commands above? If I wished to do everything one of the commands above does manually, what steps would I have to take?

  • 1
    I think you're asking about packaging, not building. Building the kernel is configure make make install, or make menuconfig, make, make install... Oct 4, 2014 at 12:11
  • @hbdgaf This is building the kernel package. This includes building the kernel image (i.e. transforming a bunch of source files into an executable image) as well as building the package (i.e. bundling a bunch of files together in an archive). Oct 4, 2014 at 12:53
  • Does make also build all the modules or is that done separately?
    – Echows
    Oct 4, 2014 at 14:24
  • @Echows there's separate target for modules, modules-install iirc. Coming from Gentoo where I first built my kernel, I found that building it on Ubuntu/debian is quite more complicated, thanks to packaging it. One of the many reasons I prefer Gentoo. Aug 9, 2016 at 10:05

1 Answer 1


make-kpkg is a command from the package kernel-package, which used to be part of the official packaging infrastructure for the kernel packages that get shipped in the Debian distribution. It is not being used for that purpose anymore because the current maintainer for the kernel packages inside the Debian distribution chose to stop using it; however, the authors of the kernel-package package have not stopped maintaining it, so it is still an officially supported way of creating your own Debian packaged version of a kernel. It has various options and targets; the most important ones are the ones you refer to in your question, i.e., kernel-image (which builds a package containing the kernel and modules that you selected during make config), and kernel-headers (which contains the include files that you might need if you want to compile an out-of-tree module). The kernel-package package is maintained as part of the Debian (or derivative, like Ubuntu) release with which it was released, so as a result if things change in the Debian infrastructure then newer versions of kernel-package will be updated to incorporate it, and they will ship with that version of Debian. As a result, a kernel package created by the kernel-package package is always tailored best for the version of Debian on which it was created. However, if things change within the Linux kernel in a way that makes kernel-package break, then updating your kernel package for a stable version of Debian may be somewhat complicated.

make deb-pkg is a target in the Linux kernel's build infrastructure. It receives patches from Debian developers, but as it is not maintained within Debian itself, it always uses the tools and policies that are most up to date at the point in time where the kernel version you're trying to build was created. This means that in some cases, it might try to use a tool that isn't available on an older distribution yet. As it is not maintained inside Debian, it is not an officially-supported method (at least not from the point of view of Debian) for creating kernel packages; having said that though, it is mostly maintained by people who are involved in Debian, and so there is no reason to suspect that it won't work.

Whichever method you choose is just a matter of preference; unless you are heavily invested in peculiar outcomes of the package building options, both methods will work just fine.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .