From 50de9ff98e813c7ba37d552c40d24a7a36d3b789 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ertu=C4=9Frul=20Erata?= Date: Sun, 3 Jan 2016 18:45:50 +0200 Subject: [PATCH] fix for ntfs usb-disc --- system/base/eudev/files/10-flash-mounts.rules | 88 ++++++++++++++----- system/base/eudev/pspec.xml | 2 +- 2 files changed, 66 insertions(+), 24 deletions(-) diff --git a/system/base/eudev/files/10-flash-mounts.rules b/system/base/eudev/files/10-flash-mounts.rules index 95f21a88..f2f66f44 100644 --- a/system/base/eudev/files/10-flash-mounts.rules +++ b/system/base/eudev/files/10-flash-mounts.rules @@ -1,33 +1,75 @@ -#!/bin/sh -# start at sdb to ignore the system hard drive -KERNEL!="sd[b-z]*", GOTO="exit" -ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="exit" +#! /bin/sh -# import some useful filesystem info as variables -IMPORT{program}="/sbin/blkid -o udev -p %N" +####################################### +# USB Flash Drives automounting # +####################################### -# get the label if present, otherwise assign one based on device/partition -ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}" -ENV{ID_FS_LABEL}=="", ENV{dir_name}="flash_drive_%k" +# start at sdb to ignore the system hard drive +KERNEL!="sd[b-z]*", GOTO="exit" +ACTION=="add", PROGRAM!="/sbin/blkid %N", GOTO="exit" -# create the dir in /media and symlink it to /mnt -ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'" +# import some useful filesystem info as variables +IMPORT{program}="/sbin/blkid -o udev -p %N" -# global mount options -#ACTION=="add", ENV{mount_options}="relatime" +# get the label if present, otherwise assign one based on device/partition +ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}" +ENV{ID_FS_LABEL}=="", ENV{dir_name}="flash_drive_%k" -# filesystem-specific mount options (777/666 dir/file perms for vfat) -ACTION=="add",ENV{mount_options_vfat}="gid=100,dmask=000,fmask=111,utf8,flush,rw,noatime,users" +# create the dir in /media and symlink it to /mnt +ACTION=="add", RUN+="/bin/mkdir -p '/media/%E{dir_name}'" -# add device to /etc/fstab -#ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", RUN+="/bin/sed -i '$a\/dev/%k /media/%E{dir_name} vfat %E{mount_options_vfat} 0 0' /etc/fstab" +# global mount options +#ACTION=="add", ENV{mount_options}="relatime" -# mount device -ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs", RUN+="/bin/mount -t auto -o %E{mount_options_vfat} /dev/%k '/media/%E{dir_name}'" +# filesystem-specific mount options (777/666 dir/file perms for ntfs/vfat) -# clean up after device removal -ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l '/media/%E{dir_name}'", RUN+="/bin/rmdir '/media/%E{dir_name}'" -ACTION=="remove", ENV{ID_FS_TYPE}!="", RUN+="/bin/sed -i '/\/dev\/%k /d' /etc/fstab" -# exit + +######## +# vfat # +######## + +# vfat specific mount options +ACTION=="add", ENV{mount_options_vfat}="gid=100,dmask=000,fmask=111,utf8,flush,rw,noatime,users" + +# add device to /etc/fstab +ACTION=="add", ENV{ID_FS_TYPE}=="vfat", RUN+="/bin/sed -i '$a\/dev/%k /media/%E{dir_name} vfat %E{mount_options_vfat} 0 0' /etc/fstab" + +# mount device +ACTION=="add", ENV{ID_FS_TYPE}=="vfat", RUN+="/bin/mount -t auto -o %E{mount_options_vfat} /dev/%k '/media/%E{dir_name}'" + + + +######## +# ntfs # +######## + +# ntfs specific mount options +ACTION=="add", ENV{mount_options_ntfs}="gid=100,dmask=000,fmask=111,utf8,flush,rw,noatime,users" + +# add device to /etc/fstab +ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/sed -i '$a\/dev/%k /media/%E{dir_name} ntfs-3g %E{mount_options_ntfs} 0 0' /etc/fstab" + +# mount device +ACTION=="add", ENV{ID_FS_TYPE}=="ntfs", RUN+="/bin/mount -t ntfs-3g -o %E{mount_options_ntfs} /dev/%k '/media/%E{dir_name}'" + + + +##################### +# other filesystems # +##################### + +# ntfs specific mount options +ACTION=="add", ENV{mount_options_other}="gid=100,dmask=000,fmask=111,utf8,flush,rw,noatime,users" + +# automount all other filesystems +ACTION=="add", ENV{ID_FS_TYPE}!="(ntfs|vfat)", RUN+="/bin/mount -t auto -o %E{mount_options_other} /dev/%k '/media/%E{dir_name}'" + +################################# +# clean up after device removal # +################################# +ACTION=="remove", ENV{dir_name}!="", RUN+="/bin/umount -l '/media/%E{dir_name}'", RUN+="/bin/rmdir '/media/%E{dir_name}'" +ACTION=="remove", ENV{ID_FS_TYPE}!="", RUN+="/bin/sed -i '/\/dev\/%k /d' /etc/fstab" + +# exit LABEL="exit" diff --git a/system/base/eudev/pspec.xml b/system/base/eudev/pspec.xml index 84935372..f1cf0bd1 100644 --- a/system/base/eudev/pspec.xml +++ b/system/base/eudev/pspec.xml @@ -123,7 +123,7 @@ 2016-01-03 3.1.2 - Add rules for mount storage. + Add rules for mount storage, ntfs usb disc too. Ertuğrul Erata ertugrulerata@gmail.com