How to mount a drive without creating a directory?

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











up vote
-1
down vote

favorite












When you plug a flashdrive into Ubuntu, it creates a directory in /media/<username> with the flash drive name as the mount point name. When you unmount this directory, the directory cleanly goes away.



When you do mount <x> on the command line you always require a mount point which must be an existing dir. How do you do it without creating the folder? There must be a way.







share|improve this question
















  • 1




    I suppose "use an existing directory" is not a very satisfying answer? You do need to have some directory to mount to.
    – ilkkachu
    Dec 6 '17 at 8:15






  • 1




    Oh, why must it be possible to mount without a mount point?
    – fpmurphy1
    Dec 6 '17 at 8:20














up vote
-1
down vote

favorite












When you plug a flashdrive into Ubuntu, it creates a directory in /media/<username> with the flash drive name as the mount point name. When you unmount this directory, the directory cleanly goes away.



When you do mount <x> on the command line you always require a mount point which must be an existing dir. How do you do it without creating the folder? There must be a way.







share|improve this question
















  • 1




    I suppose "use an existing directory" is not a very satisfying answer? You do need to have some directory to mount to.
    – ilkkachu
    Dec 6 '17 at 8:15






  • 1




    Oh, why must it be possible to mount without a mount point?
    – fpmurphy1
    Dec 6 '17 at 8:20












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











When you plug a flashdrive into Ubuntu, it creates a directory in /media/<username> with the flash drive name as the mount point name. When you unmount this directory, the directory cleanly goes away.



When you do mount <x> on the command line you always require a mount point which must be an existing dir. How do you do it without creating the folder? There must be a way.







share|improve this question












When you plug a flashdrive into Ubuntu, it creates a directory in /media/<username> with the flash drive name as the mount point name. When you unmount this directory, the directory cleanly goes away.



When you do mount <x> on the command line you always require a mount point which must be an existing dir. How do you do it without creating the folder? There must be a way.









share|improve this question











share|improve this question




share|improve this question










asked Dec 6 '17 at 7:39









James Dean

104




104







  • 1




    I suppose "use an existing directory" is not a very satisfying answer? You do need to have some directory to mount to.
    – ilkkachu
    Dec 6 '17 at 8:15






  • 1




    Oh, why must it be possible to mount without a mount point?
    – fpmurphy1
    Dec 6 '17 at 8:20












  • 1




    I suppose "use an existing directory" is not a very satisfying answer? You do need to have some directory to mount to.
    – ilkkachu
    Dec 6 '17 at 8:15






  • 1




    Oh, why must it be possible to mount without a mount point?
    – fpmurphy1
    Dec 6 '17 at 8:20







1




1




I suppose "use an existing directory" is not a very satisfying answer? You do need to have some directory to mount to.
– ilkkachu
Dec 6 '17 at 8:15




I suppose "use an existing directory" is not a very satisfying answer? You do need to have some directory to mount to.
– ilkkachu
Dec 6 '17 at 8:15




1




1




Oh, why must it be possible to mount without a mount point?
– fpmurphy1
Dec 6 '17 at 8:20




Oh, why must it be possible to mount without a mount point?
– fpmurphy1
Dec 6 '17 at 8:20










6 Answers
6






active

oldest

votes

















up vote
2
down vote













You always need a directory to use a mount point on a Unix-like system. There is software, e.g. automount and udev, that will automatically create the directory for you , but a directory must exist for the mount to actually occur.






