I am beginner in ubuntu linux and i need to write simple bash script, that can identify necessary flash drive(which contains only one vfat partition) using uuid of this partition, and get the mount point of this flash drive.The /etc/fstab file does'nt contains mountig rule for this drive. For example, let partition uuid as 7DCD-9380 Using the readlink tool i can get device link in /dev catalog :

teddy@st1:~$ readlink -f /dev/disk/by-uuid/7DCD-9380  

But how i can get mount point of /dev/sdc1 device ?

  • You could mount it wherever you want, for example on /mnt/flashdrive (after mkdir /mnt/flashdrive of course). What specific mount point are you looking for? May 20, 2011 at 12:00

4 Answers 4


What you're after is findmnt. For example:

$ findmnt -rn -S UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -o TARGET


$ findmnt -rn -S PARTUUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -o TARGET

If nothing is mounted matching that UUID, nothing is output and the return code is 1 (failure), otherwise, the mountpoint is output and the return code is 0 (success).

Explanation of options

-r, --raw              use raw output format
-n, --noheadings       don't print column headings
-S, --source <string>  the device to mount (by name, maj:min, 
                         LABEL=, UUID=, PARTUUID=, PARTLABEL=)
-o, --output <list>    the output columns to be shown

Available columns:
      TARGET  mountpoint

mount knows this.


mount | grep /dev/sdc1

Or (likely to be faster):

grep '/dev/sdc1' /etc/mtab
  • 2
    Ah, I hadn't understood the question then. You can also use /etc/mtab. May 20, 2011 at 12:18
  • Didn't know that, added it :-) May 20, 2011 at 12:22
  • Thanks for your advice, i hoped to find easier way to get path to catalog where my flash is mounted(without using awk/sed), but but it seems there is no such easy way(such as getting link of partition in /dev catalog using it uuid) :) May 20, 2011 at 12:33

The kernel's mount table is at /proc/mounts. This is slightly more reliable than /etc/mtab, because a system/software error may result in the mtab being corrupted or not written to when it should be.

  • 1
    System error or / beeing mounted read only. Dec 11, 2014 at 11:50

To find the actual device from the UUID, blkid may be better than your readlink solution, which relies on udev.

mydev=$(blkid -l -o device -t UUID="$myuuid")

To get the mount point for this device, you can use this:

grep $mydev /proc/mounts | cut -d' ' -f 2


df -P | grep $mydev | awk '{print $6}'

The latter is more portable, because /proc is Linux-only. The df solution with the -P (POSIX) option should also work on Mac and other Unix systems.

Of course, both would break if your mount point contained spaces. But nobody mounts stuff in "/mnt/evil mount point/", right?

If you fear your predecessor might have done just that, you can use perl instead of awk:

df -P | grep $mydev | perl -pe 's/^(\S+\s+){5}//'

(the grep could also be handled by perl, but it may be harder to read for some)

The perl regex replaces 5 groups of non-spaces+spaces with nothing, leaving only the rest of line. Which is the mount point including any possible spaces.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .