I am compiling linux kernel on Debian Stretch:

cd linux-4.9.59/
make menuconfig

so far so good.

normally, I would then issue make modules_install, to copy the modules to /lib/modules/.

But this kernel is intended for another machine, so I don't want to copy the modules locally. Besides, I am not compiling as root, so writing to /lib/modules/ would not work anyway.

mkdir -vp "${INSTALL_MOD_PATH}

make modules_install

The above copies the newly compiled modules to directory ../MY_NEW_KERNEL/lib/modules/. But it does not generate the modules.dep and map files in ../MY_NEW_KERNEL/lib/modules/

Normally, if this was currently running kernel, I could run depmod to generate it in /lib/modules/. But I am not running this kernel on current machine.

And even when I copy bzImage and modules to the target machine, I would have to restart into the new kernel first, and then run depmod .

But the problem is, the kernel will not boot because it cannot find the modules, because I did not run depmod.

How can I run depmod for kernel modules, when the kernel is not currently running ?

1 Answer 1


To answer your question, this should work. The System.map was created in the just-built source directory and is required:

$ depmod -b "$INSTALL_MOD_PATH" -F System.map 4.9.59

Where 4.9.59 is your new non-running kernel's version.

Now, even the plain vanilla linux kernel source allows to build debian packages.

$ make help|grep deb
  deb-pkg             - Build both source and binary deb kernel packages
  bindeb-pkg          - Build only the binary kernel deb package

e,g: Instead of make and make modules_install (as normal user, root isn't needed):

stretch-amd64:~/linux-source-4.13.10$ make bindeb-pkg -j4

[... way later ...]

stretch-amd64:~/linux-source-4.13.10$ $ ls -1 ../*4.13.10*deb

Of course this might require a few additional debian packages, like dpkg-dev, fakeroot and a few related, but if the destination is a debian too, that's then perhaps easier to install it there.


You must log in to answer this question.

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