share|improve this answer



























    up vote
    1
    down vote













    Mounting a device means making its filesystem available through a specific directory (mountpoint) attached to the tree rooted at /.



    Therefore, you always need an already existing directory to use as a mountpoint. Without it, you would not be able to access the mounted device.



    Note that the directory used as mountpoint doesn't need to be empty; however, its old contents would be made inaccessible after the mount. For this reason, and to avoid confusion, usually devices are mounted on empty directories.



    @Kusalananda's answer provides a function that makes the creation of the mountpoint automatic and transparent to the user, but under the hood the directory must always exist.






    share|improve this answer



























      up vote
      1
      down vote













      No , it is not possible to mount a device without creating a mount point, " the mount command require a mount point" :



      mount -t type device dir



      This tells the kernel to attach the filesystem found on device (which is of type type) at the directory dir




      man mount






      share|improve this answer



























        up vote
        0
        down vote














        There must be a way.




        No, there is no way.




        How do you do it without creating the folder?




        There has to be some directory given to mount as a mount point.




        Maybe you asked bad. But I personally don't see any logic in your question.






        share|improve this answer



























          up vote
          0
          down vote













          mymount () 


          On most Unices, with most file systems, the mount utility requires that the mountpoint be an existing directory.



          With the bash shell function above, this directory is created if it does not already exist. The mountpoint is assumed to be the last argument on the command line when invoking the function. This allows you to mount a device anywhere without manually creating the mountpoint.



          This is probably somewhat like whatever it is that creates the /media/username mountpoint on your system does.



          Likewise, you could define myumount that unmounted a device and removed its mountpoint.



          This obviously does not get around the fact that the directory can't be created by mount (or deleted by umount), at least not by the mount implementations that I know about, but it allows you to hide the creation of the directory in a function.




          Unix philosophy: Do one thing and do it well.



          mount requires a directory to mount something at. Creating this directory is the task for mkdir.






          share|improve this answer


















          • 4




            Your answer does not meet the OPs requirement, i.e. without creating a directory
            – fpmurphy1
            Dec 6 '17 at 8:23










          • @fpmurphy1 Can't be done in the general case, which is what I wrote. I then created a function that encapsulates the creation of the directory, so that it doesn't need to be created manually.
            – Kusalananda
            Dec 6 '17 at 8:31

















          up vote
          0
          down vote













          You left unclear what you want to achieve and why you can't create a mountpoint dir, making this is a typical XY question.



          If your main issue is to temporarily mount a drive without having to create and clean up the mountpoint, then you may use /mnt which is designated to this purpose by the Filesystem Hierarchy Standard. It is discouraged to use /mnt for long-term/permanent mounting.






          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%2f409120%2fhow-to-mount-a-drive-without-creating-a-directory%23new-answer', 'question_page');

            );

            Post as a guest






























            6 Answers
            6






            active

            oldest

            votes








            6 Answers
            6






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            2
            down vote













            You always need a directory to use a mount point on a Unix-like system. There is software, e.g. automount and udev, that will automatically create the directory for you , but a directory must exist for the mount to actually occur.






            share|improve this answer
























              up vote
              2
              down vote













              You always need a directory to use a mount point on a Unix-like system. There is software, e.g. automount and udev, that will automatically create the directory for you , but a directory must exist for the mount to actually occur.






              share|improve this answer






















                up vote
                2
                down vote










                up vote
                2
                down vote









                You always need a directory to use a mount point on a Unix-like system. There is software, e.g. automount and udev, that will automatically create the directory for you , but a directory must exist for the mount to actually occur.






                share|improve this answer












                You always need a directory to use a mount point on a Unix-like system. There is software, e.g. automount and udev, that will automatically create the directory for you , but a directory must exist for the mount to actually occur.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 6 '17 at 8:48









                fpmurphy1

                2,231915




                2,231915






















                    up vote
                    1
                    down vote













                    Mounting a device means making its filesystem available through a specific directory (mountpoint) attached to the tree rooted at /.



                    Therefore, you always need an already existing directory to use as a mountpoint. Without it, you would not be able to access the mounted device.



                    Note that the directory used as mountpoint doesn't need to be empty; however, its old contents would be made inaccessible after the mount. For this reason, and to avoid confusion, usually devices are mounted on empty directories.



                    @Kusalananda's answer provides a function that makes the creation of the mountpoint automatic and transparent to the user, but under the hood the directory must always exist.






                    share|improve this answer
























                      up vote
                      1
                      down vote













                      Mounting a device means making its filesystem available through a specific directory (mountpoint) attached to the tree rooted at /.



                      Therefore, you always need an already existing directory to use as a mountpoint. Without it, you would not be able to access the mounted device.



                      Note that the directory used as mountpoint doesn't need to be empty; however, its old contents would be made inaccessible after the mount. For this reason, and to avoid confusion, usually devices are mounted on empty directories.



                      @Kusalananda's answer provides a function that makes the creation of the mountpoint automatic and transparent to the user, but under the hood the directory must always exist.






                      share|improve this answer






















                        up vote
                        1
                        down vote










                        up vote
                        1
                        down vote









                        Mounting a device means making its filesystem available through a specific directory (mountpoint) attached to the tree rooted at /.



                        Therefore, you always need an already existing directory to use as a mountpoint. Without it, you would not be able to access the mounted device.



                        Note that the directory used as mountpoint doesn't need to be empty; however, its old contents would be made inaccessible after the mount. For this reason, and to avoid confusion, usually devices are mounted on empty directories.



                        @Kusalananda's answer provides a function that makes the creation of the mountpoint automatic and transparent to the user, but under the hood the directory must always exist.






                        share|improve this answer












                        Mounting a device means making its filesystem available through a specific directory (mountpoint) attached to the tree rooted at /.



                        Therefore, you always need an already existing directory to use as a mountpoint. Without it, you would not be able to access the mounted device.



                        Note that the directory used as mountpoint doesn't need to be empty; however, its old contents would be made inaccessible after the mount. For this reason, and to avoid confusion, usually devices are mounted on empty directories.



                        @Kusalananda's answer provides a function that makes the creation of the mountpoint automatic and transparent to the user, but under the hood the directory must always exist.







                        share|improve this answer












                        share|improve this answer



                        share|improve this answer










                        answered Dec 6 '17 at 8:38









                        dr01

                        15.3k114769




                        15.3k114769




















                            up vote
                            1
                            down vote













                            No , it is not possible to mount a device without creating a mount point, " the mount command require a mount point" :



                            mount -t type device dir



                            This tells the kernel to attach the filesystem found on device (which is of type type) at the directory dir




                            man mount






                            share|improve this answer
























                              up vote
                              1
                              down vote













                              No , it is not possible to mount a device without creating a mount point, " the mount command require a mount point" :



                              mount -t type device dir



                              This tells the kernel to attach the filesystem found on device (which is of type type) at the directory dir




                              man mount






                              share|improve this answer






















                                up vote
                                1
                                down vote










                                up vote
                                1
                                down vote









                                No , it is not possible to mount a device without creating a mount point, " the mount command require a mount point" :



                                mount -t type device dir



                                This tells the kernel to attach the filesystem found on device (which is of type type) at the directory dir




                                man mount






                                share|improve this answer












                                No , it is not possible to mount a device without creating a mount point, " the mount command require a mount point" :



                                mount -t type device dir



                                This tells the kernel to attach the filesystem found on device (which is of type type) at the directory dir




                                man mount







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Dec 6 '17 at 8:53









                                GAD3R

                                22.6k154894




                                22.6k154894




















                                    up vote
                                    0
                                    down vote














                                    There must be a way.




                                    No, there is no way.




                                    How do you do it without creating the folder?




                                    There has to be some directory given to mount as a mount point.




                                    Maybe you asked bad. But I personally don't see any logic in your question.






                                    share|improve this answer
























                                      up vote
                                      0
                                      down vote














                                      There must be a way.




                                      No, there is no way.




                                      How do you do it without creating the folder?




                                      There has to be some directory given to mount as a mount point.




                                      Maybe you asked bad. But I personally don't see any logic in your question.






                                      share|improve this answer






















                                        up vote
                                        0
                                        down vote










                                        up vote
                                        0
                                        down vote










                                        There must be a way.




                                        No, there is no way.




                                        How do you do it without creating the folder?




                                        There has to be some directory given to mount as a mount point.




                                        Maybe you asked bad. But I personally don't see any logic in your question.






                                        share|improve this answer













                                        There must be a way.




                                        No, there is no way.




                                        How do you do it without creating the folder?




                                        There has to be some directory given to mount as a mount point.




                                        Maybe you asked bad. But I personally don't see any logic in your question.







                                        share|improve this answer












                                        share|improve this answer



                                        share|improve this answer










                                        answered Dec 6 '17 at 8:35









                                        Vlastimil

                                        6,4411147119




                                        6,4411147119




















                                            up vote
                                            0
                                            down vote













                                            mymount () 


                                            On most Unices, with most file systems, the mount utility requires that the mountpoint be an existing directory.



                                            With the bash shell function above, this directory is created if it does not already exist. The mountpoint is assumed to be the last argument on the command line when invoking the function. This allows you to mount a device anywhere without manually creating the mountpoint.



                                            This is probably somewhat like whatever it is that creates the /media/username mountpoint on your system does.



                                            Likewise, you could define myumount that unmounted a device and removed its mountpoint.



                                            This obviously does not get around the fact that the directory can't be created by mount (or deleted by umount), at least not by the mount implementations that I know about, but it allows you to hide the creation of the directory in a function.




                                            Unix philosophy: Do one thing and do it well.



                                            mount requires a directory to mount something at. Creating this directory is the task for mkdir.






                                            share|improve this answer


















                                            • 4




                                              Your answer does not meet the OPs requirement, i.e. without creating a directory
                                              – fpmurphy1
                                              Dec 6 '17 at 8:23










                                            • @fpmurphy1 Can't be done in the general case, which is what I wrote. I then created a function that encapsulates the creation of the directory, so that it doesn't need to be created manually.
                                              – Kusalananda
                                              Dec 6 '17 at 8:31














                                            up vote
                                            0
                                            down vote













                                            mymount () 


                                            On most Unices, with most file systems, the mount utility requires that the mountpoint be an existing directory.



                                            With the bash shell function above, this directory is created if it does not already exist. The mountpoint is assumed to be the last argument on the command line when invoking the function. This allows you to mount a device anywhere without manually creating the mountpoint.



                                            This is probably somewhat like whatever it is that creates the /media/username mountpoint on your system does.



                                            Likewise, you could define myumount that unmounted a device and removed its mountpoint.



                                            This obviously does not get around the fact that the directory can't be created by mount (or deleted by umount), at least not by the mount implementations that I know about, but it allows you to hide the creation of the directory in a function.




                                            Unix philosophy: Do one thing and do it well.



                                            mount requires a directory to mount something at. Creating this directory is the task for mkdir.






                                            share|improve this answer


















                                            • 4




                                              Your answer does not meet the OPs requirement, i.e. without creating a directory
                                              – fpmurphy1
                                              Dec 6 '17 at 8:23










                                            • @fpmurphy1 Can't be done in the general case, which is what I wrote. I then created a function that encapsulates the creation of the directory, so that it doesn't need to be created manually.
                                              – Kusalananda
                                              Dec 6 '17 at 8:31












                                            up vote
                                            0
                                            down vote










                                            up vote
                                            0
                                            down vote









                                            mymount () 


                                            On most Unices, with most file systems, the mount utility requires that the mountpoint be an existing directory.



                                            With the bash shell function above, this directory is created if it does not already exist. The mountpoint is assumed to be the last argument on the command line when invoking the function. This allows you to mount a device anywhere without manually creating the mountpoint.



                                            This is probably somewhat like whatever it is that creates the /media/username mountpoint on your system does.



                                            Likewise, you could define myumount that unmounted a device and removed its mountpoint.



                                            This obviously does not get around the fact that the directory can't be created by mount (or deleted by umount), at least not by the mount implementations that I know about, but it allows you to hide the creation of the directory in a function.




                                            Unix philosophy: Do one thing and do it well.



                                            mount requires a directory to mount something at. Creating this directory is the task for mkdir.






                                            share|improve this answer














                                            mymount () 


                                            On most Unices, with most file systems, the mount utility requires that the mountpoint be an existing directory.



                                            With the bash shell function above, this directory is created if it does not already exist. The mountpoint is assumed to be the last argument on the command line when invoking the function. This allows you to mount a device anywhere without manually creating the mountpoint.



                                            This is probably somewhat like whatever it is that creates the /media/username mountpoint on your system does.



                                            Likewise, you could define myumount that unmounted a device and removed its mountpoint.



                                            This obviously does not get around the fact that the directory can't be created by mount (or deleted by umount), at least not by the mount implementations that I know about, but it allows you to hide the creation of the directory in a function.




                                            Unix philosophy: Do one thing and do it well.



                                            mount requires a directory to mount something at. Creating this directory is the task for mkdir.







                                            share|improve this answer














                                            share|improve this answer



                                            share|improve this answer








                                            edited Dec 6 '17 at 9:51

























                                            answered Dec 6 '17 at 8:16









                                            Kusalananda

                                            104k14206324




                                            104k14206324







                                            • 4




                                              Your answer does not meet the OPs requirement, i.e. without creating a directory
                                              – fpmurphy1
                                              Dec 6 '17 at 8:23










                                            • @fpmurphy1 Can't be done in the general case, which is what I wrote. I then created a function that encapsulates the creation of the directory, so that it doesn't need to be created manually.
                                              – Kusalananda
                                              Dec 6 '17 at 8:31












                                            • 4




                                              Your answer does not meet the OPs requirement, i.e. without creating a directory
                                              – fpmurphy1
                                              Dec 6 '17 at 8:23










                                            • @fpmurphy1 Can't be done in the general case, which is what I wrote. I then created a function that encapsulates the creation of the directory, so that it doesn't need to be created manually.
                                              – Kusalananda
                                              Dec 6 '17 at 8:31







                                            4




                                            4




                                            Your answer does not meet the OPs requirement, i.e. without creating a directory
                                            – fpmurphy1
                                            Dec 6 '17 at 8:23




                                            Your answer does not meet the OPs requirement, i.e. without creating a directory
                                            – fpmurphy1
                                            Dec 6 '17 at 8:23












                                            @fpmurphy1 Can't be done in the general case, which is what I wrote. I then created a function that encapsulates the creation of the directory, so that it doesn't need to be created manually.
                                            – Kusalananda
                                            Dec 6 '17 at 8:31




                                            @fpmurphy1 Can't be done in the general case, which is what I wrote. I then created a function that encapsulates the creation of the directory, so that it doesn't need to be created manually.
                                            – Kusalananda
                                            Dec 6 '17 at 8:31










                                            up vote
                                            0
                                            down vote













                                            You left unclear what you want to achieve and why you can't create a mountpoint dir, making this is a typical XY question.



                                            If your main issue is to temporarily mount a drive without having to create and clean up the mountpoint, then you may use /mnt which is designated to this purpose by the Filesystem Hierarchy Standard. It is discouraged to use /mnt for long-term/permanent mounting.






                                            share|improve this answer
























                                              up vote
                                              0
                                              down vote













                                              You left unclear what you want to achieve and why you can't create a mountpoint dir, making this is a typical XY question.



                                              If your main issue is to temporarily mount a drive without having to create and clean up the mountpoint, then you may use /mnt which is designated to this purpose by the Filesystem Hierarchy Standard. It is discouraged to use /mnt for long-term/permanent mounting.






                                              share|improve this answer






















                                                up vote
                                                0
                                                down vote










                                                up vote
                                                0
                                                down vote









                                                You left unclear what you want to achieve and why you can't create a mountpoint dir, making this is a typical XY question.



                                                If your main issue is to temporarily mount a drive without having to create and clean up the mountpoint, then you may use /mnt which is designated to this purpose by the Filesystem Hierarchy Standard. It is discouraged to use /mnt for long-term/permanent mounting.






                                                share|improve this answer












                                                You left unclear what you want to achieve and why you can't create a mountpoint dir, making this is a typical XY question.



                                                If your main issue is to temporarily mount a drive without having to create and clean up the mountpoint, then you may use /mnt which is designated to this purpose by the Filesystem Hierarchy Standard. It is discouraged to use /mnt for long-term/permanent mounting.







                                                share|improve this answer












                                                share|improve this answer



                                                share|improve this answer










                                                answered Dec 6 '17 at 12:18









                                                Murphy

                                                1,7471517




                                                1,7471517



























                                                     

                                                    draft saved


                                                    draft discarded















































                                                     


                                                    draft saved


                                                    draft discarded














                                                    StackExchange.ready(
                                                    function ()
                                                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f409120%2fhow-to-mount-a-drive-without-creating-a-directory%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