Jump to content

automount sda1


1955sergey1955

Recommended Posts

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

 

Link to comment
Share on other sites

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?) 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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

Important Information

Terms of Use - Privacy Policy - Guidelines