Can automatically mounted camera be automatically unmounted by script in 14.04 Announcing the...

What kind of equipment or other technology is necessary to photograph sprites (atmospheric phenomenon)

Raising a bilingual kid. When should we introduce the majority language?

Has a Nobel Peace laureate ever been accused of war crimes?

Weaponising the Grasp-at-a-Distance spell

What helicopter has the most rotor blades?

How is an IPA symbol that lacks a name (e.g. ɲ) called?

Why aren't these two solutions equivalent? Combinatorics problem

Pointing to problems without suggesting solutions

Why does BitLocker not use RSA?

Can gravitational waves pass through a black hole?

Why doesn't the university give past final exams' answers?

Why does my GNOME settings mention "Moto C Plus"?

What *exactly* is electrical current, voltage, and resistance?

Can I ask an author to send me his ebook?

Should man-made satellites feature an intelligent inverted "cow catcher"?

Does using the Inspiration rules for character defects encourage My Guy Syndrome?

Etymology of 見舞い

Why did Israel vote against lifting the American embargo on Cuba?

A journey... into the MIND

"Destructive force" carried by a B-52?

Coin Game with infinite paradox

Can this water damage be explained by lack of gutters and grading issues?

Im stuck and having trouble with ¬P ∨ Q Prove: P → Q

Trying to enter the Fox's den



Can automatically mounted camera be automatically unmounted by script in 14.04



Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)Prevent a specific USB device from auto-mountingHow can I remove unmounted SD Card icons from my desktop?where camera are mounted?can I use sonycybershot digital camera for videochattingHow can i open my front camera in 12.10?14.04 doesn't mount digital cameraMounting a camera as mass storage automaticallyHow can I mount a Samsung Camera on Ubuntu?How can I prevent my external hard drive from automatically poweríng on right after I unmounted it?How can I use my laptop's video camera on Ubuntu?How can I get rid of the yellow tint in the image from my Macbook's camera





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







3















The version of Ubuntu I have (14.04.1) automatically mounts my digital camera and generates a box inviting me to say what to do with it. Since I was dissatisfied with all the options presented, I wrote a script which does exactly what I want, using gphoto2 to access the camera and get files from it. The one problem is that, even if I have specified 'do nothing' to the box, the camera remains mounted and thus, as far as gphoto2 is concerned, unavailable because not released. In order to release it I must open or find a folder display, and specifically eject the camera. I would rather not bother with this step and just let my script run. I am wondering if there is a way to do this.










share|improve this question























  • It's possible using udev rules: askubuntu.com/questions/301122/…

    – Flint
    Dec 6 '14 at 6:23


















3















The version of Ubuntu I have (14.04.1) automatically mounts my digital camera and generates a box inviting me to say what to do with it. Since I was dissatisfied with all the options presented, I wrote a script which does exactly what I want, using gphoto2 to access the camera and get files from it. The one problem is that, even if I have specified 'do nothing' to the box, the camera remains mounted and thus, as far as gphoto2 is concerned, unavailable because not released. In order to release it I must open or find a folder display, and specifically eject the camera. I would rather not bother with this step and just let my script run. I am wondering if there is a way to do this.










share|improve this question























  • It's possible using udev rules: askubuntu.com/questions/301122/…

    – Flint
    Dec 6 '14 at 6:23














3












3








3








The version of Ubuntu I have (14.04.1) automatically mounts my digital camera and generates a box inviting me to say what to do with it. Since I was dissatisfied with all the options presented, I wrote a script which does exactly what I want, using gphoto2 to access the camera and get files from it. The one problem is that, even if I have specified 'do nothing' to the box, the camera remains mounted and thus, as far as gphoto2 is concerned, unavailable because not released. In order to release it I must open or find a folder display, and specifically eject the camera. I would rather not bother with this step and just let my script run. I am wondering if there is a way to do this.










share|improve this question














The version of Ubuntu I have (14.04.1) automatically mounts my digital camera and generates a box inviting me to say what to do with it. Since I was dissatisfied with all the options presented, I wrote a script which does exactly what I want, using gphoto2 to access the camera and get files from it. The one problem is that, even if I have specified 'do nothing' to the box, the camera remains mounted and thus, as far as gphoto2 is concerned, unavailable because not released. In order to release it I must open or find a folder display, and specifically eject the camera. I would rather not bother with this step and just let my script run. I am wondering if there is a way to do this.







camera unmount






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 6 '14 at 5:56









