Hi,
i'm looking for few auto dev rules to automount usb devices, written below rule after some google.
Quote:
KERNEL!="sd[b-z][0-9]", GOTO="media_by_label_auto_mount_end"
IMPORT{program}="/sbin/blkid -o udev -p %N"
ACTION=="add", ENV{mount_options}="relatime"
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},user,utf8,umask=000"
ENV{dir_name}="%E{ID_FS_LABEL}"
ACTION=="add", RUN+="/bin/mkdir -p /media/%E{dir_name}", RUN+="/bin/mount -o $env{mount_options} /dev/%k /media/%E{dir_name}"
ACTION=="remove", RUN+="/bin/umount -l /media/%E{dir_name}"
ACTION=="remove", RUN+="/bin/rm -rf /media/%E{dir_name}"
LABEL="media_by_label_auto_mount_end"
|
working perfectly, the way it works is if you connect an usb, it creates an dir with name of its lable, lets say "8gb" and mounts the device on it , so finally you'll see my usb mounted on "/media/8gb" now i want with specific names lets say, "data", so i modified my rule as below.
problem i experiencing is if i insert any external hdd, with two partitions, it is mounting both partions on "/media/data"
but i want it like "/media/data1" and "/media/data2". for that i should your range. like we use creating multiple files "touch file{1..10}, so it will create "file1, file2 ... file10"
i tried modifing rule as
if above thing works, my first partions will be mounted on "data1" and second partition on "data2" and so on ... but it is not working like that.
please help me with correct solution.
thanks in advance.