I have a linux media player that was very common before android's age. It is a MIPS running Linux Venus 2.6.12.6 and has 2 sata, 2 usb and 1 sdcard port. Since the flash memory is very limited, I installed optware, ssh and nano on sdcard and put inln -s /tmp/usbmounts/sdb1/opt /optThe sdcard can remain plugged for good since I won't use sdcard for media. It works very well if I do not have other usb plugged or if I plug other usb after boot. But if I plug other usb before boot, the sdcard port always be mounted to sdc or sdd and of course the link won't work. I (kind of) resolved this by putting a script at boot to locate /opt and link accordingly. However, I found that there is other activity that can change the mount point after boot.The player mainly runs a software called Dvdplayer. This software has a menu on screen for user to choose media to play. Every time when this menu is called up, the mount point seems to change, EVEN WITHOUT any additional usb plug in. Say if after boot, my sdcard is mounted to sdb, after calling up the menu, it changed to sdc (sdb has nothing). Calling up the menu again, it becomes sdd (sdb and sdc has nothing). Call the menu the 3rd time, it goes back to sdc and then to and fore between sdc and sdd, never sdb again.Searching the internet, I understand this is hotplugging and I am able to locate the software. But different from the usual linux hotplug, the softare is an executable elf file instead of a script, and I cannot find any system variables related the hotplug, such as SUBSYSTEM, ACTION, PRODUCT, TYPE, INTERFACE, DEVICE etc. Instead, it has a sequence number in /sys/kernel/hotplug_seqnum. It has empty folders like /tmp/lock/hotplug/convert_tmp, ...mount_tmp, ...rename_tmp and ...volume_lock. mount_tmp is the only folder that has its date changed, but still is always empty.I've tried to trap the hotplug by moving the /sbin/hotplug to /sbin/sbin/hotplug and put in my own hotplug script in /sbin/hotplug. The script looks like thismount / -o remount,rwecho $* >> /usr/local/etc/init.d/hotplug.log/sbin/sbin/hotplug $*But it doesn't work: after calling the menu, nothing was logged and all plug-in mounts were lost.All I wanted to do now is to trap the hotplug activities and relink my /opt correctly. Appreciate any help or a better method of ensuring the correct link for /opt.
Embedded linux hotplug changed mount point
linux;usb;embedded;sd card;hot plug
Better to explicitly say that this is a shell script and I wish to use ${@} instead of $*:#!/bin/shmount -o remount,rw /echo ${@} >/tmp/log.txtecho >>/tmp/log.txtenv >>/tmp/log.txt # if /tmp is writable or tmpfsexec /sbin/sbin/hotplug ${@}If the system is sane, this should work. Many embedded, however, are not. Beware.