I'm trying to compile and install a kernel. After download the code and configure the installation I have executed succesfully these comands:

# make bzImage
# make modules
# make

But when I try to execute this other command:

# make install

I've got this error:

[root@Asterix linux-4.18.5]# make install
sh ./arch/x86/boot/install.sh 4.18.5 arch/x86/boot/bzImage \
        System.map "/boot"
depmod: ERROR: could not open directory /lib/modules/4.18.5: No such file or directory
depmod: FATAL: could not search modules: No such file or directory
Kernel version 4.18.5 has no module directory /lib/modules/4.18.5
[root@Asterix linux-4.18.5]#

What am I doing wrong? How can I fix this error?

  • 2
    Have you tried make install modules_install? – Andy Dalton Aug 28 '18 at 18:10
  • I think this is the last step, don't you? make bzImage, make modules, make, make install and make modules_install – José Carlos Aug 28 '18 at 18:12
  • Note that you don't need to run each as discrete steps. – Andy Dalton Aug 28 '18 at 20:09
  • Why I don't need to run all these steps? – José Carlos Aug 28 '18 at 20:11
  • 1
    @JoséCarlos you can remove your "Edit I:" and instead post it as an answer. After some time you can accept your own answer as the solution. This helps preserve the "Question and Answer" structure of the site. – Kevin Kruse Aug 28 '18 at 21:00

Fixed it!!!

@Andy Dalton gave me the solution!!! The correct sequence of commands to create the new Kernel and install it is:

# make
# make install modules_install

Modern vanilla kernels even include direct packaging options for a few formats:

.../linux$ make help


Kernel packaging:
  rpm-pkg             - Build both source and binary RPM kernel packages
  binrpm-pkg          - Build only the binary kernel RPM package
  deb-pkg             - Build both source and binary deb kernel packages
  bindeb-pkg          - Build only the binary kernel deb package
  snap-pkg            - Build only the binary kernel snap package (will connect to external hosts)
  tar-pkg             - Build the kernel as an uncompressed tarball
  targz-pkg           - Build the kernel as a gzip compressed tarball
  tarbz2-pkg          - Build the kernel as a bzip2 compressed tarball
  tarxz-pkg           - Build the kernel as a xz compressed tarball


So make binrpm-pkg should build one (or a few) package(s) directly for easy handling.

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.