Jump to content

Recommended Posts

Posted

Good day!
I can not auto-flush.
The directory is created / deleted when installing / removing the flash.
But the mount does not happen - error 1.

 

/var/log/arbian-hardware-monitor.log


Fri Oct 26 19:51:50 UTC 2018 | Orange Pi Lite | 5.65 | armhf | armv7l | 4.14.78-sunxi


To autoload flash:

/etc/udev/rules.d/20-automount_flash.rules


ACTION=="add" KERNEL=="sd[a-z][0-9]"  RUN+="/bin/mkdir -p /media/%k"
ACTION=="add" KERNEL=="sd[a-z][0-9]"  RUN+="/bin/mount    uid=1000      /dev/%k /media/%k"
ACTION=="remove"  KERNEL=="sd[a-z][0-9]"  RUN+="/bin/rmdir /media/%k"

result in:
/var/log/daemon.log

Process '/bin/mount    uid=1000    /dev/sda1 /media/sda1' failed with exit code 1.

---- error!!

sudo mount /media/sda1 /media/sda1        #    ok!!!!!

 

Why error?


Sergey

 

Posted

Good day, Guidol!
In the examples, uid=1000 is present everywhere (https://habr.com/post/58769/    uid=1000; http://zenux.ru/articles/40/  uid=1000).
I enter under the root. Does not help and UID=0 (if at the entrance uid = 0).
Since it is necessary to do the right thing for a single user with root or without root rights?
Sergey

 

Posted
2 hours ago, 1955sergey1955 said:

Since it is necessary to do the right thing for a single user with root or without root rights?

uid=1000 is only for unix-/linux-filesystem like ext4 and not for FAT/VFAT

 

the mount command doesnt work from udev on my test system, but ther is another command: pmount

- pmount - mount removable devices as normal user

 

So install pmount:

apt install pmount

 

and then change your udev-file /etc/udev/rules.d/20-automount_flash.rules:

ACTION=="add" KERNEL=="sd[a-z][0-9]"  RUN+="/bin/mkdir -p /media/%k"
ACTION=="add" KERNEL=="sd[a-z][0-9]"  RUN+="/usr/bin/pmount /dev/%k /media/%k"
ACTION=="remove" KERNEL=="sd[a-z][0-9]"  RUN+="/bin/rmdir /media/%k"

after that reload the udev-rules with:
 

udevadm control --reload-rules

BUT: be aware to securely umount your USB-Device (Stick?) 

Posted

Good day, Guidol!

Unfortunately the team did not help.
The result is deplorable - the mount does not occur.
In addition, the command rmdir does not work when extracting USB.
Sergey

 

 

Posted
19 minutes ago, 1955sergey1955 said:

The result is deplorable - the mount does not occur.
In addition, the command rmdir does not work when extracting USB.

on my NanoPi Neo2 with armbian it did work with pmount.

maybe you add a chmod 777 for the created directory

 

the rmdir and umount only does work if you are not actively in the directory of the device, because when it is in use you cant rmdir/umount

Posted

Good day, Guidol!

The create directory command mount did not affect the creation / deletion of a directory.

 

ACTION=="add" KERNEL=="sd[a-z][0-9]" RUN+="/bin/mkdir -p /media/%k"

#ACTION=="add" KERNEL=="sd[a-z][0-9]" RUN+="/usr/bin/pmount /dev/%k /media/%k"

ACTION=="remove" KERNEL=="sd[a-z][0-9]" RUN+="/bin/rmdir /media/%k"

Creating a directory always passes.
When you exclude the pmount command, the directory is erased.

 

terminal command:  pmount   /dev/sda1 /media/sda1   - mounting device - ok.

 

Sergey

 

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines