Welcome! Log In Create A New Profile

Advanced

how to Automount USB and remote file mangement

Posted by exenew 
how to Automount USB and remote file mangement
December 15, 2011 01:06PM
Is there simple step by step guide to install any good USB automount package, basically drives are mounted an unmouted automatically when removed?

Also is there any pakcage that i can use to remotely mange USB drives files e.g i can copy file from one usb to another one without having to go command line and coping to maching where i am making this copy from (I've samba for file share right now)


Thanks

BTW - thanks to everyone on this forum i am not linux guru but by reading here i was able to installed Debian then Samba and then Asterisk on dockstar. Its amazing how much this tiny little device can do..!!!
Re: how to Automount USB and remote file mangement
December 15, 2011 02:27PM
See kraqh3d's udev rules to automount the USB drive:

In this thread (at about the end).
Re: how to Automount USB and remote file mangement
December 15, 2011 02:51PM
Correct me if wrong i need to create new tile as shown here, rigth? what are the variables that i need to change for my situation?
Also if i read correctly do i need 'pmount' installed? if so how?

==============================================
root@debian:~# cat /etc/udev/rules.d/90-automount.rules
# --sync to allow removal without corruption

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{name}=="", ENV{name}="%k"

ACTION=="add", RUN+="/usr/bin/pmount -t %E{ID_FS_TYPE} --sync --noatime --umask 000 %k %E{name}"
ACTION=="remove", RUN+="/usr/bin/pumount %E{name}"

LABEL="media_label_end"

==============================================
Re: how to Automount USB and remote file mangement
December 15, 2011 03:54PM
Here is my setup for USB drives auto-mounting (came from this original working thread). There are 3 parts: udev rules, pmounting all USB drives in rc.local, and the pmount script. Note that I've modified kraqh3d's original udev rules to add a rule for "*Async", so that any USB drive that has a label ends with Async then it will be automounted as asynchroneous (instead of "synch" which substantially slows down flash drives).

udev rules (the xx in file name xx-automount.rules varies depending on Debian installation)
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"

Mounting drives in startup
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

pmount script
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

Updated: corrected syntax error in pmount script (should be *Async )



Edited 4 time(s). Last edit at 12/15/2011 04:16PM by bodhi.
Author:

Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: