I am trying to build my own module for usbhid.ko, but after I compiled, I can't load the module. dmesg says no symbol version for module_layout. I am wondering what is the problem? I have already used the kernel source provided by Ubuntu and I have also make sure the kernel version is the same.

3 Answers 3


Specifically what the problem is that when you built your module, the kernel source tree was probably missing the Modules.symvers file. The kbuild system actually warns you about this when you build your module. If Modules.symvers is missing, you'll see:

Warning: Symbol version dump /usr/src/linux-2.6.34-12/Modules.symvers is missing; modules will have no dependencies and modversions.

If your kernel has CONFIG_MODVERSIONS enabled, then during the modpost phase of building your driver it will run scripts/mod/modpost with the -m option. If you're brave and take a look at the scripts/mod/modpost.c source, you'll see that the -m option adds the _module_layout_ symbol from vmlinux, however if you don't have Modules.symvers from your kernel, you'll not get the CRC value for this symbol and you'll end up with this error message.

So there are two ways around this.

1) run a full build of your running kernel to generate Modules.symvers, then rebuild your module. [http://www.mjmwired.net/kernel/Documentation/kbuild/modules.txt][1]

51  === 2. How to Build External Modules
53  To build external modules, you must have a prebuilt kernel available
54  that contains the configuration and header files used in the build.
55  Also, the kernel must have been built with modules enabled. If you are
56  using a distribution kernel, there will be a package for the kernel you
57  are running provided by your distribution.
59  An alternative is to use the "make" target "modules_prepare." This will
60  make sure the kernel contains the information required. The target
61  exists solely as a simple way to prepare a kernel source tree for
62  building external modules.
64  NOTE: "modules_prepare" will not build Module.symvers even if
65  CONFIG_MODVERSIONS is set; therefore, a full kernel build needs to be
66  executed to make module versioning work.

2) The other option is to tell stupid modprobe to just ignore all that crap and just load your module anyways:

modprobe -f <module>

I tend to favor option 2 :)

  • 1
    +1 for "tell stupid modprobe to just ignore all that crap and just load your module anyways" comment. Mar 10, 2016 at 15:04
  • I tried 2 and found that the module won't auto load at boot time. is there a way to -f at boot time? Dec 16, 2018 at 4:22
  • "tell stupid modprobe to just ignore all that crap and just lock up your system anyways" FTFY. Sometimes errors matter. Jul 21, 2020 at 17:13

Have both the linux-headers and linux-source packages corresponding to your kernel installed. For example for kernel 3.2.0-27-generic-pae you need:

  1. linux-headers-3.2.0-27-generic-pae and
  2. linux-source-3.2.0-27-generic-pae.

In case the version for the packages above doesn't match your running kernel version then you need to replace $(uname -r) with the version string from your installed kernel package from above.
For the above example the package version is 3.2.0-27-generic-pae. When you run uname -r and its output is something different then 3.2.0-27-generic-pae then you need to replace each $(uname -r) below to match the version string from the installed packages.

  1. cd /usr/src/linux-source-$Version and unpack the .tar.bz2 archive in place and cd into the extracted directory - I guess you already did this
  2. cp /boot/config-$(uname -r) .config into the kernel source directory
  3. cp /usr/src/linux-headers-$(uname -r)/Module.symvers . into the kernel source directory

After you've done that, in the kernel source directory, do this:

  1. make prepare
  2. make scripts
  3. make M=drivers/usb/serial - change the path after M= to suit your needs

Unfortunately, I don't know how to build a specific module while keeping Module.symvers untouched. Doing make drivers/usb/serial/option.ko, for example, kills the Module.symvers file, and you end up with your original problem. Using the M= parameter doesn't kill it, but you have to build all the modules in the specified path - and I haven't found a way around it yet.

  • This seems the best way to do things, in case you're compiling the module in the same tree version...
    – Treviño
    Jul 13, 2013 at 19:46

You must use the precisely identical kernel configuration prior to running make prepare. Also, if you're building it out-of-tree, you need to be building it against the precisely identical kernel headers matching your currently running kernel (or the target one if you aren't running it at time of compilation).

  • "make mrproper" , "cp /boot/config-$(uname -r) .config" , "make oldconfig" , "make prepare" , "make scripts" I have used these instructions to prepare the compilation. I would like to know if I have copied the correct configuration file? seems like there is only one config which matches my kernel version in /boot/. sorry about the formatting as the comment box has no format....
    – SpecC
    Nov 24, 2010 at 8:27
  • Yes, that seems correct. Where are you invoking the build, and if not from the toplevel directory, what SUBDIRS value are you passing? Nov 24, 2010 at 11:36
  • thanks for the reply. when I tried to build the usbhid.ko. I used this command "make modules SUBDIRS=drivers/hid/usbhid"
    – SpecC
    Nov 25, 2010 at 8:08
  • when I ran the command "make modules SUBDIRS=drivers/hid/usbhid", I get the following warning "WARNING: Symbol version dump /usr/src/linux-source-2.6.31/Module.symvers is missing; modules will have no dependencies and modversions. "
    – SpecC
    Nov 25, 2010 at 21:30
  • @SpecC As you investigate your problem, update your original question with the steps you are taking. Then Dan will update his answer, and you will keep updating until you figure it out instead of a string of comments which end up buried, see the guide for more tips: meta.askubuntu.com/questions/257/how-does-ask-ubuntu-work Nov 27, 2010 at 14:44

You must log in to answer this question.

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