Are Modules listed under /sys/module all the Loaded Modules?












3















I'm wondering if I can use the directory listing of /sys/module instead of lsmod to get a list of currently loaded modules.



Is that the list of loaded modules only? Or maybe that combined with /sys/module/*/initstate?










share|improve this question





























    3















    I'm wondering if I can use the directory listing of /sys/module instead of lsmod to get a list of currently loaded modules.



    Is that the list of loaded modules only? Or maybe that combined with /sys/module/*/initstate?










    share|improve this question



























      3












      3








      3








      I'm wondering if I can use the directory listing of /sys/module instead of lsmod to get a list of currently loaded modules.



      Is that the list of loaded modules only? Or maybe that combined with /sys/module/*/initstate?










      share|improve this question
















      I'm wondering if I can use the directory listing of /sys/module instead of lsmod to get a list of currently loaded modules.



      Is that the list of loaded modules only? Or maybe that combined with /sys/module/*/initstate?







      linux kernel-modules sysfs






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Aug 26 '15 at 23:06









      Gilles

      539k12810891606




      539k12810891606










      asked Aug 26 '15 at 20:13









      Kyle BrandtKyle Brandt

      397114




      397114






















          1 Answer
          1






          active

          oldest

          votes


















          6














          Each loaded module has an entry in /sys/module. But there are also kernel components with an entry in /sys/module that are not loaded as modules. Each kernel component¹ that can be built as a module has an entry in /sys/module, whether it is compiled and loaded as a module or compiled as part of the main kernel image.



          lsmod gets the list of loaded modules from /proc/modules.



          I think that only loaded modules have an initstate file in their /sys/module directory, so you can use that too.



          ¹ That's each component of the loaded kernel. The kernel doesn't know or care what modules you may have in files on your hard disk. The kernel doesn't care what modules were built at the same time of the kernel image, either; it may show that via /proc/config but it doesn't use that information for anything.






          share|improve this answer


























          • A fun side effect is that you can't insmod modules that are named exactly like built-in modules and you become totally clueless why: unix.stackexchange.com/questions/364956/…

            – Ciro Santilli 新疆改造中心 六四事件 法轮功
            Apr 16 '18 at 14:21











          • @Gilles I was wondering if you could clarify "Each kernel component that can be built as a module has an entry in /sys/module". On my system: lsmod | wc -l => 116. ls /sys/module | wc -l = >201. grep '=m' /boot/config-$(uname -r) => 4934.

            – catanman
            3 hours ago











          • @catanman That's the loaded modules. Usually you would only load a small number of modules compared to the number that were built, and you may load modules that were built separately.

            – Gilles
            3 hours ago






          • 1





            No. You have 2389 options set to y, not all of which are components (some are yes/no settings but not a distinct component). You have 4934 components available as modules. You have 116 loaded modules, and 201-116=85 components that could be loaded as modules, but are built in.

            – Gilles
            2 hours ago






          • 1





            @catanman 1) Look in the Kconfig files in the kernel source (either directly or via a kernel configuration tool). 2) Yes. 3) Yes (but you'd need to have a compatible .ko file, which is hard to ensure unless the file was built from the same kernel version with the same options).

            – Gilles
            1 hour ago











          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',
          autoActivateHeartbeat: false,
          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%2f225706%2fare-modules-listed-under-sys-module-all-the-loaded-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









          6














          Each loaded module has an entry in /sys/module. But there are also kernel components with an entry in /sys/module that are not loaded as modules. Each kernel component¹ that can be built as a module has an entry in /sys/module, whether it is compiled and loaded as a module or compiled as part of the main kernel image.



          lsmod gets the list of loaded modules from /proc/modules.



          I think that only loaded modules have an initstate file in their /sys/module directory, so you can use that too.



          ¹ That's each component of the loaded kernel. The kernel doesn't know or care what modules you may have in files on your hard disk. The kernel doesn't care what modules were built at the same time of the kernel image, either; it may show that via /proc/config but it doesn't use that information for anything.






          share|improve this answer


























          • A fun side effect is that you can't insmod modules that are named exactly like built-in modules and you become totally clueless why: unix.stackexchange.com/questions/364956/…

            – Ciro Santilli 新疆改造中心 六四事件 法轮功
            Apr 16 '18 at 14:21











          • @Gilles I was wondering if you could clarify "Each kernel component that can be built as a module has an entry in /sys/module". On my system: lsmod | wc -l => 116. ls /sys/module | wc -l = >201. grep '=m' /boot/config-$(uname -r) => 4934.

            – catanman
            3 hours ago











          • @catanman That's the loaded modules. Usually you would only load a small number of modules compared to the number that were built, and you may load modules that were built separately.

            – Gilles
            3 hours ago






          • 1





            No. You have 2389 options set to y, not all of which are components (some are yes/no settings but not a distinct component). You have 4934 components available as modules. You have 116 loaded modules, and 201-116=85 components that could be loaded as modules, but are built in.

            – Gilles
            2 hours ago






          • 1





            @catanman 1) Look in the Kconfig files in the kernel source (either directly or via a kernel configuration tool). 2) Yes. 3) Yes (but you'd need to have a compatible .ko file, which is hard to ensure unless the file was built from the same kernel version with the same options).

            – Gilles
            1 hour ago
















          6














          Each loaded module has an entry in /sys/module. But there are also kernel components with an entry in /sys/module that are not loaded as modules. Each kernel component¹ that can be built as a module has an entry in /sys/module, whether it is compiled and loaded as a module or compiled as part of the main kernel image.



          lsmod gets the list of loaded modules from /proc/modules.



          I think that only loaded modules have an initstate file in their /sys/module directory, so you can use that too.



          ¹ That's each component of the loaded kernel. The kernel doesn't know or care what modules you may have in files on your hard disk. The kernel doesn't care what modules were built at the same time of the kernel image, either; it may show that via /proc/config but it doesn't use that information for anything.






          share|improve this answer


























          • A fun side effect is that you can't insmod modules that are named exactly like built-in modules and you become totally clueless why: unix.stackexchange.com/questions/364956/…

            – Ciro Santilli 新疆改造中心 六四事件 法轮功
            Apr 16 '18 at 14:21











          • @Gilles I was wondering if you could clarify "Each kernel component that can be built as a module has an entry in /sys/module". On my system: lsmod | wc -l => 116. ls /sys/module | wc -l = >201. grep '=m' /boot/config-$(uname -r) => 4934.

            – catanman
            3 hours ago











          • @catanman That's the loaded modules. Usually you would only load a small number of modules compared to the number that were built, and you may load modules that were built separately.

            – Gilles
            3 hours ago






          • 1





            No. You have 2389 options set to y, not all of which are components (some are yes/no settings but not a distinct component). You have 4934 components available as modules. You have 116 loaded modules, and 201-116=85 components that could be loaded as modules, but are built in.

            – Gilles
            2 hours ago






          • 1





            @catanman 1) Look in the Kconfig files in the kernel source (either directly or via a kernel configuration tool). 2) Yes. 3) Yes (but you'd need to have a compatible .ko file, which is hard to ensure unless the file was built from the same kernel version with the same options).

            – Gilles
            1 hour ago














          6












          6








          6







          Each loaded module has an entry in /sys/module. But there are also kernel components with an entry in /sys/module that are not loaded as modules. Each kernel component¹ that can be built as a module has an entry in /sys/module, whether it is compiled and loaded as a module or compiled as part of the main kernel image.



          lsmod gets the list of loaded modules from /proc/modules.



          I think that only loaded modules have an initstate file in their /sys/module directory, so you can use that too.



          ¹ That's each component of the loaded kernel. The kernel doesn't know or care what modules you may have in files on your hard disk. The kernel doesn't care what modules were built at the same time of the kernel image, either; it may show that via /proc/config but it doesn't use that information for anything.






          share|improve this answer















          Each loaded module has an entry in /sys/module. But there are also kernel components with an entry in /sys/module that are not loaded as modules. Each kernel component¹ that can be built as a module has an entry in /sys/module, whether it is compiled and loaded as a module or compiled as part of the main kernel image.



          lsmod gets the list of loaded modules from /proc/modules.



          I think that only loaded modules have an initstate file in their /sys/module directory, so you can use that too.



          ¹ That's each component of the loaded kernel. The kernel doesn't know or care what modules you may have in files on your hard disk. The kernel doesn't care what modules were built at the same time of the kernel image, either; it may show that via /proc/config but it doesn't use that information for anything.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 3 hours ago

























          answered Aug 27 '15 at 0:28









          GillesGilles

          539k12810891606




          539k12810891606













          • A fun side effect is that you can't insmod modules that are named exactly like built-in modules and you become totally clueless why: unix.stackexchange.com/questions/364956/…

            – Ciro Santilli 新疆改造中心 六四事件 法轮功
            Apr 16 '18 at 14:21











          • @Gilles I was wondering if you could clarify "Each kernel component that can be built as a module has an entry in /sys/module". On my system: lsmod | wc -l => 116. ls /sys/module | wc -l = >201. grep '=m' /boot/config-$(uname -r) => 4934.

            – catanman
            3 hours ago











          • @catanman That's the loaded modules. Usually you would only load a small number of modules compared to the number that were built, and you may load modules that were built separately.

            – Gilles
            3 hours ago






          • 1





            No. You have 2389 options set to y, not all of which are components (some are yes/no settings but not a distinct component). You have 4934 components available as modules. You have 116 loaded modules, and 201-116=85 components that could be loaded as modules, but are built in.

            – Gilles
            2 hours ago






          • 1





            @catanman 1) Look in the Kconfig files in the kernel source (either directly or via a kernel configuration tool). 2) Yes. 3) Yes (but you'd need to have a compatible .ko file, which is hard to ensure unless the file was built from the same kernel version with the same options).

            – Gilles
            1 hour ago



















          • A fun side effect is that you can't insmod modules that are named exactly like built-in modules and you become totally clueless why: unix.stackexchange.com/questions/364956/…

            – Ciro Santilli 新疆改造中心 六四事件 法轮功
            Apr 16 '18 at 14:21











          • @Gilles I was wondering if you could clarify "Each kernel component that can be built as a module has an entry in /sys/module". On my system: lsmod | wc -l => 116. ls /sys/module | wc -l = >201. grep '=m' /boot/config-$(uname -r) => 4934.

            – catanman
            3 hours ago











          • @catanman That's the loaded modules. Usually you would only load a small number of modules compared to the number that were built, and you may load modules that were built separately.

            – Gilles
            3 hours ago






          • 1





            No. You have 2389 options set to y, not all of which are components (some are yes/no settings but not a distinct component). You have 4934 components available as modules. You have 116 loaded modules, and 201-116=85 components that could be loaded as modules, but are built in.

            – Gilles
            2 hours ago






          • 1





            @catanman 1) Look in the Kconfig files in the kernel source (either directly or via a kernel configuration tool). 2) Yes. 3) Yes (but you'd need to have a compatible .ko file, which is hard to ensure unless the file was built from the same kernel version with the same options).

            – Gilles
            1 hour ago

















          A fun side effect is that you can't insmod modules that are named exactly like built-in modules and you become totally clueless why: unix.stackexchange.com/questions/364956/…

          – Ciro Santilli 新疆改造中心 六四事件 法轮功
          Apr 16 '18 at 14:21





          A fun side effect is that you can't insmod modules that are named exactly like built-in modules and you become totally clueless why: unix.stackexchange.com/questions/364956/…

          – Ciro Santilli 新疆改造中心 六四事件 法轮功
          Apr 16 '18 at 14:21













          @Gilles I was wondering if you could clarify "Each kernel component that can be built as a module has an entry in /sys/module". On my system: lsmod | wc -l => 116. ls /sys/module | wc -l = >201. grep '=m' /boot/config-$(uname -r) => 4934.

          – catanman
          3 hours ago





          @Gilles I was wondering if you could clarify "Each kernel component that can be built as a module has an entry in /sys/module". On my system: lsmod | wc -l => 116. ls /sys/module | wc -l = >201. grep '=m' /boot/config-$(uname -r) => 4934.

          – catanman
          3 hours ago













          @catanman That's the loaded modules. Usually you would only load a small number of modules compared to the number that were built, and you may load modules that were built separately.

          – Gilles
          3 hours ago





          @catanman That's the loaded modules. Usually you would only load a small number of modules compared to the number that were built, and you may load modules that were built separately.

          – Gilles
          3 hours ago




          1




          1





          No. You have 2389 options set to y, not all of which are components (some are yes/no settings but not a distinct component). You have 4934 components available as modules. You have 116 loaded modules, and 201-116=85 components that could be loaded as modules, but are built in.

          – Gilles
          2 hours ago





          No. You have 2389 options set to y, not all of which are components (some are yes/no settings but not a distinct component). You have 4934 components available as modules. You have 116 loaded modules, and 201-116=85 components that could be loaded as modules, but are built in.

          – Gilles
          2 hours ago




          1




          1





          @catanman 1) Look in the Kconfig files in the kernel source (either directly or via a kernel configuration tool). 2) Yes. 3) Yes (but you'd need to have a compatible .ko file, which is hard to ensure unless the file was built from the same kernel version with the same options).

          – Gilles
          1 hour ago





          @catanman 1) Look in the Kconfig files in the kernel source (either directly or via a kernel configuration tool). 2) Yes. 3) Yes (but you'd need to have a compatible .ko file, which is hard to ensure unless the file was built from the same kernel version with the same options).

          – Gilles
          1 hour ago


















          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.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f225706%2fare-modules-listed-under-sys-module-all-the-loaded-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

          Histoire des bourses de valeurs

          Why is there Russian traffic in my log files?

          Rename multiple files to decrement number in file name?