john.cord Wrote:plz let me know if it works...
Ok so scratch all those other solutions. Undo everything you have tried before. I've found a working solution which uses udev. So make sure it's installed, which it most likely is.
Create a udev rule file:
Code:
# sudo vi /etc/udev/rules.d/11-media-by-label-auto-mount.rules
And put this in it:
Code:
KERNEL!="[color=red]sd[a-z][0-9][/color]", 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}="[color=red]usbhd[/color]-%k"
# Global mount options
[color=red]ACTION=="add", ENV{mount_options}="relatime"[/color]
# Filesystem-specific mount options
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},utf8,[color=red]uid=1000,gid=1000[/color],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"
Note that I have highlighted some things in red that I changed to suit my needs.
First, I changed
to
since sda is my internal HDD.
I commented out ACTION=="add", ENV{mount_options}="relatime" so it would look like:
Code:
#ACTION=="add", ENV{mount_options}="relatime"
I believe it was causing some problems for me.
For ENV{dir_name}="usbhd-%k", you can change usbhd to whatever you want. It will be the prefix for the mount name in the event it does not have a label.
Last, the UID and GID I changed to 1000 which is my main user.
Give credit where credit is due is what I say.
Original writeup is @
https://wiki.archlinux.org/index.php/Udev
Some other links that I found that may help are:
http://ubuntuforums.org/showpost.php?p=1...ostcount=8
http://igurublog.wordpress.com/downloads/script-devmon/