0

How does the terms

make, make bzImage, make modules, make install, make modules_install relate to each other.

One kernel tutorial I saw used all make bzImage, make modules, make install, make modules_install commands to compile and install a new kernel. While another one used only make, make install and make modules_install commanads. So what are the differences?

1

Over time, the Linux kernel compilation process has itself been developed further. It has become more complex, but also more streamlined. Run make help in the kernel source directory to see a list of all make targets and brief explanations of each.

With the current 5.x kernel series, the commands make and make all are equivalent: both of them will run an architecture-specific list of default targets.

On the x86 hardware architecture, the default list contains:

  • make vmlinux to build the bare kernel (this is also automatically executed if you run make bzImage, as before you can make a compressed bootable kernel image file, you'll first need to make the thing you'll want to compress; the uncompressed version is also useful for certain kernel debugging tools.)
  • make modules to build the kernel modules
  • make bzImage to create the bootable compressed kernel image file.

All of the above can be executed as a regular user, without extra privileges.

On the other hand, make install will use either ~/bin/installkernel or /sbin/installkernel if they exist. Your own ~/bin/installkernel might include the use of sudo or similar where applicable, but the system /sbin/installkernel is typically written to expect that you already have root access.

Likewise, make modules_install will copy the modules of the new kernel version to /lib/modules/<kernel_version>/ directory tree, so it will require root access to run successfully.

As the best practice is to avoid running any long and complicated processes (such as kernel compilation!) as root if there is no specific need, the current minimal kernel compilation process would be something like:

  • configure kernel as a regular user
  • run make or make all as a regular user
  • run sudo make modules_install to install the kernel modules
  • run sudo make install to install the actual kernel. I would recommend doing this last, since /sbin/installkernel may trigger other operations like automatic building of an initramfs file, and those other operations would be more successful if the new kernel modules are already in place.

But if you are doing kernel development and not just building a customized kernel for your own needs, you might want to use a more fine-grained process; for example, if you are developing a kernel module, you might want to run make modules as a separate step so you can more easily see if it fails because of an error you've made, and can get to fixing the error more quickly. After fixing the error, you will then be able to just skip to running make modules again, as the previous steps are already successfully done.

Likewise, a developer working with the early kernel start-up process might just want the bzImage for testing in another system (one with a tricky set of ACPI tables or whatever), and not care about the modules at all.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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