Automount USB flash disk (fw 4.0.0 +).
In category Routers .
Example script:
#!/bin/sh
#
LAST=0
i=0
while true
do
flsh=`cat /proc/diskstats |awk '/8\x20\x20\x20\x20\x20\x20\x201/ {print $3}'`
if [ $flsh ]; then
i=1
else
i=0
fi
if [ $LAST != $i ]; then
LAST=$i
if [ $i = 1 ]; then
echo "Mount flash disk."
if [ -d /mnt/flash ]; then
mount /dev/$flsh /mnt/flash
else
mkdir /mnt/flash
mount /dev/$flsh /mnt/flash
fi
else
echo "UMOUNT flash disk."
umount /mnt/flash
rmdir /mnt/flash
fi
fi
sleep 2
done
Create a file automount.sh and copy it e.g. to root folder and start it from Startup script as you can see below.
Startup Script:
#!/bin/sh # # This script will be executed *after* all the other init scripts. # You can put your own initialization stuff in here. sh /root/automount.sh &
After reboot the router you can see folder /mnt/flash after inserted USB flash disk.