Why can't I bind-mount “/” inside a user namespace?

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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
12
down vote

favorite
1












Why doesn't this work?



$ unshare -rm mount --bind / /mnt
mount: /mnt: wrong fs type, bad option, bad superblock on /, missing codepage or helper program, or other error.


These work ok:



$ unshare -rm mount --bind /tmp /mnt
$ unshare -rm mount --bind /root /mnt
$



$ uname -r # Linux kernel version
4.17.3-200.fc28.x86_64






share|improve this question



























    up vote
    12
    down vote

    favorite
    1












    Why doesn't this work?



    $ unshare -rm mount --bind / /mnt
    mount: /mnt: wrong fs type, bad option, bad superblock on /, missing codepage or helper program, or other error.


    These work ok:



    $ unshare -rm mount --bind /tmp /mnt
    $ unshare -rm mount --bind /root /mnt
    $



    $ uname -r # Linux kernel version
    4.17.3-200.fc28.x86_64






    share|improve this question























      up vote
      12
      down vote

      favorite
      1









      up vote
      12
      down vote

      favorite
      1






      1





      Why doesn't this work?



      $ unshare -rm mount --bind / /mnt
      mount: /mnt: wrong fs type, bad option, bad superblock on /, missing codepage or helper program, or other error.


      These work ok:



      $ unshare -rm mount --bind /tmp /mnt
      $ unshare -rm mount --bind /root /mnt
      $



      $ uname -r # Linux kernel version
      4.17.3-200.fc28.x86_64






      share|improve this question













      Why doesn't this work?



      $ unshare -rm mount --bind / /mnt
      mount: /mnt: wrong fs type, bad option, bad superblock on /, missing codepage or helper program, or other error.


      These work ok:



      $ unshare -rm mount --bind /tmp /mnt
      $ unshare -rm mount --bind /root /mnt
      $



      $ uname -r # Linux kernel version
      4.17.3-200.fc28.x86_64








      share|improve this question












      share|improve this question




      share|improve this question








      edited Jul 18 at 22:31
























      asked Jul 18 at 22:22









      sourcejedi

      18k22375




      18k22375




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          15
          down vote



          accepted










          The difference is that / has child mounts. Inside a user namespace, you are not allowed to separate inherited mounts from their child mounts. A more obvious example is that you are not allowed to umount /proc. Otherwise, it could suddenly grant you access to files that were hidden underneath other mounts. Overmounts are sometimes used deliberately as a security measure.



          You are allowed to create a recursive bind mount instead, which preserves all the sub-mounts:



          $ unshare -rm mount --rbind / /mnt





          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%2f457100%2fwhy-cant-i-bind-mount-inside-a-user-namespace%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
            15
            down vote



            accepted










            The difference is that / has child mounts. Inside a user namespace, you are not allowed to separate inherited mounts from their child mounts. A more obvious example is that you are not allowed to umount /proc. Otherwise, it could suddenly grant you access to files that were hidden underneath other mounts. Overmounts are sometimes used deliberately as a security measure.



            You are allowed to create a recursive bind mount instead, which preserves all the sub-mounts:



            $ unshare -rm mount --rbind / /mnt





            share|improve this answer

























              up vote
              15
              down vote



              accepted










              The difference is that / has child mounts. Inside a user namespace, you are not allowed to separate inherited mounts from their child mounts. A more obvious example is that you are not allowed to umount /proc. Otherwise, it could suddenly grant you access to files that were hidden underneath other mounts. Overmounts are sometimes used deliberately as a security measure.



              You are allowed to create a recursive bind mount instead, which preserves all the sub-mounts:



              $ unshare -rm mount --rbind / /mnt





              share|improve this answer























                up vote
                15
                down vote



                accepted







                up vote
                15
                down vote



                accepted






                The difference is that / has child mounts. Inside a user namespace, you are not allowed to separate inherited mounts from their child mounts. A more obvious example is that you are not allowed to umount /proc. Otherwise, it could suddenly grant you access to files that were hidden underneath other mounts. Overmounts are sometimes used deliberately as a security measure.



                You are allowed to create a recursive bind mount instead, which preserves all the sub-mounts:



                $ unshare -rm mount --rbind / /mnt





                share|improve this answer













                The difference is that / has child mounts. Inside a user namespace, you are not allowed to separate inherited mounts from their child mounts. A more obvious example is that you are not allowed to umount /proc. Otherwise, it could suddenly grant you access to files that were hidden underneath other mounts. Overmounts are sometimes used deliberately as a security measure.



                You are allowed to create a recursive bind mount instead, which preserves all the sub-mounts:



                $ unshare -rm mount --rbind / /mnt






                share|improve this answer













                share|improve this answer



                share|improve this answer











                answered Jul 18 at 22:26









                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%2f457100%2fwhy-cant-i-bind-mount-inside-a-user-namespace%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