StarrygordonStarrygordon

163




163













  • It's possible using udev rules: askubuntu.com/questions/301122/…

    – Flint
    Dec 6 '14 at 6:23



















  • It's possible using udev rules: askubuntu.com/questions/301122/…

    – Flint
    Dec 6 '14 at 6:23

















It's possible using udev rules: askubuntu.com/questions/301122/…

– Flint
Dec 6 '14 at 6:23





It's possible using udev rules: askubuntu.com/questions/301122/…

– Flint
Dec 6 '14 at 6:23










2 Answers
2






active

oldest

votes


















0














If you do not want to fiddle with udev (which is a system thing), you can use the udisk interface to unmount the camera.



The camera will normally mount at a fixed place, like /media/user/1234-5678/ or similar (YMMV, depends on how the camera formats the card); and as a device, say /dev/sdc1/.



Now, you can unmount it from your script using



 udisksctl unmount -b /dev/sdc1


the problem is that the device can change; my solution is having this little magic



 udisksctl unmount -b $(mount | grep 1234-5678  | cut -d" "  -f1)


which will work provided that the card id doesn't change.






share|improve this answer



















  • 1





    The camera (a Nikon Coolpix p90) is being connected via PTP. As a result it does not appear mounted on anything in /media, nor does it appear in mtab. This is a feature introduced with 14.04, I believe. In earlier versions of 14.04, many digital cameras could not be connected. The present arrangement seems to be patch. In order to 'release' the camera from gphoto2's point of view, I have to ask for a folder to be opened (that is, directory contents displayed in a window) and then 'eject' it. There is no obvious command-line way to do this.

    – Starrygordon
    Dec 7 '14 at 3:58



















0














For Ubuntu 17.10, 18.04, and up, you'll need to use the utility gio (which replaced gvfs-mount).



gio mount -l


will show you the mountable drives.



If you have a camera plugged in, it might look like this:



$ gio mount -l
Drive(0): DA4032
Type: GProxyDrive (GProxyVolumeMonitorUDisks2)
Volume(0): Canon Digital Camera
Type: GProxyVolume (GProxyVolumeMonitorGPhoto2)
Mount(0): Canon Digital Camera -> gphoto2://%5Busb%3A002,002%5D/
Type: GProxyShadowMount (GProxyVolumeMonitorGPhoto2)
Mount(1): Canon Digital Camera -> gphoto2://%5Busb%3A002,002%5D/
Type: GDaemonMount


