I would like to automatically mount a usb disk when I plug it.
I believed udev is the solution, so I created /etc/udev/rules.d/99_extern_hdd.rules that only contains:
ACTION=="add", SUBSYSTEM=="block", ENV{ID_VENDOR_ID}=="1058", ENV{ID_MODEL_ID}=="25a2", RUN+="/etc/mount_extern.sh" The script /etc/mount_extern.sh contains:
#!/bin/bash ls -dl /media > /tmp/output ls -dl /media/data >> /tmp/output echo "mount ${DEVNAME} /media/data" >> /tmp/output mount ${DEVNAME} /media/data >> /tmp/output 2>&1 But when I plug my disk the output ( /tmp/output created by /etc/mount_extern.sh) gives me:
drwxr-xr-x 13 root root 4096 Aug 14 10:47 /media drwxr-xr-x 2 root root 4096 Dec 18 2017 /media/data mount /dev/sde1 /media/data mount: /media/data: permission denied. I don't understand why I have this permission denied. The rights of the folder seem good no? also when I do sudo mount /dev/sde1 /media/data, it works fine
Any idea?
My OS is Linux archlinux 5.8.10-arch1-1 #1 SMP PREEMPT Thu, 17 Sep 2020 18:01:06 +0000 x86_64 GNU/Linux