-   Programming (
-   -   find mount point given device (

kornelix 04-10-2007 04:21 PM

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?


GrapefruiTgirl 04-10-2007 04:38 PM

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.:scratch:

BotKeeper 04-13-2007 09:01 AM

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).

All times are GMT -5. The time now is 03:03 AM.