You are not logged in.
Pages: 1
Hi Archers, my currently occurred problem is, that my external usb-drive does not get mounted via udev rule, and it is only mountable manually by command which refers to /etc/fstab.
(sudo mount /mnt/disk)
/etc/udev/rules.d/11-mnt-auto-mount.rules
# KERNEL=="sr[0-9]", GOTO="mnt_cd_dvd"
KERNEL!="sd[a-z][0-9]", GOTO="mnt_auto_mount_end"# Global mount options
ACTION=="add", ENV{mount_options}="relatime,noexec"
# Filesystem-specific mount options
ACTION=="add", IMPORT{program}="/sbin/blkid -o udev -p %N"
ACTION=="add", ENV{ID_FS_TYPE}=="vfat|ntfs-3g", ENV{mount_options}="$env{mount_options},utf8,uid=1000,gid=100,umask=002,fmask=133,dmask=002"# selfmade exceptions
# get ATTRS{serial} by: udevadm info -a -n /dev/sdd | grep serial
# 4tb
ATTRS{serial}=="504C323332314C4147335248524A", ENV{mount_dir_number}="", GOTO="mnt_mybook"
# 2tb
ATTRS{serial}=="5743415A4130383931303733", ENV{mount_dir_number}="2", GOTO="mnt_mybook"
# 1tb
ATTRS{serial}=="57442D574341534A30373931373935", ENV{mount_dir_number}="3", GOTO="mnt_mybook"
ATTRS{serial}=="09212B50E0F219A3", ENV{mount_dir_number}="2", GOTO="mnt_kingston_datatraveler"
ATTRS{serial}=="AA010216131916344754", ENV{mount_dir_number}="", GOTO="mnt_sandisk_extreme"
GOTO="mnt_auto_mount_end"# Mount under /mnt and create the symbolic link in /mnt
ACTION=="add", RUN+="/bin/mkdir -p /mnt/%k", RUN+="/bin/mount -o $env{mount_options} /dev/%k /mnt/%k"# Clean up after removal
ACTION=="remove", RUN+="/bin/rm -f /media/usbhd-%k", RUN+="/bin/umount -l /mnt/%k", RUN+="/bin/rmdir /mnt/%k"
GOTO="mnt_auto_mount_end"LABEL="mnt_mybook"
SYMLINK="mybook$env{mount_dir_number}", GROUP="storage"
ACTION=="add", RUN+="/bin/mkdir /mnt/disk$env{mount_dir_number}"
ACTION=="add", RUN+="/bin/mount -o rw,nosuid,nodev,noexec,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 /dev/%k /mnt/disk$env{mount_dir_number}"
ACTION=="remove", RUN+="/bin/umount -l /mnt/disk$env{mount_dir_number}"
ACTION=="remove", RUN+="/bin/rmdir /mnt/disk$env{mount_dir_number}"GOTO="mnt_auto_mount_end"
LABEL="mnt_kingston_datatraveler"
SYMLINK="usbstick$env{mount_dir_number}", GROUP="storage"
ACTION=="add", RUN+="/bin/mkdir -p /mnt/usbstick$env{mount_dir_number}", RUN+="/bin/mount /mnt/usbstick$env{mount_dir_number}"
ACTION=="remove", RUN+="/bin/umount -l /mnt/usbstick$env{mount_dir_number}", RUN+="/bin/rmdir /mnt/usbstick$env{mount_dir_number}"
GOTO="mnt_auto_mount_end"LABEL="mnt_sandisk_extreme"
SYMLINK="usbstick$env{mount_dir_number}", GROUP="storage"
ACTION=="add", RUN+="/bin/mkdir -p /mnt/usbstick$env{mount_dir_number}", RUN+="/bin/mount /mnt/usbstick$env{mount_dir_number}"
ACTION=="remove", RUN+="/bin/umount -l /mnt/usbstick$env{mount_dir_number}", RUN+="/bin/rmdir /mnt/usbstick$env{mount_dir_number}"
GOTO="mnt_auto_mount_end"# Exit
LABEL="mnt_auto_mount_end"
My /etc/fstab looks like:
#
# /etc/fstab: static file system information
#
# <file system> <dir> <type> <options> <dump> <pass>
# /dev/sdc6
UUID=46554740-f8b3-493f-af76-f9903c358856 / ext4 rw,noatime,nodiratime,data=ordered,discard 0 1# /dev/sdc5
UUID=322d0093-c25c-4520-a3f0-411315234073 /boot ext2 rw,noatime,nodiratime,discard 0 2/dev/disk/by-id/ata-WDC_WD30EZRX-00DC0B0_WD-WMC1T2051374-part4 /var/cache/pacman ext4 rw,noatime 0 2
/dev/disk/by-id/ata-WDC_WD30EZRX-00DC0B0_WD-WMC1T2051374-part5 /home ext4 defaults 0 2/dev/disk/by-id/ata-WDC_WD30EZRX-00DC0B0_WD-WMC1T2051374-part3 /mnt/data ext4 defaults,users,noexec 0 2
/dev/disk/by-id/ata-WDC_WD30EZRX-00DC0B0_WD-WMC1T2051374-part2 /mnt/wineprefiix ext4 defaults,users,noexec 0 2
/dev/disk/by-id/ata-WDC_WD30EZRX-00DC0B0_WD-WMC1T2051374-part6 /mnt/tempswap ext4 defaults,users,noexec 0 2
/dev/disk/by-id/ata-WDC_WD30EZRX-00DC0B0_WD-WMC1T2051374-part7 /mnt/vm ext4 defaults,users,noexec 0 2/dev/disk/by-id/ata-WDC_WD30EZRX-00DC0B0_WD-WMC1T2051374-part1 /mnt/backup ext4 defaults,users,exec 0 2
/dev/disk/by-id/usb-WD_My_Book_1140_504C323332314C4147335248524A-0:0-part1 /mnt/disk ntfs-3g noatime,nodiratime,uid=1000,gid=users,umask=0022,fmask=133,dmask=002,auto,users 0 0
/dev/disk/by-id/ata-WDC_WD20EARS-00MVWB0_WD-WCAZA0891073-part1 /mnt/disk2 ntfs-3g noatime,noexec,uid=1000,gid=users,umask=0022,fmask=113,dmask=002,noauto,users 0 0
/dev/disk/by-id/ata-WDC_WD10EACS-00ZJB0_WD-WCASJ0791795-part1 /mnt/disk3 ntfs-3g noatime,noexec,uid=1000,gid=users,umask=0022,fmask=113,dmask=002,noauto,users 0 0# data traveller
/dev/disk/by-id/usb-Kingston_DataTraveler_II+_09212B50E0F219A3-0:0-part1 /mnt/usbstick2 vfat noatime,defaults,noexec,noauto,uid=1000,gid=users,umask=0022,fmask=133,dmask=002,users 0 0
# sandisk extreme
/dev/disk/by-id/usb-SanDisk_Extreme_AA010216131916344754-0:0-part1 /mnt/usbstick ntfs-3g noatime,defaults,noexec,noauto,uid=1000,gid=users,umask=0022,fmask=133,dmask=002,users 0 0
I tried to add additional mount and umount commands in that udev rule, without positive result.
plug in
ls -lh /mnt/ ; ls -lh /mnt/
ls: Zugriff auf /mnt/disk nicht möglich: Der Socket ist nicht verbunden
insgesamt 44K
d????????? ? ? ? ? ? disk
drwxr-xr-x 3 root root 4,0K 24. Mär 13:48 tempswap
drwxr-xr-x 3 root root 4,0K 11. Mai 17:02 vm
umount /mnt/disk ; mount /mnt/disk
[...]
drwxrwxr-x 1 johnd users 4096 5. Mai 22:17 disk
Does anyone has an idea why automount does not do what it should (and did before switched to systemd)??
Thanks
JD
Offline
Wow... that's long. ![]()
My advice would be to stop abusing udev, it's not meant to be used for stuff like that. Use a udisks-based solution, there are many to choose from.
Offline
ACTION=="add", RUN+="/bin/mkdir /mnt/disk$env{mount_dir_number}"
ACTION=="add", RUN+="/bin/mount -o rw,nosuid,nodev,noexec,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 /dev/%k /mnt/disk$env{mount_dir_number}"
I would use instead e.g.:
RUN+="/root/bin/mymount %k $env{mount_dir_number}"And that will make debugging your mymount script a lot easier ![]()
Don't forget to chmod 700 mymount.
Offline
Thanks, but i don't have mymount.
tomks suggestion solved my problem, i changed the udev rule like this:
[...]
LABEL="mnt_mybook"
SYMLINK="mybook$env{mount_dir_number}", GROUP="storage"
ACTION=="add", RUN+="/bin/mkdir /mnt/disk$env{mount_dir_number}"
#ACTION=="add", RUN+="/bin/mount -o rw,nosuid,nodev,noexec,noatime,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096 /dev/%k /mnt/disk$env{mount_dir_number}"
ACTION=="add", RUN+="/usr/bin/udisksctl mount -b /dev/mybook"
ACTION=="remove", RUN+="/bin/umount -l /mnt/disk$env{mount_dir_number}"
ACTION=="remove", RUN+="/bin/rmdir /mnt/disk$env{mount_dir_number}"GOTO="mnt_auto_mount_end"
[...]
This also uses the settings from /etc/fstab.
Offline
ROFL.... not what I meant at all, but I guess you're happy. ![]()
My point is that you don't need specific udev rules for this stuff, you just install and run some udisks-based app e.g. udiskie.
Offline
don't have mymount
I meant that you would *create* it, containing those 2 commands: mkdir and mount.
Offline
Pages: 1