Mount point by device ID
Hi ppl !
Bus 001 Device 011: ID 0951:161a Kingston Technology
Bus 001 Device 010: ID 0951:1642 Kingston Technology
ls -l /dev/disk/by-* do not show any info regarding device ID and mount point
mtab lists only mount point for a block device , but cant find anywhere a relation between device ID and mount point
How can i get the mount point for lets say " ID 1651 ???
Are you perhaps thinking of mounting by UUID? The UUID is not exactly the same as the device ID.
This article helped me:
Nope mate, trying to write a small bash to execute an app. when USB device ID is present,if not present then not running that app which resides inside that flash.
In server mode , USB flash aint mounted when inserted, and cannot look in /media/ for a specific label like "1Gb_special" because is not mounted.
If knowing somehow that lsusb | grep "ID 0951:1624" is linked to /dev/sdg i can do a pretty job indeed by mounting that device in a folder that i can work with.
Otherwise i can do it by mounting all sdX unmounted devices one by one and scan for a file inside but it is ugly.
Want to be more like an HASP key, that's why i need to detect the /dev/sdX name for a specific flash device ID
Same bash will be on more than 1 server , and for one is /dev/sdb other can be /dev/sdg depending by how many drives are present there
Hope that my english is readable !
I did a mistake in my question , saying mount point instead of /dev/sdX name
My bad was to believe that all flash disks report unique ID s , i discovered that 2 identical flash memories report same ID.
Have to buy a HASP and rethink all from scratch.
Thanks for quick reply Frankbell !!
If you use udev you can easily create a link to device with your own name (for example "/dev/id0951-1624") when usb drive is connected. And then mount with that name. You can also use "--no-canonicalize" option for mount to store path to devices as entered.
As frankbell write, the UUID mechanism was created, it is unique. Did you checked "/dev/disk/by-uuid"? These device links (by-id, by-label, etc.) are created when device is connected, not when mounted.
true eSelix , and thanks 4 the pile-up
I simply do not agree with messing up udevadm , which indeed is the mechanism preventing things shuffle up in linux.
However , I did sort this up by looping as root at start up
and greping there for USB serial number that i want, which point afterwards to it's dev node.
fdisk -l | grep -o 0xc7bd6c97
fdisk -l | sed -e '1,/0xc7bd6c97/d' | grep -m1 "/dev" | sed 's/ .*//g'
in this way I can get a lock on unique serial number and not messing up udev on multiple servers
Could be ugly from a professional point of view but now i'm happy
|All times are GMT -5. The time now is 10:48 PM.|