WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Automount USB rules.d Query  (Read 7266 times)

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11560
Re: Automount USB rules.d Query
« Reply #15 on: December 28, 2021, 02:39:43 PM »
Hi Rabie
... is there a way to automaticlly rename the new attached usb ? like /mnt/myusbstick ?
That would really complicate things. I created  /mnt/MyDisk  and mounted a drive to it. The  MountTool  app did not
display that device or that directory.

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Automount USB rules.d Query
« Reply #16 on: December 28, 2021, 02:49:02 PM »
Hi Rich,

Quote
# If your CD drive or your card reader devices won't automount, try this:
# echo 2000 | sudo tee /sys/module/block/parameters/events_dfl_poll_msecs
If that solves the problem, add it to  bootlocal.sh.

yes that did solve it,  although after removing the sd card, it doesn't delete the /mnt/sd* file automatically, but that isn't a problem.

Quote
That would really complicate things. I created  /mnt/MyDisk  and mounted a drive to it. The  MountTool  app did not
display that device or that directory.

i don't really care if the disk is going to be shown in the mnttool. I know that i wouldn't be able to unmount it with the mnttool.
my goal is just to mount it with the Script like that /mnt/MyDisk automatically.

« Last Edit: December 28, 2021, 03:10:40 PM by Rabie »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11560
Re: Automount USB rules.d Query
« Reply #17 on: December 28, 2021, 03:08:38 PM »
Hi Rabie
If you have a fixed mountpoint (i.e. ~/mnt/MyDisk) and you are only ever mounting one device at a time, it's doable.
If you want to dynamically create and remove devices to custom mountpoints, you will have to keep track of the
names and what is mounted to them.


Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Automount USB rules.d Query
« Reply #18 on: December 28, 2021, 03:13:04 PM »
Hi Rabie
If you have a fixed mountpoint (i.e. ~/mnt/MyDisk) and you are only ever mounting one device at a time, it's doable.
If you want to dynamically create and remove devices to custom mountpoints, you will have to keep track of the
names and what is mounted to them.

ok i think it would be easier to mount in a fixed path like /mnt/MyDisk/$1 (Where /mnt/MyDisk is saved permanent in /opt/.filetool.lst)


and something else, where should i put the mount options in the Script like:
Code: [Select]
mount /dev/$1 -o  iocharset=utf8,codepage=850 /mnt/$1
« Last Edit: December 28, 2021, 03:14:41 PM by Rabie »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11560
Re: Automount USB rules.d Query
« Reply #19 on: December 28, 2021, 05:03:53 PM »
Hi Rabie
... and something else, where should i put the mount options in the Script like: ...
Are you referring to the  automount.sh  script? Then, assuming those options are valid for mounting the file system
type in question, you may have to add some separate entries, for example:

See attached file.

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Automount USB rules.d Query
« Reply #20 on: December 28, 2021, 05:44:44 PM »
Hi Rich,
first i tested the options without the mountpoint "MyDisk" like this:(See Attachment)
it works perfectly

Before:
Code: [Select]
drwxr-xr-x    2 root     root         32768 Dec 28 21:01 t?w/
-rwxr-xr-x    1 root     root             0 Dec 28 21:01 t??t.txt

after:
Code: [Select]
drwxr-xr-x    2 root     root         32768 Dec 28 21:01 tÜw/
-rwxr-xr-x    1 root     root             0 Dec 28 21:01 tööt.txt

as soon as i add MyDisk to the lines, nothing appears in /mnt/MyDisk

and still getting the new drive in /mnt/sd* but empty
Code: [Select]
ls -al /mnt/MyDisk/
total 0
drwxrwxrwx    2 root     staff           40 Dec 28 23:24 ./
drwxr-sr-x    8 root     staff          160 Dec 28 23:29 ../

Code: [Select]
ls -al /mnt/
total 4
drwxr-sr-x    8 root     staff          160 Dec 28 23:29 ./
drwxr-sr-x   17 root     staff          400 Dec 28 23:19 ../
drwxrwxrwx    2 root     staff           40 Dec 28 23:24 MyDisk/
drwxr-sr-x    2 root     staff           40 Dec 28 23:18 sda1/
drwxr-sr-x    2 root     staff           40 Dec 28 23:18 sda2/
drwxr-sr-x    2 root     staff           40 Dec 28 23:18 sda3/
drwxr-xr-x    4 root     root          4096 Dec  8  2020 sdc1/
drwxr-sr-x    2 root     staff           40 Dec 28 23:29 sdd1/      #where this is the new drive but its also empty

« Last Edit: December 30, 2021, 09:53:09 AM by Rich »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11560
Re: Automount USB rules.d Query
« Reply #21 on: December 28, 2021, 09:59:31 PM »
Hi Rabie
Yeah, I missed that. I don't create the individual mountpoints (sda1, sdd1, etc.), the system script  /usr/sbin/rebuildfstab
does that. It defaults to  /mnt. See the attachment for the fix. It will even create the  MyDisk  directory if it does not
exist, so you don't need to back it up.

... yes that did solve it,  although after removing the sd card, it doesn't delete the /mnt/sd* file automatically, but that isn't a problem. ...
Are you sure? The  echo 2000  means those devices only get polled every 2 seconds. So there could be a 2 second delay
before the script gets called again and removes that directory.

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Automount USB rules.d Query
« Reply #22 on: December 29, 2021, 05:27:10 AM »
Hi Rich,

Quote
Yeah, I missed that. I don't create the individual mountpoints (sda1, sdd1, etc.), the system script  /usr/sbin/rebuildfstab
does that. It defaults to  /mnt. See the attachment for the fix. It will even create the  MyDisk  directory if it does not
exist, so you don't need to back it up.
i think there is a bug, that i can't find. i attached the Script after editing it
i already found extra text quote in those two lines:
Code: [Select]
if grep -q "/dev/$MyDev /mnt/MyDisk/"$MyDev" /proc/mounts   #right before  $MyDev
logger "$0 /mnt/MyDisk/"$MyDev" forcibly unmounted"

Anyway, the Script doesn't create MyDisk and even if its already there doesn't mount in it and doesn't mount in /mnt

Code: [Select]
tail -f /tmp/automount.log
11:06:11.%N sdd1 automount.sh started
11:06:11.%N sdd1 Start Action=remove ID_FS_TYPE=vfat
11:06:11.%N sdd1 Queue fixed, PID 13471 removed.
11:06:11.%N sdd1 Arbitration complete.
the log doesn't say anything more than that, when plug in or out

Code: [Select]
ls -al
drwxr-sr-x    7 root     staff          140 Dec 29 10:59 ./
drwxr-sr-x   17 root     staff          400 Dec 29 10:28 ../
drwxr-sr-x    2 root     staff           40 Dec 29 10:28 sda1/
drwxr-sr-x    2 root     staff           40 Dec 29 10:28 sda2/
drwxr-sr-x    2 root     staff           40 Dec 29 10:28 sda3/
drwxr-xr-x    4 root     root          4096 Dec  8  2020 sdc1/
sdd doesn't exist

Quote
Are you sure? The  echo 2000  means those devices only get polled every 2 seconds. So there could be a 2 second delay
before the script gets called again and removes that directory.

yes for sure, but thats happens just with the sd card, the script doesn't do the remove action:
Code: [Select]
tail -f /tmp/automount.log
11:23:25.%N sdb1 automount.sh started
11:23:25.%N sdb1 Start Action=add ID_FS_TYPE=vfat
11:23:25.%N sdb1 Arbitration complete.
11:23:26.%N sdb1 Rebuildfstab
11:23:26.%N sdb1 Mount succeeded.
11:23:27.%N sdb1 Refreshed MountTool
11:23:27.%N sdb1 End.


« Last Edit: December 29, 2021, 05:50:58 AM by Rabie »

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Automount USB rules.d Query
« Reply #23 on: December 29, 2021, 06:03:17 AM »
OMG, never mind
i found the third extra text quote  :P  and it did work
Code: [Select]
ls -al MyDisk/
total 32
drwxrwxrwx    3 root     staff           60 Dec 29 12:14 ./
drwxr-sr-x    9 root     staff          180 Dec 29 12:14 ../
drwxr-xr-x    5 root     root         32768 Jan  1  1970 sdd1/

Edit:
also the sd card its not been redirected to MyDisk
« Last Edit: December 29, 2021, 06:18:11 AM by Rabie »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11560
Re: Automount USB rules.d Query
« Reply #24 on: December 29, 2021, 11:28:07 AM »
Hi Rabie
... i found the third extra text quote  :P  and it did work ...
Well done.

Quote
... also the sd card its not been redirected to MyDisk
Is this still an issue?

Run:
Code: [Select]
udevadm monitor --env > usb.txtPlug in your sd card, unmount it, unplug it.
Attach usb.txt and automount.log to your next post.

If you have syslog running, include the results of:
Code: [Select]
grep automount /var/log/messages

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Automount USB rules.d Query
« Reply #25 on: December 29, 2021, 12:00:44 PM »
Quote
Is this still an issue?
my mistake, its not an issue anymore but this is:

Quote
Are you sure? The  echo 2000  means those devices only get polled every 2 seconds. So there could be a 2 second delay
before the script gets called again and removes that directory.
yes for sure, but thats happens just with the sd card, the script doesn't do the action "remove"

Code: [Select]
tail -f /tmp/automount.log
11:23:25.%N sdb1 automount.sh started
11:23:25.%N sdb1 Start Action=add ID_FS_TYPE=vfat
11:23:25.%N sdb1 Arbitration complete.
11:23:26.%N sdb1 Rebuildfstab
11:23:26.%N sdb1 Mount succeeded.
11:23:27.%N sdb1 Refreshed MountTool
11:23:27.%N sdb1 End.

i didn't unmounted the sd card manualy, because i wanted to see if it removes the sd* after unpluging the sd card.
« Last Edit: December 30, 2021, 09:54:35 AM by Rich »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11560
Re: Automount USB rules.d Query
« Reply #26 on: December 29, 2021, 12:59:07 PM »
Hi Rabie
Before I forget, the copy of the  automount.sh  file you attached to one of your previous posts contained  CRLF
sequences suggesting you have been editing it using Windows. If you insist on editing Linux files under Windows,
then run this command when you copy them back to your Linux machine:
Code: [Select]
dos2unix automount.shThis ensures the file only contains  LF  sequences which some Linux programs might expect.

There are a couple of messages missing in your attachment which is why the directory does not get removed.
The last message in your file  514.559260  corresponds to  6751422.879854  in the sdcard.txt attachment.
The next message  6751424.734325  is the one automount.sh will respond to.

I suspect it may be a firmware issue with your reader. Maybe see if there is an update available. Your firmware
is currently  ID_REVISION=1.00.

My reader had a firmware issue:
7. If you have a Teac All-In-One Multi-Card Reader and it won't recognize anything larger than 2GB, update the firmware to 4.08.

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Automount USB rules.d Query
« Reply #27 on: December 29, 2021, 01:13:48 PM »
Hi Rich,
Quote
Before I forget, the copy of the  automount.sh  file you attached to one of your previous posts contained  CRLF
sequences suggesting you have been editing it using Windows. If you insist on editing Linux files under Windows,
then run this command when you copy them back to your Linux machine:
Code: [Select]
dos2unix automount.sh
This ensures the file only contains  LF  sequences which some Linux programs might expect.
wow, thx for the information


Quote
There are a couple of messages missing in your attachment which is why the directory does not get removed.
The last message in your file  514.559260  corresponds to  6751422.879854  in the sdcard.txt attachment.
The next message  6751424.734325  is the one automount.sh will respond to.

I suspect it may be a firmware issue with your reader. Maybe see if there is an update available. Your firmware
is currently  ID_REVISION=1.00.

My reader had a firmware issue:
Quote from: Rich on November 22, 2019, 10:22:05 PM
7. If you have a Teac All-In-One Multi-Card Reader and it won't recognize anything larger than 2GB, update the firmware to 4.08.
ok i will see that. Its not really a big Problem, i have reached my goal with your help and will use the script from now on.
Thank you very much.  ;D

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11560
Re: Automount USB rules.d Query
« Reply #28 on: December 29, 2021, 01:39:56 PM »
Hi Rabie
You are welcome. :)

Offline Rabie

  • Sr. Member
  • ****
  • Posts: 272
Re: Automount USB rules.d Query
« Reply #29 on: December 29, 2021, 06:03:07 PM »
Hi Rich,
Quote
I suspect it may be a firmware issue with your reader. Maybe see if there is an update available. Your firmware
is currently  ID_REVISION=1.00.
i have been trying to find Information about the firmware, any Tipps how to update ?