Are all kernel argument really used by the kernel?

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











up vote
3
down vote

favorite












Why does Linux allow ‘init=/bin/bash’?



I read this, answers are saying it's KERNEL running this init program.



Then I started to wonder, Linux usually comes with a initramfs, which will eventually mount and pivot_root to real root filesystem. So what does this init argument mean? The path in the initramfs? Or like I guessed, it's not read by the kernel but by init of initramfs to exec the real init.



Also, the root=UUID=xxxx argument, is that really read by kernel or just by init of initramfs to find the real root filesystem?



It seems like I can pass any argument I want as kernel arguments, so are they all read by the kernel or at least some of them are only meaningful to userspace programs?










share|improve this question

























    up vote
    3
    down vote

    favorite












    Why does Linux allow ‘init=/bin/bash’?



    I read this, answers are saying it's KERNEL running this init program.



    Then I started to wonder, Linux usually comes with a initramfs, which will eventually mount and pivot_root to real root filesystem. So what does this init argument mean? The path in the initramfs? Or like I guessed, it's not read by the kernel but by init of initramfs to exec the real init.



    Also, the root=UUID=xxxx argument, is that really read by kernel or just by init of initramfs to find the real root filesystem?



    It seems like I can pass any argument I want as kernel arguments, so are they all read by the kernel or at least some of them are only meaningful to userspace programs?










    share|improve this question























      up vote
      3
      down vote

      favorite









      up vote
      3
      down vote

      favorite











      Why does Linux allow ‘init=/bin/bash’?



      I read this, answers are saying it's KERNEL running this init program.



      Then I started to wonder, Linux usually comes with a initramfs, which will eventually mount and pivot_root to real root filesystem. So what does this init argument mean? The path in the initramfs? Or like I guessed, it's not read by the kernel but by init of initramfs to exec the real init.



      Also, the root=UUID=xxxx argument, is that really read by kernel or just by init of initramfs to find the real root filesystem?



      It seems like I can pass any argument I want as kernel arguments, so are they all read by the kernel or at least some of them are only meaningful to userspace programs?










      share|improve this question













      Why does Linux allow ‘init=/bin/bash’?



      I read this, answers are saying it's KERNEL running this init program.



      Then I started to wonder, Linux usually comes with a initramfs, which will eventually mount and pivot_root to real root filesystem. So what does this init argument mean? The path in the initramfs? Or like I guessed, it's not read by the kernel but by init of initramfs to exec the real init.



      Also, the root=UUID=xxxx argument, is that really read by kernel or just by init of initramfs to find the real root filesystem?



      It seems like I can pass any argument I want as kernel arguments, so are they all read by the kernel or at least some of them are only meaningful to userspace programs?







      linux-kernel






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      神秘德里克

      250110




      250110




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          Parameters passed on the kernel command line don’t have to be meaningful for the kernel: the kernel parameters documentation says




          The kernel parses parameters from the kernel command line up to “–”; if it doesn’t recognize a parameter and it doesn’t contain a ‘.’, the parameter gets passed to init: parameters with ‘=’ go into init’s environment, others are passed as command line arguments to init. Everything after “–” is passed as an argument to init.




          This doesn’t apply to init and root which really are kernel parameters, and are handled by the kernel. They can also be acted upon by user-space, since they appear in /proc/cmdline. (Thus for example systemd takes the quiet kernel parameter into account to reduce its output.)






          share|improve this answer




















          • Thany you. So, the init, is that the path in the initramfs? And root… why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?
            – ç¥žç§˜å¾·é‡Œå…‹
            1 hour ago










          • Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't find ld-linux.so ELF or recursion-too-deep script or anything just can't be execve?
            – ç¥žç§˜å¾·é‡Œå…‹
            1 hour ago







          • 1




            If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system and init is loaded from there; otherwise, the kernel mounts the file system on the device given by root and loads init from that (if it can mount it). If the init program is broken, then the system fails to boot with the “No init found.” message. init is run using do_execve so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.
            – Stephen Kitt
            1 hour ago










          • I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
            – plugwash
            52 mins ago










          • @plugwash you’re right, the kernel runs /init from the initramfs, and if that doesn’t exist, tries to run the program specified in init=, or /sbin/init, from the root file system.
            – Stephen Kitt
            43 mins ago

















          up vote
          1
          down vote













          Passing custom kernel arguments is one way to customize a system during a KickStart install, for example a PXE server could set:



          linuxefi /c7/vmlinuz ks=http://.../ks/c7 lab ksdevice=eth0 net.ifnames=0 biosdevname=0


          where lab is then used in the KickStart configuration to do different things than for other system builds:



          %pre
          ...
          case " $(cat /proc/cmdline)" in
          ...
          * lab*)
          filesystems_lab
          ;;
          *)
          filesystems_common
          ;;
          ...


          Here to setup a different filesystem layout than used on other system types. Hopefully different labels are used for local customizations than are used by the kernel, given the single namespace involved.






          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%2f473260%2fare-all-kernel-argument-really-used-by-the-kernel%23new-answer', 'question_page');

            );

            Post as a guest






























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            5
            down vote



            accepted










            Parameters passed on the kernel command line don’t have to be meaningful for the kernel: the kernel parameters documentation says




            The kernel parses parameters from the kernel command line up to “–”; if it doesn’t recognize a parameter and it doesn’t contain a ‘.’, the parameter gets passed to init: parameters with ‘=’ go into init’s environment, others are passed as command line arguments to init. Everything after “–” is passed as an argument to init.




            This doesn’t apply to init and root which really are kernel parameters, and are handled by the kernel. They can also be acted upon by user-space, since they appear in /proc/cmdline. (Thus for example systemd takes the quiet kernel parameter into account to reduce its output.)






            share|improve this answer




















            • Thany you. So, the init, is that the path in the initramfs? And root… why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?
              – ç¥žç§˜å¾·é‡Œå…‹
              1 hour ago










            • Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't find ld-linux.so ELF or recursion-too-deep script or anything just can't be execve?
              – ç¥žç§˜å¾·é‡Œå…‹
              1 hour ago







            • 1




              If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system and init is loaded from there; otherwise, the kernel mounts the file system on the device given by root and loads init from that (if it can mount it). If the init program is broken, then the system fails to boot with the “No init found.” message. init is run using do_execve so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.
              – Stephen Kitt
              1 hour ago










            • I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
              – plugwash
              52 mins ago










            • @plugwash you’re right, the kernel runs /init from the initramfs, and if that doesn’t exist, tries to run the program specified in init=, or /sbin/init, from the root file system.
              – Stephen Kitt
              43 mins ago














            up vote
            5
            down vote



            accepted










            Parameters passed on the kernel command line don’t have to be meaningful for the kernel: the kernel parameters documentation says




            The kernel parses parameters from the kernel command line up to “–”; if it doesn’t recognize a parameter and it doesn’t contain a ‘.’, the parameter gets passed to init: parameters with ‘=’ go into init’s environment, others are passed as command line arguments to init. Everything after “–” is passed as an argument to init.




            This doesn’t apply to init and root which really are kernel parameters, and are handled by the kernel. They can also be acted upon by user-space, since they appear in /proc/cmdline. (Thus for example systemd takes the quiet kernel parameter into account to reduce its output.)






            share|improve this answer




















            • Thany you. So, the init, is that the path in the initramfs? And root… why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?
              – ç¥žç§˜å¾·é‡Œå…‹
              1 hour ago










            • Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't find ld-linux.so ELF or recursion-too-deep script or anything just can't be execve?
              – ç¥žç§˜å¾·é‡Œå…‹
              1 hour ago







            • 1




              If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system and init is loaded from there; otherwise, the kernel mounts the file system on the device given by root and loads init from that (if it can mount it). If the init program is broken, then the system fails to boot with the “No init found.” message. init is run using do_execve so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.
              – Stephen Kitt
              1 hour ago










            • I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
              – plugwash
              52 mins ago










            • @plugwash you’re right, the kernel runs /init from the initramfs, and if that doesn’t exist, tries to run the program specified in init=, or /sbin/init, from the root file system.
              – Stephen Kitt
              43 mins ago












            up vote
            5
            down vote



            accepted







            up vote
            5
            down vote



            accepted






            Parameters passed on the kernel command line don’t have to be meaningful for the kernel: the kernel parameters documentation says




            The kernel parses parameters from the kernel command line up to “–”; if it doesn’t recognize a parameter and it doesn’t contain a ‘.’, the parameter gets passed to init: parameters with ‘=’ go into init’s environment, others are passed as command line arguments to init. Everything after “–” is passed as an argument to init.




            This doesn’t apply to init and root which really are kernel parameters, and are handled by the kernel. They can also be acted upon by user-space, since they appear in /proc/cmdline. (Thus for example systemd takes the quiet kernel parameter into account to reduce its output.)






            share|improve this answer












            Parameters passed on the kernel command line don’t have to be meaningful for the kernel: the kernel parameters documentation says




            The kernel parses parameters from the kernel command line up to “–”; if it doesn’t recognize a parameter and it doesn’t contain a ‘.’, the parameter gets passed to init: parameters with ‘=’ go into init’s environment, others are passed as command line arguments to init. Everything after “–” is passed as an argument to init.




            This doesn’t apply to init and root which really are kernel parameters, and are handled by the kernel. They can also be acted upon by user-space, since they appear in /proc/cmdline. (Thus for example systemd takes the quiet kernel parameter into account to reduce its output.)







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 1 hour ago









            Stephen Kitt

            148k23327394




            148k23327394











            • Thany you. So, the init, is that the path in the initramfs? And root… why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?
              – ç¥žç§˜å¾·é‡Œå…‹
              1 hour ago










            • Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't find ld-linux.so ELF or recursion-too-deep script or anything just can't be execve?
              – ç¥žç§˜å¾·é‡Œå…‹
              1 hour ago







            • 1




              If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system and init is loaded from there; otherwise, the kernel mounts the file system on the device given by root and loads init from that (if it can mount it). If the init program is broken, then the system fails to boot with the “No init found.” message. init is run using do_execve so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.
              – Stephen Kitt
              1 hour ago










            • I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
              – plugwash
              52 mins ago










            • @plugwash you’re right, the kernel runs /init from the initramfs, and if that doesn’t exist, tries to run the program specified in init=, or /sbin/init, from the root file system.
              – Stephen Kitt
              43 mins ago
















            • Thany you. So, the init, is that the path in the initramfs? And root… why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?
              – ç¥žç§˜å¾·é‡Œå…‹
              1 hour ago










            • Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't find ld-linux.so ELF or recursion-too-deep script or anything just can't be execve?
              – ç¥žç§˜å¾·é‡Œå…‹
              1 hour ago







            • 1




              If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system and init is loaded from there; otherwise, the kernel mounts the file system on the device given by root and loads init from that (if it can mount it). If the init program is broken, then the system fails to boot with the “No init found.” message. init is run using do_execve so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.
              – Stephen Kitt
              1 hour ago










            • I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
              – plugwash
              52 mins ago










            • @plugwash you’re right, the kernel runs /init from the initramfs, and if that doesn’t exist, tries to run the program specified in init=, or /sbin/init, from the root file system.
              – Stephen Kitt
              43 mins ago















            Thany you. So, the init, is that the path in the initramfs? And root… why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?
            – ç¥žç§˜å¾·é‡Œå…‹
            1 hour ago




            Thany you. So, the init, is that the path in the initramfs? And root… why it's useful to kernel? Shouldn't the real root mounted by the init in the initramfs? Basically , if they are handled by kernel, then for what?
            – ç¥žç§˜å¾·é‡Œå…‹
            1 hour ago












            Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't find ld-linux.so ELF or recursion-too-deep script or anything just can't be execve?
            – ç¥žç§˜å¾·é‡Œå…‹
            1 hour ago





            Also a little curious, what if init-in-the-initramfs is a set-uid-non-root file? A file without executable bit? Will it be run as root anyway? What if it's broken ELF or can't find ld-linux.so ELF or recursion-too-deep script or anything just can't be execve?
            – ç¥žç§˜å¾·é‡Œå…‹
            1 hour ago





            1




            1




            If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system and init is loaded from there; otherwise, the kernel mounts the file system on the device given by root and loads init from that (if it can mount it). If the init program is broken, then the system fails to boot with the “No init found.” message. init is run using do_execve so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.
            – Stephen Kitt
            1 hour ago




            If the boot loader loaded an initrd or initramfs alongside the kernel, then that becomes the root file system and init is loaded from there; otherwise, the kernel mounts the file system on the device given by root and loads init from that (if it can mount it). If the init program is broken, then the system fails to boot with the “No init found.” message. init is run using do_execve so I suspect it might well be affected by setuid bits etc., probably resulting in an unbootable system.
            – Stephen Kitt
            1 hour ago












            I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
            – plugwash
            52 mins ago




            I'm pretty sure the kernel doesn't load the program specified in "init=" from the initramfs. It an initramfs is in use then it seems to run as normal before the user-specified init program is run (not sure if it's the kernel that does this or code in the initramfs).
            – plugwash
            52 mins ago












            @plugwash you’re right, the kernel runs /init from the initramfs, and if that doesn’t exist, tries to run the program specified in init=, or /sbin/init, from the root file system.
            – Stephen Kitt
            43 mins ago




            @plugwash you’re right, the kernel runs /init from the initramfs, and if that doesn’t exist, tries to run the program specified in init=, or /sbin/init, from the root file system.
            – Stephen Kitt
            43 mins ago












            up vote
            1
            down vote













            Passing custom kernel arguments is one way to customize a system during a KickStart install, for example a PXE server could set:



            linuxefi /c7/vmlinuz ks=http://.../ks/c7 lab ksdevice=eth0 net.ifnames=0 biosdevname=0


            where lab is then used in the KickStart configuration to do different things than for other system builds:



            %pre
            ...
            case " $(cat /proc/cmdline)" in
            ...
            * lab*)
            filesystems_lab
            ;;
            *)
            filesystems_common
            ;;
            ...


            Here to setup a different filesystem layout than used on other system types. Hopefully different labels are used for local customizations than are used by the kernel, given the single namespace involved.






            share|improve this answer
























              up vote
              1
              down vote













              Passing custom kernel arguments is one way to customize a system during a KickStart install, for example a PXE server could set:



              linuxefi /c7/vmlinuz ks=http://.../ks/c7 lab ksdevice=eth0 net.ifnames=0 biosdevname=0


              where lab is then used in the KickStart configuration to do different things than for other system builds:



              %pre
              ...
              case " $(cat /proc/cmdline)" in
              ...
              * lab*)
              filesystems_lab
              ;;
              *)
              filesystems_common
              ;;
              ...


              Here to setup a different filesystem layout than used on other system types. Hopefully different labels are used for local customizations than are used by the kernel, given the single namespace involved.






              share|improve this answer






















                up vote
                1
                down vote










                up vote
                1
                down vote









                Passing custom kernel arguments is one way to customize a system during a KickStart install, for example a PXE server could set:



                linuxefi /c7/vmlinuz ks=http://.../ks/c7 lab ksdevice=eth0 net.ifnames=0 biosdevname=0


                where lab is then used in the KickStart configuration to do different things than for other system builds:



                %pre
                ...
                case " $(cat /proc/cmdline)" in
                ...
                * lab*)
                filesystems_lab
                ;;
                *)
                filesystems_common
                ;;
                ...


                Here to setup a different filesystem layout than used on other system types. Hopefully different labels are used for local customizations than are used by the kernel, given the single namespace involved.






                share|improve this answer












                Passing custom kernel arguments is one way to customize a system during a KickStart install, for example a PXE server could set:



                linuxefi /c7/vmlinuz ks=http://.../ks/c7 lab ksdevice=eth0 net.ifnames=0 biosdevname=0


                where lab is then used in the KickStart configuration to do different things than for other system builds:



                %pre
                ...
                case " $(cat /proc/cmdline)" in
                ...
                * lab*)
                filesystems_lab
                ;;
                *)
                filesystems_common
                ;;
                ...


                Here to setup a different filesystem layout than used on other system types. Hopefully different labels are used for local customizations than are used by the kernel, given the single namespace involved.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered 1 hour ago









                thrig

                22.9k12854




                22.9k12854



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f473260%2fare-all-kernel-argument-really-used-by-the-kernel%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    Installing NextGIS Connect into QGIS 3?

                    One-line joke