Persistent mountpoint for USB storage
Isaac Dunham
ibid.ag at gmail.com
Sat Oct 31 03:49:31 UTC 2015
On Fri, Oct 30, 2015 at 02:28:11PM +0100, Franz Leu wrote:
> Hi
>
>
>
> I'd like to mount USB storage on persistent mount point depending in the
> USB port it's plugged in.
>
> Plugged in port 0 always mounts to /mnt/usb0
>
> Plugged in port 1 always mounts to /mnt/usb1
>
> ...
>
>
>
> How can I achieve this automatically, manually or by a script.
If you can figure out from sysfs whether a given disk is attached to port
0/1/2/..., you can do the following:
- have /dev/usbdisk<port> in your fstab
- have a script that looks in the proper sysfs dir (/sys/class/block/<disk>)
and follows a bunch of symlinks to figure out if it's usb and which port,
then use a symlink.
However, I'm not sure how you'd do the script.
Right here, it *seems* that I have three ports (1-1, 1-2, and 1-3), and I
can tell the difference by this:
DISKPATH=$(readlink -f /sys/class/block/<disk>)
USBPATH=${DISKSPOT#*/usb}
USBPORT=$(echo $USBPATH | cut -d/ -f2)
But I'm not sure about all that; it's my best guess of what's going on.
HTH,
Isaac Dunham
More information about the busybox
mailing list