Does order of mount operations matter when mounting into an existing mountpoint?












5















The question Best practice when mounting a new disk within an existing mount?
inspired me to ask this follow-up question:



The other question asked whether it is ok to



mount /dev/sdb1 /home
mount /dev/sdb2 /home/mythtv


so that /home/mythtv is a mountpoint within the mountpoint
/home. (spoiler: Yes, it is perfectly ok.).



What if I'd change the order of commands to



mount /dev/sdb2 /home/mythtv
mount /dev/sdb1 /home


Will that yield the same result or will /home/mythtv be hidden by /home?
I assume /home contains an (empty) directory /home/mythtv.










share|improve this question



























    5















    The question Best practice when mounting a new disk within an existing mount?
    inspired me to ask this follow-up question:



    The other question asked whether it is ok to



    mount /dev/sdb1 /home
    mount /dev/sdb2 /home/mythtv


    so that /home/mythtv is a mountpoint within the mountpoint
    /home. (spoiler: Yes, it is perfectly ok.).



    What if I'd change the order of commands to



    mount /dev/sdb2 /home/mythtv
    mount /dev/sdb1 /home


    Will that yield the same result or will /home/mythtv be hidden by /home?
    I assume /home contains an (empty) directory /home/mythtv.










    share|improve this question

























      5












      5








      5


      1






      The question Best practice when mounting a new disk within an existing mount?
      inspired me to ask this follow-up question:



      The other question asked whether it is ok to



      mount /dev/sdb1 /home
      mount /dev/sdb2 /home/mythtv


      so that /home/mythtv is a mountpoint within the mountpoint
      /home. (spoiler: Yes, it is perfectly ok.).



      What if I'd change the order of commands to



      mount /dev/sdb2 /home/mythtv
      mount /dev/sdb1 /home


      Will that yield the same result or will /home/mythtv be hidden by /home?
      I assume /home contains an (empty) directory /home/mythtv.










      share|improve this question














      The question Best practice when mounting a new disk within an existing mount?
      inspired me to ask this follow-up question:



      The other question asked whether it is ok to



      mount /dev/sdb1 /home
      mount /dev/sdb2 /home/mythtv


      so that /home/mythtv is a mountpoint within the mountpoint
      /home. (spoiler: Yes, it is perfectly ok.).



      What if I'd change the order of commands to



      mount /dev/sdb2 /home/mythtv
      mount /dev/sdb1 /home


      Will that yield the same result or will /home/mythtv be hidden by /home?
      I assume /home contains an (empty) directory /home/mythtv.







      mount






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 4 at 11:08









      PerlDuckPerlDuck

      5,85111333




      5,85111333






















          1 Answer
          1






          active

          oldest

          votes


















          11














          Yes, it matters! Your first example:



          mount /dev/sdb1 /home
          mount /dev/sdb2 /home/mythtv


          is the only right way, when mounting you must respect the tree order.



          In your second example,



          mount /dev/sdb2 /home/mythtv
          mount /dev/sdb1 /home


          If we are assuming /home/mythtv exists on the filesystem, it is gonna mount it with no problem, but after you mount the second volume you won't be able to access the first one anymore.



          This is because you let the system mount sdb2 on an existing path at /home/mythtv. When you mount on /home/, you are telling your system to mount it on the /home path which also exists but is going to "cover" existing mount point. They are both mounted, but when you type cd /home/mythtv, Bash takes you to sdb1:/home/mythtv instead sdb2:/home/mythtv because they are different paths.



          I hope the explanation is clear. If not, please ask in the comments, I'll try to get it to you more clearly.



          Update



          as per @mook765's comment, the order is important also in the fstab files:



          The fstab file is read up to down while mounting, and down to up when umounting. In another case, if you try to umount /home before /home/mythtv mount will tell you the /home resource is busy because you have the /home/mythtv mounted and it cannot handle it.






          share|improve this answer





















          • 2





            @PerlDuck This is also important for /etc/fstab, line order matters.

            – mook765
            Jan 4 at 11:37






          • 1





            Yes Absolutely, @mook765 say the true, fstab file when mount is read up to down, and when umount down to up, in other case if you try to umount /home before /home/mythtv mount will say to you the /home resource is busy, because have the /home/mythtv mounted and cannot handle it.

            – AtomiX84
            Jan 4 at 11:47













          • In which cases would /etc/fstab be used for unmounting? The only thing I could think of is umount -a, but that command looks at what's actually mounted, not /etc/fstab.

            – kasperd
            Jan 4 at 16:02











          • by reading here seems it also used by umount: man7.org/linux/man-pages/man5/fstab.5.html, anyway after thinking a while on this (if you can confirm to me) the umount go to read the fstab when you invoke: umount /mount/point. But I repeat, may I misunderstanding the process of umount, the mount I'm sure is gonna to work like I had describe.

            – AtomiX84
            Jan 4 at 18:44











          • Up to down? You mean bottom up or top down???

            – FreeSoftwareServers
            Jan 4 at 21:23











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2faskubuntu.com%2fquestions%2f1106879%2fdoes-order-of-mount-operations-matter-when-mounting-into-an-existing-mountpoint%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









          11














          Yes, it matters! Your first example:



          mount /dev/sdb1 /home
          mount /dev/sdb2 /home/mythtv


          is the only right way, when mounting you must respect the tree order.



          In your second example,



          mount /dev/sdb2 /home/mythtv
          mount /dev/sdb1 /home


          If we are assuming /home/mythtv exists on the filesystem, it is gonna mount it with no problem, but after you mount the second volume you won't be able to access the first one anymore.



          This is because you let the system mount sdb2 on an existing path at /home/mythtv. When you mount on /home/, you are telling your system to mount it on the /home path which also exists but is going to "cover" existing mount point. They are both mounted, but when you type cd /home/mythtv, Bash takes you to sdb1:/home/mythtv instead sdb2:/home/mythtv because they are different paths.



          I hope the explanation is clear. If not, please ask in the comments, I'll try to get it to you more clearly.



          Update



          as per @mook765's comment, the order is important also in the fstab files:



          The fstab file is read up to down while mounting, and down to up when umounting. In another case, if you try to umount /home before /home/mythtv mount will tell you the /home resource is busy because you have the /home/mythtv mounted and it cannot handle it.






          share|improve this answer





















          • 2





            @PerlDuck This is also important for /etc/fstab, line order matters.

            – mook765
            Jan 4 at 11:37






          • 1





            Yes Absolutely, @mook765 say the true, fstab file when mount is read up to down, and when umount down to up, in other case if you try to umount /home before /home/mythtv mount will say to you the /home resource is busy, because have the /home/mythtv mounted and cannot handle it.

            – AtomiX84
            Jan 4 at 11:47













          • In which cases would /etc/fstab be used for unmounting? The only thing I could think of is umount -a, but that command looks at what's actually mounted, not /etc/fstab.

            – kasperd
            Jan 4 at 16:02











          • by reading here seems it also used by umount: man7.org/linux/man-pages/man5/fstab.5.html, anyway after thinking a while on this (if you can confirm to me) the umount go to read the fstab when you invoke: umount /mount/point. But I repeat, may I misunderstanding the process of umount, the mount I'm sure is gonna to work like I had describe.

            – AtomiX84
            Jan 4 at 18:44











          • Up to down? You mean bottom up or top down???

            – FreeSoftwareServers
            Jan 4 at 21:23
















          11














          Yes, it matters! Your first example:



          mount /dev/sdb1 /home
          mount /dev/sdb2 /home/mythtv


          is the only right way, when mounting you must respect the tree order.



          In your second example,



          mount /dev/sdb2 /home/mythtv
          mount /dev/sdb1 /home


          If we are assuming /home/mythtv exists on the filesystem, it is gonna mount it with no problem, but after you mount the second volume you won't be able to access the first one anymore.



          This is because you let the system mount sdb2 on an existing path at /home/mythtv. When you mount on /home/, you are telling your system to mount it on the /home path which also exists but is going to "cover" existing mount point. They are both mounted, but when you type cd /home/mythtv, Bash takes you to sdb1:/home/mythtv instead sdb2:/home/mythtv because they are different paths.



          I hope the explanation is clear. If not, please ask in the comments, I'll try to get it to you more clearly.



          Update



          as per @mook765's comment, the order is important also in the fstab files:



          The fstab file is read up to down while mounting, and down to up when umounting. In another case, if you try to umount /home before /home/mythtv mount will tell you the /home resource is busy because you have the /home/mythtv mounted and it cannot handle it.






          share|improve this answer





















          • 2





            @PerlDuck This is also important for /etc/fstab, line order matters.

            – mook765
            Jan 4 at 11:37






          • 1





            Yes Absolutely, @mook765 say the true, fstab file when mount is read up to down, and when umount down to up, in other case if you try to umount /home before /home/mythtv mount will say to you the /home resource is busy, because have the /home/mythtv mounted and cannot handle it.

            – AtomiX84
            Jan 4 at 11:47













          • In which cases would /etc/fstab be used for unmounting? The only thing I could think of is umount -a, but that command looks at what's actually mounted, not /etc/fstab.

            – kasperd
            Jan 4 at 16:02











          • by reading here seems it also used by umount: man7.org/linux/man-pages/man5/fstab.5.html, anyway after thinking a while on this (if you can confirm to me) the umount go to read the fstab when you invoke: umount /mount/point. But I repeat, may I misunderstanding the process of umount, the mount I'm sure is gonna to work like I had describe.

            – AtomiX84
            Jan 4 at 18:44











          • Up to down? You mean bottom up or top down???

            – FreeSoftwareServers
            Jan 4 at 21:23














          11












          11








          11







          Yes, it matters! Your first example:



          mount /dev/sdb1 /home
          mount /dev/sdb2 /home/mythtv


          is the only right way, when mounting you must respect the tree order.



          In your second example,



          mount /dev/sdb2 /home/mythtv
          mount /dev/sdb1 /home


          If we are assuming /home/mythtv exists on the filesystem, it is gonna mount it with no problem, but after you mount the second volume you won't be able to access the first one anymore.



          This is because you let the system mount sdb2 on an existing path at /home/mythtv. When you mount on /home/, you are telling your system to mount it on the /home path which also exists but is going to "cover" existing mount point. They are both mounted, but when you type cd /home/mythtv, Bash takes you to sdb1:/home/mythtv instead sdb2:/home/mythtv because they are different paths.



          I hope the explanation is clear. If not, please ask in the comments, I'll try to get it to you more clearly.



          Update



          as per @mook765's comment, the order is important also in the fstab files:



          The fstab file is read up to down while mounting, and down to up when umounting. In another case, if you try to umount /home before /home/mythtv mount will tell you the /home resource is busy because you have the /home/mythtv mounted and it cannot handle it.






          share|improve this answer















          Yes, it matters! Your first example:



          mount /dev/sdb1 /home
          mount /dev/sdb2 /home/mythtv


          is the only right way, when mounting you must respect the tree order.



          In your second example,



          mount /dev/sdb2 /home/mythtv
          mount /dev/sdb1 /home


          If we are assuming /home/mythtv exists on the filesystem, it is gonna mount it with no problem, but after you mount the second volume you won't be able to access the first one anymore.



          This is because you let the system mount sdb2 on an existing path at /home/mythtv. When you mount on /home/, you are telling your system to mount it on the /home path which also exists but is going to "cover" existing mount point. They are both mounted, but when you type cd /home/mythtv, Bash takes you to sdb1:/home/mythtv instead sdb2:/home/mythtv because they are different paths.



          I hope the explanation is clear. If not, please ask in the comments, I'll try to get it to you more clearly.



          Update



          as per @mook765's comment, the order is important also in the fstab files:



          The fstab file is read up to down while mounting, and down to up when umounting. In another case, if you try to umount /home before /home/mythtv mount will tell you the /home resource is busy because you have the /home/mythtv mounted and it cannot handle it.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jan 4 at 13:41









          Dan

          6,98934473




          6,98934473










          answered Jan 4 at 11:18









          AtomiX84AtomiX84

          65819




          65819








          • 2





            @PerlDuck This is also important for /etc/fstab, line order matters.

            – mook765
            Jan 4 at 11:37






          • 1





            Yes Absolutely, @mook765 say the true, fstab file when mount is read up to down, and when umount down to up, in other case if you try to umount /home before /home/mythtv mount will say to you the /home resource is busy, because have the /home/mythtv mounted and cannot handle it.

            – AtomiX84
            Jan 4 at 11:47













          • In which cases would /etc/fstab be used for unmounting? The only thing I could think of is umount -a, but that command looks at what's actually mounted, not /etc/fstab.

            – kasperd
            Jan 4 at 16:02











          • by reading here seems it also used by umount: man7.org/linux/man-pages/man5/fstab.5.html, anyway after thinking a while on this (if you can confirm to me) the umount go to read the fstab when you invoke: umount /mount/point. But I repeat, may I misunderstanding the process of umount, the mount I'm sure is gonna to work like I had describe.

            – AtomiX84
            Jan 4 at 18:44











          • Up to down? You mean bottom up or top down???

            – FreeSoftwareServers
            Jan 4 at 21:23














          • 2





            @PerlDuck This is also important for /etc/fstab, line order matters.

            – mook765
            Jan 4 at 11:37






          • 1





            Yes Absolutely, @mook765 say the true, fstab file when mount is read up to down, and when umount down to up, in other case if you try to umount /home before /home/mythtv mount will say to you the /home resource is busy, because have the /home/mythtv mounted and cannot handle it.

            – AtomiX84
            Jan 4 at 11:47













          • In which cases would /etc/fstab be used for unmounting? The only thing I could think of is umount -a, but that command looks at what's actually mounted, not /etc/fstab.

            – kasperd
            Jan 4 at 16:02











          • by reading here seems it also used by umount: man7.org/linux/man-pages/man5/fstab.5.html, anyway after thinking a while on this (if you can confirm to me) the umount go to read the fstab when you invoke: umount /mount/point. But I repeat, may I misunderstanding the process of umount, the mount I'm sure is gonna to work like I had describe.

            – AtomiX84
            Jan 4 at 18:44











          • Up to down? You mean bottom up or top down???

            – FreeSoftwareServers
            Jan 4 at 21:23








          2




          2





          @PerlDuck This is also important for /etc/fstab, line order matters.

          – mook765
          Jan 4 at 11:37





          @PerlDuck This is also important for /etc/fstab, line order matters.

          – mook765
          Jan 4 at 11:37




          1




          1





          Yes Absolutely, @mook765 say the true, fstab file when mount is read up to down, and when umount down to up, in other case if you try to umount /home before /home/mythtv mount will say to you the /home resource is busy, because have the /home/mythtv mounted and cannot handle it.

          – AtomiX84
          Jan 4 at 11:47







          Yes Absolutely, @mook765 say the true, fstab file when mount is read up to down, and when umount down to up, in other case if you try to umount /home before /home/mythtv mount will say to you the /home resource is busy, because have the /home/mythtv mounted and cannot handle it.

          – AtomiX84
          Jan 4 at 11:47















          In which cases would /etc/fstab be used for unmounting? The only thing I could think of is umount -a, but that command looks at what's actually mounted, not /etc/fstab.

          – kasperd
          Jan 4 at 16:02





          In which cases would /etc/fstab be used for unmounting? The only thing I could think of is umount -a, but that command looks at what's actually mounted, not /etc/fstab.

          – kasperd
          Jan 4 at 16:02













          by reading here seems it also used by umount: man7.org/linux/man-pages/man5/fstab.5.html, anyway after thinking a while on this (if you can confirm to me) the umount go to read the fstab when you invoke: umount /mount/point. But I repeat, may I misunderstanding the process of umount, the mount I'm sure is gonna to work like I had describe.

          – AtomiX84
          Jan 4 at 18:44





          by reading here seems it also used by umount: man7.org/linux/man-pages/man5/fstab.5.html, anyway after thinking a while on this (if you can confirm to me) the umount go to read the fstab when you invoke: umount /mount/point. But I repeat, may I misunderstanding the process of umount, the mount I'm sure is gonna to work like I had describe.

          – AtomiX84
          Jan 4 at 18:44













          Up to down? You mean bottom up or top down???

          – FreeSoftwareServers
          Jan 4 at 21:23





          Up to down? You mean bottom up or top down???

          – FreeSoftwareServers
          Jan 4 at 21:23


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • 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%2faskubuntu.com%2fquestions%2f1106879%2fdoes-order-of-mount-operations-matter-when-mounting-into-an-existing-mountpoint%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

          Aardman Animations

          Are they similar matrix

          “minimization” problem in Euclidean space related to orthonormal basis