I have a USB card reader with two SD card interfaces and two USB ports (so it can also act as a USB hub) all on the same device. I am running an embedded Linux device that is unsupervised in its use and intend to use 2 SD cards in the reader for storing data collected over several hours of operation. Each card is meant to hold specific data and the two data types cannot be mixed.Using mdev's ability to fire off a script when a USB SCSI device (either an SD card or a USB flash disk) is mounted, I can note the physical location of the USB device so that I can identify which disk is which, but there is one exception to this. The card reader reports that both of the SD cards in the reader are physically located on port 1 of the reader. This means that I'm unable to (with my current knowledge) identify in my custom-written programs the physical card that data is being written to.I can't bring the user into the loop to tell the system which card is which (the user simply plugs 2 fresh cards in, turns the device on, and walks away). How can I determine which filesystem belongs to which physical disk by using tools compatible with Busybox?Thank you.
Linux 2.6.32, busybox, Identify physical SD device
linux;usb;busybox;sd card
/sys/block is the place to look for this. When the card reader is plugged in, it lists two block devices in the style of sd*, where * is a letter. It's as though the system has added a physical scsi device without any way to access the media (unless of course there's a formatted partition on it, which the hotplug system mounts automatically through mdev's /etc/mdev.conf)./sys/block/sda (for example) is a symbolic link to /sys/devices/platform/fsl-ehci.0/usb2/2-1/2-1.1/2-1.1:1.0/host0/target0:0:0/0:0:0:1/block/sda.The section before /host/target0:0:0 is the physical device tree configuration of my USB devices. The card reader is in bus 2, port 1, port 1.The section after /host/target0:0:0 is some more device mapping that I can't quite figure out, but the last digit (for devices in this reader) is always either a 0 or a 1, which corresponds to one port or the other.So, I have what I need but it would be good for someone to come along and fill in the holes and offer a much better explanation for posterity.