tessel / openwrt-tessel

OpenWrt build scripts and package feed for Tessel 2
Other
32 stars 14 forks source link

Mount flash drives based on usb port #40

Open johnnyman727 opened 8 years ago

johnnyman727 commented 8 years ago

Currently, flash drives are mounted to a path based on the order in which they are plugged in. The first one plugged in gets /mnt/sda1 and the second gets /mnt/sdb1 - it doesn't matter which port they are plugged into. However, when the Tessel is booted, it loads the top port first so if you initially plugged in the first flash drive into the bottom port and then plugged another drive into the top, they will have their paths switched and your fs.readFile will very wrong. We can get around this by assigning paths to usb ports.

Frijol commented 8 years ago

Can we force it to be consistent?

johnnyman727 commented 8 years ago

I think there is probably a way to do it but I didn't have the time to implement it.

For anyone interested, my guess is that you would make a hotplug script that looks for new flash drives being plugged in. You should also be able to get data about the usb port being used and mount it on the proper path based on that. You will have a lot of info available to your script:

logger -t DEBUG "hotplug usb: action='$ACTION' devicename='$DEVICENAME' devname='$DEVNAME' devpath='$DEVPATH' product='$PRODUCT' type='$TYPE' interface='$INTERFACE'"

See https://wiki.openwrt.org/doc/techref/hotplug for more details.