How is modprobe run before mounting root? (no initrd)

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I am booting linux mint(version 4.14.13+) without using initrd/initramfs, and I see that /sbin/modprobe is run before mounting the root file system. I was wondering how that is possible. I instrumented the kernel to printk whenever file system is used and that's how I know that /sbin/modprobe was used.



The following link contains the full dmesg output of my boot: dmesg output




[ 3.175001] Used file system /sbin/modprobe!

[ 3.179080] Used file system /dev/console!

[ 3.844276] Used file system /dev/md0!

[ 3.899302] VFS: Mounted root (ext4 filesystem) on device 8:17.
[ 3.951578] devtmpfs: mounted

[ 3.987527] Used file system /bin/sh!






share|improve this question

























    up vote
    1
    down vote

    favorite












    I am booting linux mint(version 4.14.13+) without using initrd/initramfs, and I see that /sbin/modprobe is run before mounting the root file system. I was wondering how that is possible. I instrumented the kernel to printk whenever file system is used and that's how I know that /sbin/modprobe was used.



    The following link contains the full dmesg output of my boot: dmesg output




    [ 3.175001] Used file system /sbin/modprobe!

    [ 3.179080] Used file system /dev/console!

    [ 3.844276] Used file system /dev/md0!

    [ 3.899302] VFS: Mounted root (ext4 filesystem) on device 8:17.
    [ 3.951578] devtmpfs: mounted

    [ 3.987527] Used file system /bin/sh!






    share|improve this question























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I am booting linux mint(version 4.14.13+) without using initrd/initramfs, and I see that /sbin/modprobe is run before mounting the root file system. I was wondering how that is possible. I instrumented the kernel to printk whenever file system is used and that's how I know that /sbin/modprobe was used.



      The following link contains the full dmesg output of my boot: dmesg output




      [ 3.175001] Used file system /sbin/modprobe!

      [ 3.179080] Used file system /dev/console!

      [ 3.844276] Used file system /dev/md0!

      [ 3.899302] VFS: Mounted root (ext4 filesystem) on device 8:17.
      [ 3.951578] devtmpfs: mounted

      [ 3.987527] Used file system /bin/sh!






      share|improve this question













      I am booting linux mint(version 4.14.13+) without using initrd/initramfs, and I see that /sbin/modprobe is run before mounting the root file system. I was wondering how that is possible. I instrumented the kernel to printk whenever file system is used and that's how I know that /sbin/modprobe was used.



      The following link contains the full dmesg output of my boot: dmesg output




      [ 3.175001] Used file system /sbin/modprobe!

      [ 3.179080] Used file system /dev/console!

      [ 3.844276] Used file system /dev/md0!

      [ 3.899302] VFS: Mounted root (ext4 filesystem) on device 8:17.
      [ 3.951578] devtmpfs: mounted

      [ 3.987527] Used file system /bin/sh!








      share|improve this question












      share|improve this question




      share|improve this question








      edited Jul 13 at 22:56









      sourcejedi

      18k22375




      18k22375









      asked Jul 10 at 15:06









      systolicDrake

      505




      505




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          0
          down vote













          I don't think it is successfully running /sbin/modprobe. But there is something that interested me here. It looks like it tries to open /dev/console before "devtmpfs: mounted" or "Mounted root (ext4 filesystem)", and there is no other attempt to open /dev/console. But I thought the kernel had to open /dev/console from some filesystem for init (/bin/sh in your case)...



          It looks like if you do not have an initramfs, the kernel creates a very simple fake one. If I'm following correctly, this is why it can open /dev/console before it has mounted a real root filesystem.



          https://github.com/torvalds/linux/blob/v4.14/init/noinitramfs.c



          /*
          * Create a simple rootfs that is similar to the default initramfs
          */
          static int __init default_rootfs(void)
          {
          int err;

          err = sys_mkdir((const char __user __force *) "/dev", 0755);
          if (err < 0)
          goto out;

          err = sys_mknod((const char __user __force *) "/dev/console",
          S_IFCHR | S_IRUSR | S_IWUSR,
          new_encode_dev(MKDEV(5, 1)));
          if (err < 0)
          goto out;

          err = sys_mkdir((const char __user __force *) "/root", 0700);
          if (err < 0)
          goto out;

          return 0;


          The /root directory is relied on elsewhere in the kernel code, to mount and transition into the real root= filesystem.



          The commit that introduces this function clarifies that this specific function is only used when both initrd and initramfs support are compiled out. So otherwise, the "default initramfs" would provide the /dev/console and /root, if you did not pass a specific initramfs when booting the kernel, and you did not specify an initramfs to be built-in to the kernel.



          https://github.com/torvalds/linux/commit/c33df4eaaf41fd3e34837a6ae9a5f9970c393d9f






          share|improve this answer























            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: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            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%2f454511%2fhow-is-modprobe-run-before-mounting-root-no-initrd%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            0
            down vote













            I don't think it is successfully running /sbin/modprobe. But there is something that interested me here. It looks like it tries to open /dev/console before "devtmpfs: mounted" or "Mounted root (ext4 filesystem)", and there is no other attempt to open /dev/console. But I thought the kernel had to open /dev/console from some filesystem for init (/bin/sh in your case)...



            It looks like if you do not have an initramfs, the kernel creates a very simple fake one. If I'm following correctly, this is why it can open /dev/console before it has mounted a real root filesystem.



            https://github.com/torvalds/linux/blob/v4.14/init/noinitramfs.c



            /*
            * Create a simple rootfs that is similar to the default initramfs
            */
            static int __init default_rootfs(void)
            {
            int err;

            err = sys_mkdir((const char __user __force *) "/dev", 0755);
            if (err < 0)
            goto out;

            err = sys_mknod((const char __user __force *) "/dev/console",
            S_IFCHR | S_IRUSR | S_IWUSR,
            new_encode_dev(MKDEV(5, 1)));
            if (err < 0)
            goto out;

            err = sys_mkdir((const char __user __force *) "/root", 0700);
            if (err < 0)
            goto out;

            return 0;


            The /root directory is relied on elsewhere in the kernel code, to mount and transition into the real root= filesystem.



            The commit that introduces this function clarifies that this specific function is only used when both initrd and initramfs support are compiled out. So otherwise, the "default initramfs" would provide the /dev/console and /root, if you did not pass a specific initramfs when booting the kernel, and you did not specify an initramfs to be built-in to the kernel.



            https://github.com/torvalds/linux/commit/c33df4eaaf41fd3e34837a6ae9a5f9970c393d9f






            share|improve this answer



























              up vote
              0
              down vote













              I don't think it is successfully running /sbin/modprobe. But there is something that interested me here. It looks like it tries to open /dev/console before "devtmpfs: mounted" or "Mounted root (ext4 filesystem)", and there is no other attempt to open /dev/console. But I thought the kernel had to open /dev/console from some filesystem for init (/bin/sh in your case)...



              It looks like if you do not have an initramfs, the kernel creates a very simple fake one. If I'm following correctly, this is why it can open /dev/console before it has mounted a real root filesystem.



              https://github.com/torvalds/linux/blob/v4.14/init/noinitramfs.c



              /*
              * Create a simple rootfs that is similar to the default initramfs
              */
              static int __init default_rootfs(void)
              {
              int err;

              err = sys_mkdir((const char __user __force *) "/dev", 0755);
              if (err < 0)
              goto out;

              err = sys_mknod((const char __user __force *) "/dev/console",
              S_IFCHR | S_IRUSR | S_IWUSR,
              new_encode_dev(MKDEV(5, 1)));
              if (err < 0)
              goto out;

              err = sys_mkdir((const char __user __force *) "/root", 0700);
              if (err < 0)
              goto out;

              return 0;


              The /root directory is relied on elsewhere in the kernel code, to mount and transition into the real root= filesystem.



              The commit that introduces this function clarifies that this specific function is only used when both initrd and initramfs support are compiled out. So otherwise, the "default initramfs" would provide the /dev/console and /root, if you did not pass a specific initramfs when booting the kernel, and you did not specify an initramfs to be built-in to the kernel.



              https://github.com/torvalds/linux/commit/c33df4eaaf41fd3e34837a6ae9a5f9970c393d9f






              share|improve this answer

























                up vote
                0
                down vote










                up vote
                0
                down vote









                I don't think it is successfully running /sbin/modprobe. But there is something that interested me here. It looks like it tries to open /dev/console before "devtmpfs: mounted" or "Mounted root (ext4 filesystem)", and there is no other attempt to open /dev/console. But I thought the kernel had to open /dev/console from some filesystem for init (/bin/sh in your case)...



                It looks like if you do not have an initramfs, the kernel creates a very simple fake one. If I'm following correctly, this is why it can open /dev/console before it has mounted a real root filesystem.



                https://github.com/torvalds/linux/blob/v4.14/init/noinitramfs.c



                /*
                * Create a simple rootfs that is similar to the default initramfs
                */
                static int __init default_rootfs(void)
                {
                int err;

                err = sys_mkdir((const char __user __force *) "/dev", 0755);
                if (err < 0)
                goto out;

                err = sys_mknod((const char __user __force *) "/dev/console",
                S_IFCHR | S_IRUSR | S_IWUSR,
                new_encode_dev(MKDEV(5, 1)));
                if (err < 0)
                goto out;

                err = sys_mkdir((const char __user __force *) "/root", 0700);
                if (err < 0)
                goto out;

                return 0;


                The /root directory is relied on elsewhere in the kernel code, to mount and transition into the real root= filesystem.



                The commit that introduces this function clarifies that this specific function is only used when both initrd and initramfs support are compiled out. So otherwise, the "default initramfs" would provide the /dev/console and /root, if you did not pass a specific initramfs when booting the kernel, and you did not specify an initramfs to be built-in to the kernel.



                https://github.com/torvalds/linux/commit/c33df4eaaf41fd3e34837a6ae9a5f9970c393d9f






                share|improve this answer















                I don't think it is successfully running /sbin/modprobe. But there is something that interested me here. It looks like it tries to open /dev/console before "devtmpfs: mounted" or "Mounted root (ext4 filesystem)", and there is no other attempt to open /dev/console. But I thought the kernel had to open /dev/console from some filesystem for init (/bin/sh in your case)...



                It looks like if you do not have an initramfs, the kernel creates a very simple fake one. If I'm following correctly, this is why it can open /dev/console before it has mounted a real root filesystem.



                https://github.com/torvalds/linux/blob/v4.14/init/noinitramfs.c



                /*
                * Create a simple rootfs that is similar to the default initramfs
                */
                static int __init default_rootfs(void)
                {
                int err;

                err = sys_mkdir((const char __user __force *) "/dev", 0755);
                if (err < 0)
                goto out;

                err = sys_mknod((const char __user __force *) "/dev/console",
                S_IFCHR | S_IRUSR | S_IWUSR,
                new_encode_dev(MKDEV(5, 1)));
                if (err < 0)
                goto out;

                err = sys_mkdir((const char __user __force *) "/root", 0700);
                if (err < 0)
                goto out;

                return 0;


                The /root directory is relied on elsewhere in the kernel code, to mount and transition into the real root= filesystem.



                The commit that introduces this function clarifies that this specific function is only used when both initrd and initramfs support are compiled out. So otherwise, the "default initramfs" would provide the /dev/console and /root, if you did not pass a specific initramfs when booting the kernel, and you did not specify an initramfs to be built-in to the kernel.



                https://github.com/torvalds/linux/commit/c33df4eaaf41fd3e34837a6ae9a5f9970c393d9f







                share|improve this answer















                share|improve this answer



                share|improve this answer








                edited Jul 13 at 22:58


























                answered Jul 12 at 14:49









                sourcejedi

                18k22375




                18k22375






















                     

                    draft saved


                    draft discarded


























                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f454511%2fhow-is-modprobe-run-before-mounting-root-no-initrd%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Popular posts from this blog

                    How to check contact read email or not when send email to Individual?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay