I am having trouble compiling the Raspbian kernel from source.

I used the instructions here: https://www.raspberrypi.org/documentation/linux/kernel/building.md.

I am cross compiling on Ubuntu 16.04 64 bit, and compiling for the Raspberry Pi 2. I have followed all the necessary steps according to the guide.

At the moment, I did not change anything in the kernel source (I want to change out the rtlwifi drivers later like this, but for now, I just want to see if I can compile a kernel.)

The compiling worked, and I uploaded the new kernel to the SD card, also according to the instructions. The RPI boots to the desktop screen, but no peripherals are working. I can SSH into the Pi, but keyboard / mouse are not working. I assume this is a kernel issue, as this is the only thing I have changed since I installed a completely working Raspbian (via the SD card image).

I have seen an error message during start up:

Failed to load kernel modules. 

And then it suggests I should check

systemctl status systemd-modules-load.service

Which returns:

systemd-modules-load.service - Load Kernel Modules
   Loaded: loaded (/lib/systemd/system/systemd-modules-load.service; static; ven
   Active: failed (Result: exit-code) since Thu 2016-11-03 17:16:42 UTC; 1 years
     Docs: man:systemd-modules-load.service(8)
  Process: 110 ExecStart=/lib/systemd/systemd-modules-load (code=exited, status=
 Main PID: 110 (code=exited, status=1/FAILURE)

Warning: Journal has been rotated since unit was started. Log output is incomple

Any advice on where I am going wrong? Or any ideas on how to debug? Thanks a lot!

EDIT: Thanks to @Gerhard, I realised the command that I install the modules were wrong. It was a simple typo - copy and paste is your friend!

Here is the script then in its working form for whoever would like to use it:

export KERNEL=kernel7
sudo mount /dev/sdc1 mnt/fat32
sudo mount /dev/sdc2 mnt/ext4

sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install

sudo cp mnt/fat32/$KERNEL.img mnt/fat32/$KERNEL-backup.img
sudo cp arch/arm/boot/zImage mnt/fat32/$KERNEL.img
sudo cp arch/arm/boot/dts/*.dtb mnt/fat32
sudo cp arch/arm/boot/dts/overlays/*.dtb* mnt/fat32/overlays/
sudo cp arch/arm/boot/dts/overlays/README mnt/fat32/overlays/
sudo umount mnt/fat32
sudo umount mnt/ext4
  • Is your kernel a monolith containing all modules? Or is there an initrd.img that you didn't transfer to your RPi? In the manual you followed, "sudo make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=mnt/ext4 modules_install" is all on one line. Mar 6, 2018 at 10:34
  • I think it is a monolith as you say (although I am not quite clued up about what that means). I did not copy an initrd.img. I did install the modules using the one line as you said above. I put it in a bash script, so it is executed as one line if that answers your question. Mar 6, 2018 at 10:48
  • Monolith: all in one. Anyway, the problem on the RPi is that the kernel and the modules (if they are there, verify /lib/modules) do not correspond. Did you overwrite the original kernel or give yours a special name? Mar 6, 2018 at 10:55
  • I simply overwrote the kernel7.img. Ok, so any suggestions on how the get the modules and kernel to correspond? Mar 6, 2018 at 10:58
  • Verify the contents of /lib/modules. Do you find those corresponding to kernel7.img's release? Mar 6, 2018 at 11:01

1 Answer 1


Install modules to the correct location! ;-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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