copying the location after the -> will allow you to unmount it via gio mount -u (unmount, if you look at the help: gio help mount



gio mount -u gphoto2://%5Busb%3A002,002%5D/


will unmount the camera via shell. Now, to automate this, you'll need to create a systemd script.






share|improve this answer
























    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%2f557231%2fcan-automatically-mounted-camera-be-automatically-unmounted-by-script-in-14-04%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    If you do not want to fiddle with udev (which is a system thing), you can use the udisk interface to unmount the camera.



    The camera will normally mount at a fixed place, like /media/user/1234-5678/ or similar (YMMV, depends on how the camera formats the card); and as a device, say /dev/sdc1/.



    Now, you can unmount it from your script using



     udisksctl unmount -b /dev/sdc1


    the problem is that the device can change; my solution is having this little magic



     udisksctl unmount -b $(mount | grep 1234-5678  | cut -d" "  -f1)


    which will work provided that the card id doesn't change.






    share|improve this answer



















    • 1





      The camera (a Nikon Coolpix p90) is being connected via PTP. As a result it does not appear mounted on anything in /media, nor does it appear in mtab. This is a feature introduced with 14.04, I believe. In earlier versions of 14.04, many digital cameras could not be connected. The present arrangement seems to be patch. In order to 'release' the camera from gphoto2's point of view, I have to ask for a folder to be opened (that is, directory contents displayed in a window) and then 'eject' it. There is no obvious command-line way to do this.

      – Starrygordon
      Dec 7 '14 at 3:58
















    0














    If you do not want to fiddle with udev (which is a system thing), you can use the udisk interface to unmount the camera.



    The camera will normally mount at a fixed place, like /media/user/1234-5678/ or similar (YMMV, depends on how the camera formats the card); and as a device, say /dev/sdc1/.



    Now, you can unmount it from your script using



     udisksctl unmount -b /dev/sdc1


    the problem is that the device can change; my solution is having this little magic



     udisksctl unmount -b $(mount | grep 1234-5678  | cut -d" "  -f1)


    which will work provided that the card id doesn't change.






    share|improve this answer



















    • 1





      The camera (a Nikon Coolpix p90) is being connected via PTP. As a result it does not appear mounted on anything in /media, nor does it appear in mtab. This is a feature introduced with 14.04, I believe. In earlier versions of 14.04, many digital cameras could not be connected. The present arrangement seems to be patch. In order to 'release' the camera from gphoto2's point of view, I have to ask for a folder to be opened (that is, directory contents displayed in a window) and then 'eject' it. There is no obvious command-line way to do this.

      – Starrygordon
      Dec 7 '14 at 3:58














    0












    0








    0







    If you do not want to fiddle with udev (which is a system thing), you can use the udisk interface to unmount the camera.



    The camera will normally mount at a fixed place, like /media/user/1234-5678/ or similar (YMMV, depends on how the camera formats the card); and as a device, say /dev/sdc1/.



    Now, you can unmount it from your script using



     udisksctl unmount -b /dev/sdc1


    the problem is that the device can change; my solution is having this little magic



     udisksctl unmount -b $(mount | grep 1234-5678  | cut -d" "  -f1)


    which will work provided that the card id doesn't change.






    share|improve this answer













    If you do not want to fiddle with udev (which is a system thing), you can use the udisk interface to unmount the camera.



    The camera will normally mount at a fixed place, like /media/user/1234-5678/ or similar (YMMV, depends on how the camera formats the card); and as a device, say /dev/sdc1/.



    Now, you can unmount it from your script using



     udisksctl unmount -b /dev/sdc1


    the problem is that the device can change; my solution is having this little magic



     udisksctl unmount -b $(mount | grep 1234-5678  | cut -d" "  -f1)


    which will work provided that the card id doesn't change.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Dec 6 '14 at 9:36









    RmanoRmano

    25.6k881148




    25.6k881148








    • 1





      The camera (a Nikon Coolpix p90) is being connected via PTP. As a result it does not appear mounted on anything in /media, nor does it appear in mtab. This is a feature introduced with 14.04, I believe. In earlier versions of 14.04, many digital cameras could not be connected. The present arrangement seems to be patch. In order to 'release' the camera from gphoto2's point of view, I have to ask for a folder to be opened (that is, directory contents displayed in a window) and then 'eject' it. There is no obvious command-line way to do this.

      – Starrygordon
      Dec 7 '14 at 3:58














    • 1





      The camera (a Nikon Coolpix p90) is being connected via PTP. As a result it does not appear mounted on anything in /media, nor does it appear in mtab. This is a feature introduced with 14.04, I believe. In earlier versions of 14.04, many digital cameras could not be connected. The present arrangement seems to be patch. In order to 'release' the camera from gphoto2's point of view, I have to ask for a folder to be opened (that is, directory contents displayed in a window) and then 'eject' it. There is no obvious command-line way to do this.

      – Starrygordon
      Dec 7 '14 at 3:58








    1




    1





    The camera (a Nikon Coolpix p90) is being connected via PTP. As a result it does not appear mounted on anything in /media, nor does it appear in mtab. This is a feature introduced with 14.04, I believe. In earlier versions of 14.04, many digital cameras could not be connected. The present arrangement seems to be patch. In order to 'release' the camera from gphoto2's point of view, I have to ask for a folder to be opened (that is, directory contents displayed in a window) and then 'eject' it. There is no obvious command-line way to do this.

    – Starrygordon
    Dec 7 '14 at 3:58





    The camera (a Nikon Coolpix p90) is being connected via PTP. As a result it does not appear mounted on anything in /media, nor does it appear in mtab. This is a feature introduced with 14.04, I believe. In earlier versions of 14.04, many digital cameras could not be connected. The present arrangement seems to be patch. In order to 'release' the camera from gphoto2's point of view, I have to ask for a folder to be opened (that is, directory contents displayed in a window) and then 'eject' it. There is no obvious command-line way to do this.

    – Starrygordon
    Dec 7 '14 at 3:58













    0














    For Ubuntu 17.10, 18.04, and up, you'll need to use the utility gio (which replaced gvfs-mount).



    gio mount -l


    will show you the mountable drives.



    If you have a camera plugged in, it might look like this:



    $ gio mount -l
    Drive(0): DA4032
    Type: GProxyDrive (GProxyVolumeMonitorUDisks2)
    Volume(0): Canon Digital Camera
    Type: GProxyVolume (GProxyVolumeMonitorGPhoto2)
    Mount(0): Canon Digital Camera -> gphoto2://%5Busb%3A002,002%5D/
    Type: GProxyShadowMount (GProxyVolumeMonitorGPhoto2)
    Mount(1): Canon Digital Camera -> gphoto2://%5Busb%3A002,002%5D/
    Type: GDaemonMount


    copying the location after the -> will allow you to unmount it via gio mount -u (unmount, if you look at the help: gio help mount



    gio mount -u gphoto2://%5Busb%3A002,002%5D/


    will unmount the camera via shell. Now, to automate this, you'll need to create a systemd script.






    share|improve this answer




























      0














      For Ubuntu 17.10, 18.04, and up, you'll need to use the utility gio (which replaced gvfs-mount).



      gio mount -l


      will show you the mountable drives.



      If you have a camera plugged in, it might look like this:



      $ gio mount -l
      Drive(0): DA4032
      Type: GProxyDrive (GProxyVolumeMonitorUDisks2)
      Volume(0): Canon Digital Camera
      Type: GProxyVolume (GProxyVolumeMonitorGPhoto2)
      Mount(0): Canon Digital Camera -> gphoto2://%5Busb%3A002,002%5D/
      Type: GProxyShadowMount (GProxyVolumeMonitorGPhoto2)
      Mount(1): Canon Digital Camera -> gphoto2://%5Busb%3A002,002%5D/
      Type: GDaemonMount


      copying the location after the -> will allow you to unmount it via gio mount -u (unmount, if you look at the help: gio help mount



      gio mount -u gphoto2://%5Busb%3A002,002%5D/


      will unmount the camera via shell. Now, to automate this, you'll need to create a systemd script.






      share|improve this answer


























        0












        0








        0







        For Ubuntu 17.10, 18.04, and up, you'll need to use the utility gio (which replaced gvfs-mount).



        gio mount -l


        will show you the mountable drives.



        If you have a camera plugged in, it might look like this:



        $ gio mount -l
        Drive(0): DA4032
        Type: GProxyDrive (GProxyVolumeMonitorUDisks2)
        Volume(0): Canon Digital Camera
        Type: GProxyVolume (GProxyVolumeMonitorGPhoto2)
        Mount(0): Canon Digital Camera -> gphoto2://%5Busb%3A002,002%5D/
        Type: GProxyShadowMount (GProxyVolumeMonitorGPhoto2)
        Mount(1): Canon Digital Camera -> gphoto2://%5Busb%3A002,002%5D/
        Type: GDaemonMount


        copying the location after the -> will allow you to unmount it via gio mount -u (unmount, if you look at the help: gio help mount



        gio mount -u gphoto2://%5Busb%3A002,002%5D/


        will unmount the camera via shell. Now, to automate this, you'll need to create a systemd script.






        share|improve this answer













        For Ubuntu 17.10, 18.04, and up, you'll need to use the utility gio (which replaced gvfs-mount).



        gio mount -l


        will show you the mountable drives.



        If you have a camera plugged in, it might look like this:



        $ gio mount -l
        Drive(0): DA4032
        Type: GProxyDrive (GProxyVolumeMonitorUDisks2)
        Volume(0): Canon Digital Camera
        Type: GProxyVolume (GProxyVolumeMonitorGPhoto2)
        Mount(0): Canon Digital Camera -> gphoto2://%5Busb%3A002,002%5D/
        Type: GProxyShadowMount (GProxyVolumeMonitorGPhoto2)
        Mount(1): Canon Digital Camera -> gphoto2://%5Busb%3A002,002%5D/
        Type: GDaemonMount


        copying the location after the -> will allow you to unmount it via gio mount -u (unmount, if you look at the help: gio help mount



        gio mount -u gphoto2://%5Busb%3A002,002%5D/


        will unmount the camera via shell. Now, to automate this, you'll need to create a systemd script.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 7 hours ago









        jimbotronjimbotron

        313




        313






























            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%2f557231%2fcan-automatically-mounted-camera-be-automatically-unmounted-by-script-in-14-04%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

            Why do type traits not work with types in namespace scope?What are POD types in C++?Why can templates only be...

            Will tsunami waves travel forever if there was no land?Why do tsunami waves begin with the water flowing away...

            Simple Scan not detecting my scanner (Brother DCP-7055W)Brother MFC-L2700DW printer can print, can't...