How to auto-mount from command line?












22















How can I trigger an automount from the command line? By "automount" I don't mean fully automatic mounting, but getting a list of available devices and then selecting one and having it end up as /media/{user}/{diskid}. This functionality is provided by Nautilus or Thunar for example, but I can't seem to find a command line tool to trigger this kind of semi automatic mount.



pmount is the closest I have found, but seems to work by completely different mechanics underneath and makes devices show up as /media/sdf or something along the lines.










share|improve this question



























    22















    How can I trigger an automount from the command line? By "automount" I don't mean fully automatic mounting, but getting a list of available devices and then selecting one and having it end up as /media/{user}/{diskid}. This functionality is provided by Nautilus or Thunar for example, but I can't seem to find a command line tool to trigger this kind of semi automatic mount.



    pmount is the closest I have found, but seems to work by completely different mechanics underneath and makes devices show up as /media/sdf or something along the lines.










    share|improve this question

























      22












      22








      22


      12






      How can I trigger an automount from the command line? By "automount" I don't mean fully automatic mounting, but getting a list of available devices and then selecting one and having it end up as /media/{user}/{diskid}. This functionality is provided by Nautilus or Thunar for example, but I can't seem to find a command line tool to trigger this kind of semi automatic mount.



      pmount is the closest I have found, but seems to work by completely different mechanics underneath and makes devices show up as /media/sdf or something along the lines.










      share|improve this question














      How can I trigger an automount from the command line? By "automount" I don't mean fully automatic mounting, but getting a list of available devices and then selecting one and having it end up as /media/{user}/{diskid}. This functionality is provided by Nautilus or Thunar for example, but I can't seem to find a command line tool to trigger this kind of semi automatic mount.



      pmount is the closest I have found, but seems to work by completely different mechanics underneath and makes devices show up as /media/sdf or something along the lines.







      command-line mount






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 6 '13 at 13:44









      GrumbelGrumbel

      2,72432540




      2,72432540






















          5 Answers
          5






          active

          oldest

          votes


















          24














          You can use:



          udisks --mount device_name


          or



          udisksctl mount -b device_name


          where device_name is the name of a storage device and should look something like /dev/sdb1.



          Using sudo fdisk -l command you can find out all storage devices attached to your system.






          share|improve this answer





















          • 2





            Tried that, that however leads to /media/{disk}, different from what Thunar or Nautilus would give. The udisksctl command provided by udisks2 however seems to do what I want.

            – Grumbel
            Sep 6 '13 at 14:02






          • 1





            udisksctl status will give a proper list of devices and work as user. fdisk -l not only requires root, it will also fail with GPT drives. cat /proc/partitions would be a better low-level way to get an idea of partitions available.

            – Grumbel
            Sep 6 '13 at 14:43











          • udiskctl is extremely useful for mounting image disk files into loop devices without root privileges, too!

            – JBFWP286
            Aug 14 '17 at 22:05



















          14














          gvfs-mount



          Listing available devices can be done with:



          gvfs-mount --list


          Mounting them can be done with:



          gvfs-mount -d /dev/sdf


          Unmounting is possible via:



          gvfs-mount --unmount /media/user/01234567890


          One remaining problem is that I have no idea how to use the gvfs-mount --list output in a mount command, as --list won't show block device names and trying to use the device names it prints in a mount will result in:



          Error mounting location: volume doesn't implement mount


          udisksctl



          Listing available devices:



          udisksctl status


          Mounting is done via:



          udisksctl mount -b /dev/sdf


          or



          udisksctl mount -p block_devices/sdf


          Unmounting is done via:



          udisksctl unmount -b /dev/sdf


          or



          udisksctl unmount -p block_devices/sdf


          The object-path can be found out by doing:



          udisksctl dump


          Object of type org.freedesktop.UDisks2.Block seem to be valid as object-patch, the /org/freedesktop/UDisks2/ prefix has to be cut from the path for udisksctl to accept them.



          Conclusion



          While both gvfs-mount and udisksctl will work for the tasks, their interface is impractical as they don't provide human readable status of the disks available, just an overly verbose info dump.





          Update: gio mount replace gvfs-mount



          gvfs is now listed as deprecated (2018) and you are advised to use 'gio' which is Gnome In Out and part of Glib. See Wikipedia.



          For example, to auto-mount a second drive partition; create a bash script with executable permission to run at start-up with the following command:



          gio mount -d /dev/sda2


          If you are owner of the partition (see chown) you won't need sudo.






          share|improve this answer


























          • Could you extend your answer including how to mount an iso with gio mount? On 18.04 with Archive Mounter gio mount -l return Type: GDaemonMount but I couldn't mount it via CLI (maybe an issue?).

            – Pablo Bianchi
            7 hours ago



















          5














          A simple solution that works as required (mounts to /media/{user}/{diskid}) except that it can not list devices but needs to be given the exact, case sensitive, volume label as argument $1



          To mount:



          DEVICE=$(findfs LABEL=$1) && udisksctl mount -b $DEVICE


          To unmount:



          DEVICE=$(findfs LABEL=$1) && udisksctl unmount -b $DEVICE





          share|improve this answer


























          • Nice. Or, just : udisksctl mount -b $(findfs LABEL=<label>)

            – Brent Faust
            Mar 31 '18 at 19:06





















          1














          Just ran into the issue myself, and found the following solution:



          udisksctl mount -b /dev/disk/by-labels/$LABEL


          It will ask for the user password, even if it's you and you're already logged in.






          share|improve this answer































            0














            I wrote this Bash script to work around this problem, but be aware that I'm a scripting newbie. All suggestions welcome! Usage and description follow below the script.



            #!/bin/bash
            # umanage.sh
            # 2014-05-05

            BASEPATH="/media/$(whoami)/"
            RESULTS=$(udisksctl dump | grep IdLabel | grep -c -i "$1")

            case "$RESULTS" in

            0 ) echo "Nothing found."
            ;;

            1 ) DEVICELABEL=$(udisksctl dump | grep IdLabel | grep -i "$1" | cut -d ":" -f 2 | sed 's/^[ t]*//')
            DEVICE=$(udisksctl dump | grep -i "IdLabel: +$DEVICELABEL" -B 12 | grep " Device:" | cut -d ":" -f 2 | sed 's/^[ t]*//')
            DEVICEPATH="$BASEPATH""$DEVICELABEL"

            if [[ -z $(mount | grep "$DEVICE") ]]
            then
            echo "Found unmounted $DEVICE partition."
            echo "Do you want to mount it in $DEVICEPATH?"
            select yn in "Mount" "Ignore"
            do
            case $yn in
            Mount ) udisksctl mount -b "$DEVICE"
            break
            ;;
            Ignore ) exit
            ;;
            esac
            done
            else
            echo "Found $DEVICE partition, currently mounted in $DEVICEPATH."
            echo "Do you want to unmount it?"
            select yn in "Unmount" "Ignore"
            do
            case $yn in
            Unmount ) udisksctl unmount -b "$DEVICE"
            break
            ;;
            Ignore ) exit
            ;;
            esac
            done
            fi
            ;;

            * ) if [ $# -eq 0 ]
            then
            echo "No argument supplied"
            else
            echo "$RESULTS possible results. You may be looking for:"
            echo
            udisksctl dump | grep IdLabel | grep -i "$1" | cut -d ":" -f 2 | sed 's/^[ t]*//' | sed '/^$/d'
            echo
            echo "Please refine your search."
            fi
            ;;

            esac


            Usage:




            • save the script as umanage.sh

            • make it executable: chmod +x umanage.sh

            • run it: ./umanage.sh YourDeviceLabel


            The script accepts as an argument the label of the partition you want to mount and looks in the udisksctl dump for corresponding entries.



            If a partition is found and it's not mounted, device name and path are shown and you're offered to mount the partition. The script searches for partial labels too, and it won't care about upper or lower case (useful when you don't remember the exact label).



            ./umanage.sh PASSPORT
            Found unmounted /dev/sdf1 partition.
            Do you want to mount it in /media/pixel/My Passport?
            1) Mount
            2) Ignore
            #?


            If a partition is found and it's already mounted, you're offered to unmount it:



            ./umanage.sh passp
            Found /dev/sdf1 partition, currently mounted in /media/open/My Passport.
            Do you want to unmount it?
            1) Unmount
            2) Ignore
            #?


            If your argument matches more than a result, the script shows you the matching partition labels and asks you to refine the search:



            ./umanage.sh SS
            2 possible results. You may be looking for:

            SSD-9GB
            My Passport

            Please refine your search.





            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%2f342188%2fhow-to-auto-mount-from-command-line%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              5 Answers
              5






              active

              oldest

              votes








              5 Answers
              5






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              24














              You can use:



              udisks --mount device_name


              or



              udisksctl mount -b device_name


              where device_name is the name of a storage device and should look something like /dev/sdb1.



              Using sudo fdisk -l command you can find out all storage devices attached to your system.






              share|improve this answer





















              • 2





                Tried that, that however leads to /media/{disk}, different from what Thunar or Nautilus would give. The udisksctl command provided by udisks2 however seems to do what I want.

                – Grumbel
                Sep 6 '13 at 14:02






              • 1





                udisksctl status will give a proper list of devices and work as user. fdisk -l not only requires root, it will also fail with GPT drives. cat /proc/partitions would be a better low-level way to get an idea of partitions available.

                – Grumbel
                Sep 6 '13 at 14:43











              • udiskctl is extremely useful for mounting image disk files into loop devices without root privileges, too!

                – JBFWP286
                Aug 14 '17 at 22:05
















              24














              You can use:



              udisks --mount device_name


              or



              udisksctl mount -b device_name


              where device_name is the name of a storage device and should look something like /dev/sdb1.



              Using sudo fdisk -l command you can find out all storage devices attached to your system.






              share|improve this answer





















              • 2





                Tried that, that however leads to /media/{disk}, different from what Thunar or Nautilus would give. The udisksctl command provided by udisks2 however seems to do what I want.

                – Grumbel
                Sep 6 '13 at 14:02






              • 1





                udisksctl status will give a proper list of devices and work as user. fdisk -l not only requires root, it will also fail with GPT drives. cat /proc/partitions would be a better low-level way to get an idea of partitions available.

                – Grumbel
                Sep 6 '13 at 14:43











              • udiskctl is extremely useful for mounting image disk files into loop devices without root privileges, too!

                – JBFWP286
                Aug 14 '17 at 22:05














              24












              24








              24







              You can use:



              udisks --mount device_name


              or



              udisksctl mount -b device_name


              where device_name is the name of a storage device and should look something like /dev/sdb1.



              Using sudo fdisk -l command you can find out all storage devices attached to your system.






              share|improve this answer















              You can use:



              udisks --mount device_name


              or



              udisksctl mount -b device_name


              where device_name is the name of a storage device and should look something like /dev/sdb1.



              Using sudo fdisk -l command you can find out all storage devices attached to your system.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Sep 6 '13 at 14:25

























              answered Sep 6 '13 at 13:52









              Radu RădeanuRadu Rădeanu

              116k34247323




              116k34247323








              • 2





                Tried that, that however leads to /media/{disk}, different from what Thunar or Nautilus would give. The udisksctl command provided by udisks2 however seems to do what I want.

                – Grumbel
                Sep 6 '13 at 14:02






              • 1





                udisksctl status will give a proper list of devices and work as user. fdisk -l not only requires root, it will also fail with GPT drives. cat /proc/partitions would be a better low-level way to get an idea of partitions available.

                – Grumbel
                Sep 6 '13 at 14:43











              • udiskctl is extremely useful for mounting image disk files into loop devices without root privileges, too!

                – JBFWP286
                Aug 14 '17 at 22:05














              • 2





                Tried that, that however leads to /media/{disk}, different from what Thunar or Nautilus would give. The udisksctl command provided by udisks2 however seems to do what I want.

                – Grumbel
                Sep 6 '13 at 14:02






              • 1





                udisksctl status will give a proper list of devices and work as user. fdisk -l not only requires root, it will also fail with GPT drives. cat /proc/partitions would be a better low-level way to get an idea of partitions available.

                – Grumbel
                Sep 6 '13 at 14:43











              • udiskctl is extremely useful for mounting image disk files into loop devices without root privileges, too!

                – JBFWP286
                Aug 14 '17 at 22:05








              2




              2





              Tried that, that however leads to /media/{disk}, different from what Thunar or Nautilus would give. The udisksctl command provided by udisks2 however seems to do what I want.

              – Grumbel
              Sep 6 '13 at 14:02





              Tried that, that however leads to /media/{disk}, different from what Thunar or Nautilus would give. The udisksctl command provided by udisks2 however seems to do what I want.

              – Grumbel
              Sep 6 '13 at 14:02




              1




              1





              udisksctl status will give a proper list of devices and work as user. fdisk -l not only requires root, it will also fail with GPT drives. cat /proc/partitions would be a better low-level way to get an idea of partitions available.

              – Grumbel
              Sep 6 '13 at 14:43





              udisksctl status will give a proper list of devices and work as user. fdisk -l not only requires root, it will also fail with GPT drives. cat /proc/partitions would be a better low-level way to get an idea of partitions available.

              – Grumbel
              Sep 6 '13 at 14:43













              udiskctl is extremely useful for mounting image disk files into loop devices without root privileges, too!

              – JBFWP286
              Aug 14 '17 at 22:05





              udiskctl is extremely useful for mounting image disk files into loop devices without root privileges, too!

              – JBFWP286
              Aug 14 '17 at 22:05













              14














              gvfs-mount



              Listing available devices can be done with:



              gvfs-mount --list


              Mounting them can be done with:



              gvfs-mount -d /dev/sdf


              Unmounting is possible via:



              gvfs-mount --unmount /media/user/01234567890


              One remaining problem is that I have no idea how to use the gvfs-mount --list output in a mount command, as --list won't show block device names and trying to use the device names it prints in a mount will result in:



              Error mounting location: volume doesn't implement mount


              udisksctl



              Listing available devices:



              udisksctl status


              Mounting is done via:



              udisksctl mount -b /dev/sdf


              or



              udisksctl mount -p block_devices/sdf


              Unmounting is done via:



              udisksctl unmount -b /dev/sdf


              or



              udisksctl unmount -p block_devices/sdf


              The object-path can be found out by doing:



              udisksctl dump


              Object of type org.freedesktop.UDisks2.Block seem to be valid as object-patch, the /org/freedesktop/UDisks2/ prefix has to be cut from the path for udisksctl to accept them.



              Conclusion



              While both gvfs-mount and udisksctl will work for the tasks, their interface is impractical as they don't provide human readable status of the disks available, just an overly verbose info dump.





              Update: gio mount replace gvfs-mount



              gvfs is now listed as deprecated (2018) and you are advised to use 'gio' which is Gnome In Out and part of Glib. See Wikipedia.



              For example, to auto-mount a second drive partition; create a bash script with executable permission to run at start-up with the following command:



              gio mount -d /dev/sda2


              If you are owner of the partition (see chown) you won't need sudo.






              share|improve this answer


























              • Could you extend your answer including how to mount an iso with gio mount? On 18.04 with Archive Mounter gio mount -l return Type: GDaemonMount but I couldn't mount it via CLI (maybe an issue?).

                – Pablo Bianchi
                7 hours ago
















              14














              gvfs-mount



              Listing available devices can be done with:



              gvfs-mount --list


              Mounting them can be done with:



              gvfs-mount -d /dev/sdf


              Unmounting is possible via:



              gvfs-mount --unmount /media/user/01234567890


              One remaining problem is that I have no idea how to use the gvfs-mount --list output in a mount command, as --list won't show block device names and trying to use the device names it prints in a mount will result in:



              Error mounting location: volume doesn't implement mount


              udisksctl



              Listing available devices:



              udisksctl status


              Mounting is done via:



              udisksctl mount -b /dev/sdf


              or



              udisksctl mount -p block_devices/sdf


              Unmounting is done via:



              udisksctl unmount -b /dev/sdf


              or



              udisksctl unmount -p block_devices/sdf


              The object-path can be found out by doing:



              udisksctl dump


              Object of type org.freedesktop.UDisks2.Block seem to be valid as object-patch, the /org/freedesktop/UDisks2/ prefix has to be cut from the path for udisksctl to accept them.



              Conclusion



              While both gvfs-mount and udisksctl will work for the tasks, their interface is impractical as they don't provide human readable status of the disks available, just an overly verbose info dump.





              Update: gio mount replace gvfs-mount



              gvfs is now listed as deprecated (2018) and you are advised to use 'gio' which is Gnome In Out and part of Glib. See Wikipedia.



              For example, to auto-mount a second drive partition; create a bash script with executable permission to run at start-up with the following command:



              gio mount -d /dev/sda2


              If you are owner of the partition (see chown) you won't need sudo.






              share|improve this answer


























              • Could you extend your answer including how to mount an iso with gio mount? On 18.04 with Archive Mounter gio mount -l return Type: GDaemonMount but I couldn't mount it via CLI (maybe an issue?).

                – Pablo Bianchi
                7 hours ago














              14












              14








              14







              gvfs-mount



              Listing available devices can be done with:



              gvfs-mount --list


              Mounting them can be done with:



              gvfs-mount -d /dev/sdf


              Unmounting is possible via:



              gvfs-mount --unmount /media/user/01234567890


              One remaining problem is that I have no idea how to use the gvfs-mount --list output in a mount command, as --list won't show block device names and trying to use the device names it prints in a mount will result in:



              Error mounting location: volume doesn't implement mount


              udisksctl



              Listing available devices:



              udisksctl status


              Mounting is done via:



              udisksctl mount -b /dev/sdf


              or



              udisksctl mount -p block_devices/sdf


              Unmounting is done via:



              udisksctl unmount -b /dev/sdf


              or



              udisksctl unmount -p block_devices/sdf


              The object-path can be found out by doing:



              udisksctl dump


              Object of type org.freedesktop.UDisks2.Block seem to be valid as object-patch, the /org/freedesktop/UDisks2/ prefix has to be cut from the path for udisksctl to accept them.



              Conclusion



              While both gvfs-mount and udisksctl will work for the tasks, their interface is impractical as they don't provide human readable status of the disks available, just an overly verbose info dump.





              Update: gio mount replace gvfs-mount



              gvfs is now listed as deprecated (2018) and you are advised to use 'gio' which is Gnome In Out and part of Glib. See Wikipedia.



              For example, to auto-mount a second drive partition; create a bash script with executable permission to run at start-up with the following command:



              gio mount -d /dev/sda2


              If you are owner of the partition (see chown) you won't need sudo.






              share|improve this answer















              gvfs-mount



              Listing available devices can be done with:



              gvfs-mount --list


              Mounting them can be done with:



              gvfs-mount -d /dev/sdf


              Unmounting is possible via:



              gvfs-mount --unmount /media/user/01234567890


              One remaining problem is that I have no idea how to use the gvfs-mount --list output in a mount command, as --list won't show block device names and trying to use the device names it prints in a mount will result in:



              Error mounting location: volume doesn't implement mount


              udisksctl



              Listing available devices:



              udisksctl status


              Mounting is done via:



              udisksctl mount -b /dev/sdf


              or



              udisksctl mount -p block_devices/sdf


              Unmounting is done via:



              udisksctl unmount -b /dev/sdf


              or



              udisksctl unmount -p block_devices/sdf


              The object-path can be found out by doing:



              udisksctl dump


              Object of type org.freedesktop.UDisks2.Block seem to be valid as object-patch, the /org/freedesktop/UDisks2/ prefix has to be cut from the path for udisksctl to accept them.



              Conclusion



              While both gvfs-mount and udisksctl will work for the tasks, their interface is impractical as they don't provide human readable status of the disks available, just an overly verbose info dump.





              Update: gio mount replace gvfs-mount



              gvfs is now listed as deprecated (2018) and you are advised to use 'gio' which is Gnome In Out and part of Glib. See Wikipedia.



              For example, to auto-mount a second drive partition; create a bash script with executable permission to run at start-up with the following command:



              gio mount -d /dev/sda2


              If you are owner of the partition (see chown) you won't need sudo.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited 8 hours ago









              Pablo Bianchi

              2,4451530




              2,4451530










              answered Sep 6 '13 at 14:48









              GrumbelGrumbel

              2,72432540




              2,72432540













              • Could you extend your answer including how to mount an iso with gio mount? On 18.04 with Archive Mounter gio mount -l return Type: GDaemonMount but I couldn't mount it via CLI (maybe an issue?).

                – Pablo Bianchi
                7 hours ago



















              • Could you extend your answer including how to mount an iso with gio mount? On 18.04 with Archive Mounter gio mount -l return Type: GDaemonMount but I couldn't mount it via CLI (maybe an issue?).

                – Pablo Bianchi
                7 hours ago

















              Could you extend your answer including how to mount an iso with gio mount? On 18.04 with Archive Mounter gio mount -l return Type: GDaemonMount but I couldn't mount it via CLI (maybe an issue?).

              – Pablo Bianchi
              7 hours ago





              Could you extend your answer including how to mount an iso with gio mount? On 18.04 with Archive Mounter gio mount -l return Type: GDaemonMount but I couldn't mount it via CLI (maybe an issue?).

              – Pablo Bianchi
              7 hours ago











              5














              A simple solution that works as required (mounts to /media/{user}/{diskid}) except that it can not list devices but needs to be given the exact, case sensitive, volume label as argument $1



              To mount:



              DEVICE=$(findfs LABEL=$1) && udisksctl mount -b $DEVICE


              To unmount:



              DEVICE=$(findfs LABEL=$1) && udisksctl unmount -b $DEVICE





              share|improve this answer


























              • Nice. Or, just : udisksctl mount -b $(findfs LABEL=<label>)

                – Brent Faust
                Mar 31 '18 at 19:06


















              5














              A simple solution that works as required (mounts to /media/{user}/{diskid}) except that it can not list devices but needs to be given the exact, case sensitive, volume label as argument $1



              To mount:



              DEVICE=$(findfs LABEL=$1) && udisksctl mount -b $DEVICE


              To unmount:



              DEVICE=$(findfs LABEL=$1) && udisksctl unmount -b $DEVICE





              share|improve this answer


























              • Nice. Or, just : udisksctl mount -b $(findfs LABEL=<label>)

                – Brent Faust
                Mar 31 '18 at 19:06
















              5












              5








              5







              A simple solution that works as required (mounts to /media/{user}/{diskid}) except that it can not list devices but needs to be given the exact, case sensitive, volume label as argument $1



              To mount:



              DEVICE=$(findfs LABEL=$1) && udisksctl mount -b $DEVICE


              To unmount:



              DEVICE=$(findfs LABEL=$1) && udisksctl unmount -b $DEVICE





              share|improve this answer















              A simple solution that works as required (mounts to /media/{user}/{diskid}) except that it can not list devices but needs to be given the exact, case sensitive, volume label as argument $1



              To mount:



              DEVICE=$(findfs LABEL=$1) && udisksctl mount -b $DEVICE


              To unmount:



              DEVICE=$(findfs LABEL=$1) && udisksctl unmount -b $DEVICE






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jun 21 '14 at 9:41

























              answered Jun 21 '14 at 9:09









              zvukzvuk

              5113




              5113













              • Nice. Or, just : udisksctl mount -b $(findfs LABEL=<label>)

                – Brent Faust
                Mar 31 '18 at 19:06





















              • Nice. Or, just : udisksctl mount -b $(findfs LABEL=<label>)

                – Brent Faust
                Mar 31 '18 at 19:06



















              Nice. Or, just : udisksctl mount -b $(findfs LABEL=<label>)

              – Brent Faust
              Mar 31 '18 at 19:06







              Nice. Or, just : udisksctl mount -b $(findfs LABEL=<label>)

              – Brent Faust
              Mar 31 '18 at 19:06













              1














              Just ran into the issue myself, and found the following solution:



              udisksctl mount -b /dev/disk/by-labels/$LABEL


              It will ask for the user password, even if it's you and you're already logged in.






              share|improve this answer




























                1














                Just ran into the issue myself, and found the following solution:



                udisksctl mount -b /dev/disk/by-labels/$LABEL


                It will ask for the user password, even if it's you and you're already logged in.






                share|improve this answer


























                  1












                  1








                  1







                  Just ran into the issue myself, and found the following solution:



                  udisksctl mount -b /dev/disk/by-labels/$LABEL


                  It will ask for the user password, even if it's you and you're already logged in.






                  share|improve this answer













                  Just ran into the issue myself, and found the following solution:



                  udisksctl mount -b /dev/disk/by-labels/$LABEL


                  It will ask for the user password, even if it's you and you're already logged in.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jul 2 '18 at 22:18









                  komutakomuta

                  736




                  736























                      0














                      I wrote this Bash script to work around this problem, but be aware that I'm a scripting newbie. All suggestions welcome! Usage and description follow below the script.



                      #!/bin/bash
                      # umanage.sh
                      # 2014-05-05

                      BASEPATH="/media/$(whoami)/"
                      RESULTS=$(udisksctl dump | grep IdLabel | grep -c -i "$1")

                      case "$RESULTS" in

                      0 ) echo "Nothing found."
                      ;;

                      1 ) DEVICELABEL=$(udisksctl dump | grep IdLabel | grep -i "$1" | cut -d ":" -f 2 | sed 's/^[ t]*//')
                      DEVICE=$(udisksctl dump | grep -i "IdLabel: +$DEVICELABEL" -B 12 | grep " Device:" | cut -d ":" -f 2 | sed 's/^[ t]*//')
                      DEVICEPATH="$BASEPATH""$DEVICELABEL"

                      if [[ -z $(mount | grep "$DEVICE") ]]
                      then
                      echo "Found unmounted $DEVICE partition."
                      echo "Do you want to mount it in $DEVICEPATH?"
                      select yn in "Mount" "Ignore"
                      do
                      case $yn in
                      Mount ) udisksctl mount -b "$DEVICE"
                      break
                      ;;
                      Ignore ) exit
                      ;;
                      esac
                      done
                      else
                      echo "Found $DEVICE partition, currently mounted in $DEVICEPATH."
                      echo "Do you want to unmount it?"
                      select yn in "Unmount" "Ignore"
                      do
                      case $yn in
                      Unmount ) udisksctl unmount -b "$DEVICE"
                      break
                      ;;
                      Ignore ) exit
                      ;;
                      esac
                      done
                      fi
                      ;;

                      * ) if [ $# -eq 0 ]
                      then
                      echo "No argument supplied"
                      else
                      echo "$RESULTS possible results. You may be looking for:"
                      echo
                      udisksctl dump | grep IdLabel | grep -i "$1" | cut -d ":" -f 2 | sed 's/^[ t]*//' | sed '/^$/d'
                      echo
                      echo "Please refine your search."
                      fi
                      ;;

                      esac


                      Usage:




                      • save the script as umanage.sh

                      • make it executable: chmod +x umanage.sh

                      • run it: ./umanage.sh YourDeviceLabel


                      The script accepts as an argument the label of the partition you want to mount and looks in the udisksctl dump for corresponding entries.



                      If a partition is found and it's not mounted, device name and path are shown and you're offered to mount the partition. The script searches for partial labels too, and it won't care about upper or lower case (useful when you don't remember the exact label).



                      ./umanage.sh PASSPORT
                      Found unmounted /dev/sdf1 partition.
                      Do you want to mount it in /media/pixel/My Passport?
                      1) Mount
                      2) Ignore
                      #?


                      If a partition is found and it's already mounted, you're offered to unmount it:



                      ./umanage.sh passp
                      Found /dev/sdf1 partition, currently mounted in /media/open/My Passport.
                      Do you want to unmount it?
                      1) Unmount
                      2) Ignore
                      #?


                      If your argument matches more than a result, the script shows you the matching partition labels and asks you to refine the search:



                      ./umanage.sh SS
                      2 possible results. You may be looking for:

                      SSD-9GB
                      My Passport

                      Please refine your search.





                      share|improve this answer






























                        0














                        I wrote this Bash script to work around this problem, but be aware that I'm a scripting newbie. All suggestions welcome! Usage and description follow below the script.



                        #!/bin/bash
                        # umanage.sh
                        # 2014-05-05

                        BASEPATH="/media/$(whoami)/"
                        RESULTS=$(udisksctl dump | grep IdLabel | grep -c -i "$1")

                        case "$RESULTS" in

                        0 ) echo "Nothing found."
                        ;;

                        1 ) DEVICELABEL=$(udisksctl dump | grep IdLabel | grep -i "$1" | cut -d ":" -f 2 | sed 's/^[ t]*//')
                        DEVICE=$(udisksctl dump | grep -i "IdLabel: +$DEVICELABEL" -B 12 | grep " Device:" | cut -d ":" -f 2 | sed 's/^[ t]*//')
                        DEVICEPATH="$BASEPATH""$DEVICELABEL"

                        if [[ -z $(mount | grep "$DEVICE") ]]
                        then
                        echo "Found unmounted $DEVICE partition."
                        echo "Do you want to mount it in $DEVICEPATH?"
                        select yn in "Mount" "Ignore"
                        do
                        case $yn in
                        Mount ) udisksctl mount -b "$DEVICE"
                        break
                        ;;
                        Ignore ) exit
                        ;;
                        esac
                        done
                        else
                        echo "Found $DEVICE partition, currently mounted in $DEVICEPATH."
                        echo "Do you want to unmount it?"
                        select yn in "Unmount" "Ignore"
                        do
                        case $yn in
                        Unmount ) udisksctl unmount -b "$DEVICE"
                        break
                        ;;
                        Ignore ) exit
                        ;;
                        esac
                        done
                        fi
                        ;;

                        * ) if [ $# -eq 0 ]
                        then
                        echo "No argument supplied"
                        else
                        echo "$RESULTS possible results. You may be looking for:"
                        echo
                        udisksctl dump | grep IdLabel | grep -i "$1" | cut -d ":" -f 2 | sed 's/^[ t]*//' | sed '/^$/d'
                        echo
                        echo "Please refine your search."
                        fi
                        ;;

                        esac


                        Usage:




                        • save the script as umanage.sh

                        • make it executable: chmod +x umanage.sh

                        • run it: ./umanage.sh YourDeviceLabel


                        The script accepts as an argument the label of the partition you want to mount and looks in the udisksctl dump for corresponding entries.



                        If a partition is found and it's not mounted, device name and path are shown and you're offered to mount the partition. The script searches for partial labels too, and it won't care about upper or lower case (useful when you don't remember the exact label).



                        ./umanage.sh PASSPORT
                        Found unmounted /dev/sdf1 partition.
                        Do you want to mount it in /media/pixel/My Passport?
                        1) Mount
                        2) Ignore
                        #?


                        If a partition is found and it's already mounted, you're offered to unmount it:



                        ./umanage.sh passp
                        Found /dev/sdf1 partition, currently mounted in /media/open/My Passport.
                        Do you want to unmount it?
                        1) Unmount
                        2) Ignore
                        #?


                        If your argument matches more than a result, the script shows you the matching partition labels and asks you to refine the search:



                        ./umanage.sh SS
                        2 possible results. You may be looking for:

                        SSD-9GB
                        My Passport

                        Please refine your search.





                        share|improve this answer




























                          0












                          0








                          0







                          I wrote this Bash script to work around this problem, but be aware that I'm a scripting newbie. All suggestions welcome! Usage and description follow below the script.



                          #!/bin/bash
                          # umanage.sh
                          # 2014-05-05

                          BASEPATH="/media/$(whoami)/"
                          RESULTS=$(udisksctl dump | grep IdLabel | grep -c -i "$1")

                          case "$RESULTS" in

                          0 ) echo "Nothing found."
                          ;;

                          1 ) DEVICELABEL=$(udisksctl dump | grep IdLabel | grep -i "$1" | cut -d ":" -f 2 | sed 's/^[ t]*//')
                          DEVICE=$(udisksctl dump | grep -i "IdLabel: +$DEVICELABEL" -B 12 | grep " Device:" | cut -d ":" -f 2 | sed 's/^[ t]*//')
                          DEVICEPATH="$BASEPATH""$DEVICELABEL"

                          if [[ -z $(mount | grep "$DEVICE") ]]
                          then
                          echo "Found unmounted $DEVICE partition."
                          echo "Do you want to mount it in $DEVICEPATH?"
                          select yn in "Mount" "Ignore"
                          do
                          case $yn in
                          Mount ) udisksctl mount -b "$DEVICE"
                          break
                          ;;
                          Ignore ) exit
                          ;;
                          esac
                          done
                          else
                          echo "Found $DEVICE partition, currently mounted in $DEVICEPATH."
                          echo "Do you want to unmount it?"
                          select yn in "Unmount" "Ignore"
                          do
                          case $yn in
                          Unmount ) udisksctl unmount -b "$DEVICE"
                          break
                          ;;
                          Ignore ) exit
                          ;;
                          esac
                          done
                          fi
                          ;;

                          * ) if [ $# -eq 0 ]
                          then
                          echo "No argument supplied"
                          else
                          echo "$RESULTS possible results. You may be looking for:"
                          echo
                          udisksctl dump | grep IdLabel | grep -i "$1" | cut -d ":" -f 2 | sed 's/^[ t]*//' | sed '/^$/d'
                          echo
                          echo "Please refine your search."
                          fi
                          ;;

                          esac


                          Usage:




                          • save the script as umanage.sh

                          • make it executable: chmod +x umanage.sh

                          • run it: ./umanage.sh YourDeviceLabel


                          The script accepts as an argument the label of the partition you want to mount and looks in the udisksctl dump for corresponding entries.



                          If a partition is found and it's not mounted, device name and path are shown and you're offered to mount the partition. The script searches for partial labels too, and it won't care about upper or lower case (useful when you don't remember the exact label).



                          ./umanage.sh PASSPORT
                          Found unmounted /dev/sdf1 partition.
                          Do you want to mount it in /media/pixel/My Passport?
                          1) Mount
                          2) Ignore
                          #?


                          If a partition is found and it's already mounted, you're offered to unmount it:



                          ./umanage.sh passp
                          Found /dev/sdf1 partition, currently mounted in /media/open/My Passport.
                          Do you want to unmount it?
                          1) Unmount
                          2) Ignore
                          #?


                          If your argument matches more than a result, the script shows you the matching partition labels and asks you to refine the search:



                          ./umanage.sh SS
                          2 possible results. You may be looking for:

                          SSD-9GB
                          My Passport

                          Please refine your search.





                          share|improve this answer















                          I wrote this Bash script to work around this problem, but be aware that I'm a scripting newbie. All suggestions welcome! Usage and description follow below the script.



                          #!/bin/bash
                          # umanage.sh
                          # 2014-05-05

                          BASEPATH="/media/$(whoami)/"
                          RESULTS=$(udisksctl dump | grep IdLabel | grep -c -i "$1")

                          case "$RESULTS" in

                          0 ) echo "Nothing found."
                          ;;

                          1 ) DEVICELABEL=$(udisksctl dump | grep IdLabel | grep -i "$1" | cut -d ":" -f 2 | sed 's/^[ t]*//')
                          DEVICE=$(udisksctl dump | grep -i "IdLabel: +$DEVICELABEL" -B 12 | grep " Device:" | cut -d ":" -f 2 | sed 's/^[ t]*//')
                          DEVICEPATH="$BASEPATH""$DEVICELABEL"

                          if [[ -z $(mount | grep "$DEVICE") ]]
                          then
                          echo "Found unmounted $DEVICE partition."
                          echo "Do you want to mount it in $DEVICEPATH?"
                          select yn in "Mount" "Ignore"
                          do
                          case $yn in
                          Mount ) udisksctl mount -b "$DEVICE"
                          break
                          ;;
                          Ignore ) exit
                          ;;
                          esac
                          done
                          else
                          echo "Found $DEVICE partition, currently mounted in $DEVICEPATH."
                          echo "Do you want to unmount it?"
                          select yn in "Unmount" "Ignore"
                          do
                          case $yn in
                          Unmount ) udisksctl unmount -b "$DEVICE"
                          break
                          ;;
                          Ignore ) exit
                          ;;
                          esac
                          done
                          fi
                          ;;

                          * ) if [ $# -eq 0 ]
                          then
                          echo "No argument supplied"
                          else
                          echo "$RESULTS possible results. You may be looking for:"
                          echo
                          udisksctl dump | grep IdLabel | grep -i "$1" | cut -d ":" -f 2 | sed 's/^[ t]*//' | sed '/^$/d'
                          echo
                          echo "Please refine your search."
                          fi
                          ;;

                          esac


                          Usage:




                          • save the script as umanage.sh

                          • make it executable: chmod +x umanage.sh

                          • run it: ./umanage.sh YourDeviceLabel


                          The script accepts as an argument the label of the partition you want to mount and looks in the udisksctl dump for corresponding entries.



                          If a partition is found and it's not mounted, device name and path are shown and you're offered to mount the partition. The script searches for partial labels too, and it won't care about upper or lower case (useful when you don't remember the exact label).



                          ./umanage.sh PASSPORT
                          Found unmounted /dev/sdf1 partition.
                          Do you want to mount it in /media/pixel/My Passport?
                          1) Mount
                          2) Ignore
                          #?


                          If a partition is found and it's already mounted, you're offered to unmount it:



                          ./umanage.sh passp
                          Found /dev/sdf1 partition, currently mounted in /media/open/My Passport.
                          Do you want to unmount it?
                          1) Unmount
                          2) Ignore
                          #?


                          If your argument matches more than a result, the script shows you the matching partition labels and asks you to refine the search:



                          ./umanage.sh SS
                          2 possible results. You may be looking for:

                          SSD-9GB
                          My Passport

                          Please refine your search.






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited May 5 '14 at 17:55

























                          answered May 1 '14 at 15:41









                          pixelpixel

                          125




                          125






























                              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%2f342188%2fhow-to-auto-mount-from-command-line%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

                              GameSpot

                              日野市

                              Tu-95轟炸機