LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Mapping USB flash drive to its /dev/xxx (http://www.linuxquestions.org/questions/slackware-14/mapping-usb-flash-drive-to-its-dev-xxx-4175453270/)

waddles 03-08-2013 09:12 AM

Mapping USB flash drive to its /dev/xxx
 
I need to associate the flash drive from lsusb with the device name I get by using dmesg (i.e. /dev/sdz). If I wait long enough dmesg no longer has the stuff I need to make the association. Is there an (easier haha) other way?

guanx 03-08-2013 02:24 PM

ls -l /sys/block/ | grep usb

Didier Spaier 03-08-2013 02:30 PM

cat /proc/partitions

If you don't want to automount some flash drive but want to be able to mount it manually using always the same mount point, plug it in, type as root "blkid" to know its UUID then write a line for it in /etc/fstab replacing /dev/sdz with UUID=<string given by blkid, without the double quotes>.

PS I just saw Guanx' post. As the saying goes: "two slackers, three answers" ;)

waddles 03-09-2013 03:42 AM

Thanks guys good responses I need something (unless I am misreading the ls -l /sys/block | grep usb output) which maps 1:1 a bit closer.
lsusb output:
Bus 001 Device 004: ID 154b:005b PNY
Bus 001 Device 005: ID 0781:5530 SanDisk Corp. Cruzer
ls -l /sys/block | grep usb output:
lrwxrwxrwx 1 root root 0 Mar 8 16:38 sdc -> ../devices/pci0000:00/0000:00:10.3/usb1/1-6/1-6.4/1-6.4:1.0/host6/target6:0:0/6:0:0:0/block/sdc
lrwxrwxrwx 1 root root 0 Mar 9 01:33 sdd -> ../devices/pci0000:00/0000:00:10.3/usb1/1-6/1-6.3/1-6.3:1.0/host7/target7:0:0/7:0:0:0/block/sdd
What I need is a way to go from either Bus/Device or mfrr:modl or label to sd?.
Is there a way to do that or did I miss it? Is it the host# -2 = Device 00#?

guanx 03-09-2013 05:09 AM

lsusb.py

enine 03-09-2013 07:18 AM

So you just put the /devices entry in fstab?

sdb -> ../devices/pci0000:00/0000:00:1d.7/usb2/2-4/2-4:1.0/host4/target4:0:0/4:0:0:0/block/sdb/


I setup a hotplug script several versions ago but it seems they changed everything on me. What I do is take my previous drive and put in a usb enclosure then plug in and rsync my home to it then unplug and put it in the safe. How do I make it automount under /backup and unmount when I unplug it?

like this in fstab:

../devices/pci0000:00/0000:00:1d.7/usb2/2-4/2-4:1.0/host4/target4:0:0/4:0:0:0/block/sdb/ /backup auto defaults 1 1

XGizzmo 03-09-2013 08:25 AM

Try lsscsi

jefro 03-09-2013 05:19 PM

I'd agree that you don't want to associate it with the unreliable usb connection that may cause it to go from sdb to sdq or so. Mount by device name or uuid as suggested above.


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