0

Automount usb drive menggunakan pmount

  1. Tambahkan file “automount.rules” pada “/etc/udev/rules.d”.
  2. Tambahkan baris kode berikut:
    ACTION=="add",KERNEL=="sda*", RUN+="/usr/bin/pmount --sync --umask 000 %k"
    ACTION=="remove", KERNEL=="sda*", RUN+="/usr/bin/pumount -l %k"
    ACTION=="add",KERNEL=="sdb*", RUN+="/usr/bin/pmount --sync --umask 000 %k"
    ACTION=="remove", KERNEL=="sdb*", RUN+="/usr/bin/pumount -l %k"
    ACTION=="add",KERNEL=="sdc*", RUN+="/usr/bin/pmount --sync --umask 000 %k"
    ACTION=="remove", KERNEL=="sdc*", RUN+="/usr/bin/pumount -l %k"
  3. Reliad udev rules dengan command:
    udevadm control --reload-rules
  4.  Mount pointnya akan berada di /media/sd**.
    sd** sesuai dengan /dev/sd**.
  5. Jika ingin menggunakan mount point sesuai dengan nama label flash drive, gunakan baris kode berikut:
    KERNEL!="sd[a-z][0-9]", GOTO="media_by_label_auto_mount_end"
    
    # Import FS infos
    IMPORT{program}="/sbin/blkid -o udev -p %N"
    
    # Get a label if present, otherwise specify one
    ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
    ENV{ID_FS_LABEL}=="", ENV{dir_name}="usbhd-%k"
    
    # Global mount options
    ACTION=="add", ENV{mount_options}="relatime"
    # Filesystem-specific mount options
    ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,gid=100,umask=002"
    
    # Mount the device
    ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
    
    # Clean up after removal
    ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l /media/%E{dir_name}", RUN+="/bin/rmdir /media/%E{dir_name}"
    
    # Exit
    LABEL="media_by_label_auto_mount_end"

 

Sumber:
http://www.monperrus.net/martin/automounting+usb+flash+drives+on+linux+with+udev+and+pmount
http://unix.stackexchange.com/questions/11472/automount-usb-drives-with-no-gui-requirement-halevt-replacement