load module via /etc/modules











up vote
5
down vote

favorite












I want to load my kernel module hello.ko on boot in Ubuntu 12.04. I placed it in /lib/modules/3.8.0-31-generic/kernel/ubuntu/hello.ko, ran depmod -a, and added "hello" to /etc/modules.



However, when I restart, there is no "hello" module in lsmod. In /var/log/upstart/module-init-tools.log there is a string "FATAL: Module hello not found."



If I run modprobe hello everything is fine. What's wrong with /etc/modules? Where is it trying to find modules?










share|improve this question




























    up vote
    5
    down vote

    favorite












    I want to load my kernel module hello.ko on boot in Ubuntu 12.04. I placed it in /lib/modules/3.8.0-31-generic/kernel/ubuntu/hello.ko, ran depmod -a, and added "hello" to /etc/modules.



    However, when I restart, there is no "hello" module in lsmod. In /var/log/upstart/module-init-tools.log there is a string "FATAL: Module hello not found."



    If I run modprobe hello everything is fine. What's wrong with /etc/modules? Where is it trying to find modules?










    share|improve this question


























      up vote
      5
      down vote

      favorite









      up vote
      5
      down vote

      favorite











      I want to load my kernel module hello.ko on boot in Ubuntu 12.04. I placed it in /lib/modules/3.8.0-31-generic/kernel/ubuntu/hello.ko, ran depmod -a, and added "hello" to /etc/modules.



      However, when I restart, there is no "hello" module in lsmod. In /var/log/upstart/module-init-tools.log there is a string "FATAL: Module hello not found."



      If I run modprobe hello everything is fine. What's wrong with /etc/modules? Where is it trying to find modules?










      share|improve this question















      I want to load my kernel module hello.ko on boot in Ubuntu 12.04. I placed it in /lib/modules/3.8.0-31-generic/kernel/ubuntu/hello.ko, ran depmod -a, and added "hello" to /etc/modules.



      However, when I restart, there is no "hello" module in lsmod. In /var/log/upstart/module-init-tools.log there is a string "FATAL: Module hello not found."



      If I run modprobe hello everything is fine. What's wrong with /etc/modules? Where is it trying to find modules?







      linux kernel-modules






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 8 '14 at 18:13









      drs

      3,29352858




      3,29352858










      asked Aug 8 '14 at 18:00









      Andrey Romanchev

      2612




      2612






















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          Run sudo update-initramfs -u to get your module in the initial ramdisk for the current kernel. Otherwise it will not load on init.






          share|improve this answer

















          • 2




            This is not necessary. Modules listed in /etc/modules are loaded on init (from the kmod job, which runs once udev is up).
            – Gilles
            Aug 9 '14 at 20:07










          • @Gilles It is necessary. If the module does not exist in the initrd, then init can obviously not load it when it has not yet mounted any filesystems.
            – Lekensteyn
            Aug 10 '14 at 11:51






          • 2




            You're confusing the /init script in the initramfs and the init system which is Upstart. The initramfs doesn't even contain /etc/modules, that's part of the root filesystem. There's an Upstart job (kmod) that loads modules listed in /etc/modules. This happens after the root filesystem is mounted, it has nothing to do with the initramfs.
            – Gilles
            Aug 10 '14 at 19:53










          • Can you doublecheck if the running kernel is the correct version with the path you placed the module with uname -r. Please also check the output of modinfo /lib/modules/3.8.0-31-generic/kernel/ubuntu/hello.ko.
            – Thomas
            Jun 26 '16 at 14:48










          • @Gilles You were right, kmod loads the module after the rootfs is mounted. Since /etc/modprobe.d/ did end up in the initramfs I supposed that it would also be the case for /etc/modules which is apparently not true.
            – Lekensteyn
            Jun 27 '16 at 9:49











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f149282%2fload-module-via-etc-modules%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          0
          down vote













          Run sudo update-initramfs -u to get your module in the initial ramdisk for the current kernel. Otherwise it will not load on init.






          share|improve this answer

















          • 2




            This is not necessary. Modules listed in /etc/modules are loaded on init (from the kmod job, which runs once udev is up).
            – Gilles
            Aug 9 '14 at 20:07










          • @Gilles It is necessary. If the module does not exist in the initrd, then init can obviously not load it when it has not yet mounted any filesystems.
            – Lekensteyn
            Aug 10 '14 at 11:51






          • 2




            You're confusing the /init script in the initramfs and the init system which is Upstart. The initramfs doesn't even contain /etc/modules, that's part of the root filesystem. There's an Upstart job (kmod) that loads modules listed in /etc/modules. This happens after the root filesystem is mounted, it has nothing to do with the initramfs.
            – Gilles
            Aug 10 '14 at 19:53










          • Can you doublecheck if the running kernel is the correct version with the path you placed the module with uname -r. Please also check the output of modinfo /lib/modules/3.8.0-31-generic/kernel/ubuntu/hello.ko.
            – Thomas
            Jun 26 '16 at 14:48










          • @Gilles You were right, kmod loads the module after the rootfs is mounted. Since /etc/modprobe.d/ did end up in the initramfs I supposed that it would also be the case for /etc/modules which is apparently not true.
            – Lekensteyn
            Jun 27 '16 at 9:49















          up vote
          0
          down vote













          Run sudo update-initramfs -u to get your module in the initial ramdisk for the current kernel. Otherwise it will not load on init.






          share|improve this answer

















          • 2




            This is not necessary. Modules listed in /etc/modules are loaded on init (from the kmod job, which runs once udev is up).
            – Gilles
            Aug 9 '14 at 20:07










          • @Gilles It is necessary. If the module does not exist in the initrd, then init can obviously not load it when it has not yet mounted any filesystems.
            – Lekensteyn
            Aug 10 '14 at 11:51






          • 2




            You're confusing the /init script in the initramfs and the init system which is Upstart. The initramfs doesn't even contain /etc/modules, that's part of the root filesystem. There's an Upstart job (kmod) that loads modules listed in /etc/modules. This happens after the root filesystem is mounted, it has nothing to do with the initramfs.
            – Gilles
            Aug 10 '14 at 19:53










          • Can you doublecheck if the running kernel is the correct version with the path you placed the module with uname -r. Please also check the output of modinfo /lib/modules/3.8.0-31-generic/kernel/ubuntu/hello.ko.
            – Thomas
            Jun 26 '16 at 14:48










          • @Gilles You were right, kmod loads the module after the rootfs is mounted. Since /etc/modprobe.d/ did end up in the initramfs I supposed that it would also be the case for /etc/modules which is apparently not true.
            – Lekensteyn
            Jun 27 '16 at 9:49













          up vote
          0
          down vote










          up vote
          0
          down vote









          Run sudo update-initramfs -u to get your module in the initial ramdisk for the current kernel. Otherwise it will not load on init.






          share|improve this answer












          Run sudo update-initramfs -u to get your module in the initial ramdisk for the current kernel. Otherwise it will not load on init.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Aug 8 '14 at 18:17









          Lekensteyn

          9,710115086




          9,710115086








          • 2




            This is not necessary. Modules listed in /etc/modules are loaded on init (from the kmod job, which runs once udev is up).
            – Gilles
            Aug 9 '14 at 20:07










          • @Gilles It is necessary. If the module does not exist in the initrd, then init can obviously not load it when it has not yet mounted any filesystems.
            – Lekensteyn
            Aug 10 '14 at 11:51






          • 2




            You're confusing the /init script in the initramfs and the init system which is Upstart. The initramfs doesn't even contain /etc/modules, that's part of the root filesystem. There's an Upstart job (kmod) that loads modules listed in /etc/modules. This happens after the root filesystem is mounted, it has nothing to do with the initramfs.
            – Gilles
            Aug 10 '14 at 19:53










          • Can you doublecheck if the running kernel is the correct version with the path you placed the module with uname -r. Please also check the output of modinfo /lib/modules/3.8.0-31-generic/kernel/ubuntu/hello.ko.
            – Thomas
            Jun 26 '16 at 14:48










          • @Gilles You were right, kmod loads the module after the rootfs is mounted. Since /etc/modprobe.d/ did end up in the initramfs I supposed that it would also be the case for /etc/modules which is apparently not true.
            – Lekensteyn
            Jun 27 '16 at 9:49














          • 2




            This is not necessary. Modules listed in /etc/modules are loaded on init (from the kmod job, which runs once udev is up).
            – Gilles
            Aug 9 '14 at 20:07










          • @Gilles It is necessary. If the module does not exist in the initrd, then init can obviously not load it when it has not yet mounted any filesystems.
            – Lekensteyn
            Aug 10 '14 at 11:51






          • 2




            You're confusing the /init script in the initramfs and the init system which is Upstart. The initramfs doesn't even contain /etc/modules, that's part of the root filesystem. There's an Upstart job (kmod) that loads modules listed in /etc/modules. This happens after the root filesystem is mounted, it has nothing to do with the initramfs.
            – Gilles
            Aug 10 '14 at 19:53










          • Can you doublecheck if the running kernel is the correct version with the path you placed the module with uname -r. Please also check the output of modinfo /lib/modules/3.8.0-31-generic/kernel/ubuntu/hello.ko.
            – Thomas
            Jun 26 '16 at 14:48










          • @Gilles You were right, kmod loads the module after the rootfs is mounted. Since /etc/modprobe.d/ did end up in the initramfs I supposed that it would also be the case for /etc/modules which is apparently not true.
            – Lekensteyn
            Jun 27 '16 at 9:49








          2




          2




          This is not necessary. Modules listed in /etc/modules are loaded on init (from the kmod job, which runs once udev is up).
          – Gilles
          Aug 9 '14 at 20:07




          This is not necessary. Modules listed in /etc/modules are loaded on init (from the kmod job, which runs once udev is up).
          – Gilles
          Aug 9 '14 at 20:07












          @Gilles It is necessary. If the module does not exist in the initrd, then init can obviously not load it when it has not yet mounted any filesystems.
          – Lekensteyn
          Aug 10 '14 at 11:51




          @Gilles It is necessary. If the module does not exist in the initrd, then init can obviously not load it when it has not yet mounted any filesystems.
          – Lekensteyn
          Aug 10 '14 at 11:51




          2




          2




          You're confusing the /init script in the initramfs and the init system which is Upstart. The initramfs doesn't even contain /etc/modules, that's part of the root filesystem. There's an Upstart job (kmod) that loads modules listed in /etc/modules. This happens after the root filesystem is mounted, it has nothing to do with the initramfs.
          – Gilles
          Aug 10 '14 at 19:53




          You're confusing the /init script in the initramfs and the init system which is Upstart. The initramfs doesn't even contain /etc/modules, that's part of the root filesystem. There's an Upstart job (kmod) that loads modules listed in /etc/modules. This happens after the root filesystem is mounted, it has nothing to do with the initramfs.
          – Gilles
          Aug 10 '14 at 19:53












          Can you doublecheck if the running kernel is the correct version with the path you placed the module with uname -r. Please also check the output of modinfo /lib/modules/3.8.0-31-generic/kernel/ubuntu/hello.ko.
          – Thomas
          Jun 26 '16 at 14:48




          Can you doublecheck if the running kernel is the correct version with the path you placed the module with uname -r. Please also check the output of modinfo /lib/modules/3.8.0-31-generic/kernel/ubuntu/hello.ko.
          – Thomas
          Jun 26 '16 at 14:48












          @Gilles You were right, kmod loads the module after the rootfs is mounted. Since /etc/modprobe.d/ did end up in the initramfs I supposed that it would also be the case for /etc/modules which is apparently not true.
          – Lekensteyn
          Jun 27 '16 at 9:49




          @Gilles You were right, kmod loads the module after the rootfs is mounted. Since /etc/modprobe.d/ did end up in the initramfs I supposed that it would also be the case for /etc/modules which is apparently not true.
          – Lekensteyn
          Jun 27 '16 at 9:49


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f149282%2fload-module-via-etc-modules%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Morgemoulin

          Scott Moir

          Souastre