how to Automount USB and remote file mangement December 15, 2011 01:06PM |
Registered: 13 years ago Posts: 11 |
Re: how to Automount USB and remote file mangement December 15, 2011 02:27PM |
Admin Registered: 13 years ago Posts: 19,200 |
Re: how to Automount USB and remote file mangement December 15, 2011 02:51PM |
Registered: 13 years ago Posts: 11 |
Re: how to Automount USB and remote file mangement December 15, 2011 03:54PM |
Admin Registered: 13 years ago Posts: 19,200 |
root@Ds1:/etc/udev/rules.d# cat 70-automount.rules # NOTE: use pmount --sync in add action to allow removal without corruption # all drives ends with "Async" are mount as asynchronous for write performance. # Must eject these using webmin, or wait till writes are all done before unplug. KERNEL!="sd*", GOTO="media_label_end" ENV{ID_USB_DRIVER}!="usb-storage", GOTO="media_label_end" IMPORT{program}="/sbin/blkid -o udev -p %N", ENV{name}="%E{ID_FS_LABEL}" ENV{ID_FS_TYPE}=="", GOTO="media_label_end" ENV{name}=="", ENV{name}="%k" KERNEL=="sd*", SYMLINK+="usb-storage/%E{name}" ENV{name}!="*Async", ENV{mode}="--sync" ENV{name}=="*Async", ENV{mode}="" ACTION=="add", RUN+="/usr/bin/pmount -t %E{ID_FS_TYPE} %E{mode} --noatime --umask 000 %k %E{name}" ACTION=="remove", RUN+="/usr/bin/pumount --yes-I-really-want-lazy-unmount %E{name}" LABEL="media_label_end"
root@Ds1:/etc# cat rc.local #!/bin/sh -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. # # By default this script does nothing. echo default-on > /sys/class/leds/dockstar:green:health/trigger echo none > /sys/class/leds/dockstar:orange:misc/trigger /root/usb-storage.pmount exit 0
root@Ds1:/dev# more /root/usb-storage.pmount #!/bin/bash PMOUNT=`which pmount` if [ -z "$PMOUNT" ] then echo "Error: $0 cant find pmount!" 1>&2 exit 1 fi OPTIONS="--sync --noatime --umask 000" ROOT="/dev/usb-storage" for DEV in $( ls -1 $ROOT ) do BLKID=( `/sbin/blkid $ROOT/$DEV` ) for ITEM in ${BLKID[@]} do TEMP=`expr match "$ITEM" 'TYPE=\"\(.*\)\"'` TYPE=${TEMP//\"/} if [ -n "$TYPE" ] && [ "$TYPE" != "swap" ] then echo "$ROOT/$DEV" if [ `expr $DEV : '*Async'` ] then OPTIONS="--noatime --umask 000" fi echo `$PMOUNT -t $TYPE $OPTIONS $ROOT/$DEV $DEV` break fi done done exit 0