View the Most Wanted LQ Wiki articles.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-10-2007, 05:21 PM   #1
Registered: Oct 2005
Location: Germany
Distribution: Ubuntu
Posts: 57

Rep: Reputation: 24
find mount point given device

I need to find removable USB drives and their mount points.

I can find USB devices at least two ways:
1. $ udevinfo -e (look for devices with ID_TYPE=disk, ID_BUS=USB)
2. $ /dev/disk/by-id (look for "USB Flash" in file name) (symlink to /dev/xxx)

I can then find the mount point by looking for the device in /etc/mtab.

This seems an awful mess for such a simple task. Is there a simpler way?

Old 04-10-2007, 05:38 PM   #2
LQ Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Have you tried the command 'lsusb' in a console? It may give you *some* of the information you want, though I am not sure if it will give you mount points. I haven't got any USB drives to try it on.
On the other hand, it doesnt look as though it gives the type of info you want.

Last edited by GrapefruiTgirl; 04-10-2007 at 05:42 PM.
Old 04-13-2007, 10:01 AM   #3
LQ Newbie
Registered: Aug 2006
Posts: 17

Rep: Reputation: 0
USB (and SCSI) CDROMs are, for example, /dev/sr0. The file /proc/mounts list all mounted devices. So, you could find all mounted USB CDROMs via a command like MNT_CDS=$(awk '$1 ~ /\/dev\/sr[0-9]+$/ { print $2 }' < /proc/mounts).


device, mount, point, usb

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mount problem - device already mounted or mount point busy zahoo Linux - General 7 08-28-2009 06:02 PM
How to find the mount point for my cd-rw in cdrecord sirius57 Linux - Hardware 7 04-04-2006 07:17 PM
Where to find mount point for USB Removable device bobbelfield Mandriva 3 02-17-2006 11:37 PM
How do I map device serial number to its mount point directory? vagrawal Linux - Software 1 03-11-2004 01:25 AM
would it make sense to have 2 mount point for 1 device? sirpelidor Linux - Hardware 3 12-27-2003 01:10 PM

All times are GMT -5. The time now is 08:10 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration