tessel/openwrt-tessel

Mount flash drives based on usb port

johnnyman727 opened this issue · 2 comments

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.

Can we force it to be consistent?

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.