Files
slava.home/rse/10-USB-media-automount.rules

33 lines
1.4 KiB
Plaintext
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# /etc/udev/rules.d/10-USB-media-automount.rules
# проверка всех разделов
KERNEL!="sd[a-z][0-9]", GOTO="end"
# инфа о файловой системе
IMPORT{program}="/sbin/blkid %N"
#/root/USB_Automount/mount.sh %N %K
# Получаем метку в противном случае система присваивает сама
ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}"
ENV{ID_FS_LABEL}=="", ENV{dir_name}="UsbDisk-%k"
# Создаем папку в /media и символическую ссылку на неё в /mnt%E{dir_name}
ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'"
# Глобальные опции
ACTION=="add", ENV{mount_options}="relatime"
# Права (777/666 папки/файлы для ntfs/vfat)
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", ENV{mount_options}="$env{mount_options},gid=100,dmask=000,fmask=000,utf8"
# автомоунт ntfs через ntfs-3g
ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/mount -t ntfs-3g -o %E{mount_options} /dev/%k '/media/%E{dir_name}'"
# для остальных система сама определяет
ACTION=="add", ENV{ID_FS_TYPE}!="ntfs", RUN+="/bin/mount -t auto -o %E{mount_options} /dev/%k '/media/%E{dir_name}'"
# чистка после изьятия
ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l '/media/%E{dir_name}'", RUN+="/bin/rmdir '/media/%E{dir_name}'"
# выход
LABEL="end"