Tiny Core Linux

Tiny Core Extensions => TCE Talk => Topic started by: Rabie on December 27, 2021, 08:29:24 AM

Title: Automount USB rules.d Query
Post by: Rabie on December 27, 2021, 08:29:24 AM
Hi,
i already saw the thread http://forum.tinycorelinux.net/index.php/topic,9622.0.html and the scripts working fine.

but i have one problem, how to mount the new attached USB drive not to /mnt/$1 but to other directory
for example to /test/$1 or /mnt/test/$1

this is from my mount script
Code: [Select]
mount /dev/$1 /mnt/$1
what i want is:
Code: [Select]
mount /dev/$1 /mnt/test/$1 or
Code: [Select]
mount /dev/$1 /test/$1
can't find the option there for

Title: Re: Automount USB rules.d Query
Post by: Rich on December 27, 2021, 10:02:12 AM
Hi Rabie
If you are looking for auto mounting, here is the solution I came up with:
http://forum.tinycorelinux.net/index.php/topic,23337.0.html
I've been running it for a couple of years now.
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 27, 2021, 11:41:23 AM
Hi Rabie
If you are looking for auto mounting, here is the solution I came up with:
http://forum.tinycorelinux.net/index.php/topic,23337.0.html
I've been running it for a couple of years now.

Hi Rich,

are u running it on TC 10x_86x ?
Because there are different things in my system (TC 10.1 64x)

$ Path returns this:
Code: [Select]
tc@box:/opt/Scripts$ $ PATH
-sh: /home/tc/.local/bin:/usr/local/sbin:/usr/local/bin:/apps/bin:/usr/sbin:/usr/bin:/sbin:/bin:/etc/sysconfig/tcedir/ondemand: not found

and the date is in:
Code: [Select]
/bin/datein the Script:
Code: [Select]
/usr/local/bin/date "Already changed it"


This is my /etc/udev/rules.d/98-tc.rules: (See Attachments)

I made the Script executable and ran it manualy (after i attached an USB drive), but it gives nothing, not even the log (i changed the log to /tmp/automount.log)

Edit:
I installed ntfs-3g.tcz and checked that those are not running (parted, gdisk, mkfs, or fsck)
Title: Re: Automount USB rules.d Query
Post by: Rich on December 27, 2021, 01:51:46 PM
Hi Rabie
... $ Path returns this: ...
That's the path you see as user  tc.  The path a script launched by udev is different.

Quote
... and the date is in ...
The date as listed is correct. it states:
Code: [Select]
# coreutils version of date is required if sub-second timing is desired.
[ -e /usr/local/bin/date ] && alias date='/usr/local/bin/date'
Using coreutils is optional. This alias only gets set if  /usr/local/bin/date  exists.

Quote
... This is my /etc/udev/rules.d/98-tc.rules ...
After you make changes to udev rules, you need to run:
Code: [Select]
sudo udevadm control --reload-rules
udevadm trigger

Quote
... I made the Script executable and ran it manualy (after i attached an USB drive), ...
You can't run it that way. When udev detects a USB drive getting plugged in, it calls  automount.sh %k  where  %k
is the designation (sda, sdb, sdc, etc.) assigned to your device. It also sets certain environmental variables that
the script test for.
Title: Re: Automount USB rules.d Query
Post by: Rich on December 27, 2021, 02:14:39 PM
Hi Rabie
One more thing. The script auto mounts, it does not auto unmount, no system does. You should always unmount
a device before removing it.

The little icon at the bottom of the screen that looks like a disk drive is the  MountTool.  Single click it to launch it.
When you plug in a USB device,  automount.sh  will update the  MountTool  to display the newly mounted partitions.
After you are done, unmount the partitions. When you unplug the USB device,  automount.sh  will again update the
MountTool  to no longer display your device.
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 27, 2021, 02:31:29 PM
Hi Rabie
One more thing. The script auto mounts, it does not auto unmount, no system does. You should always unmount
a device before removing it.

The little icon at the bottom of the screen that looks like a disk drive is the  MountTool.  Single click it to launch it.
When you plug in a USB device,  automount.sh  will update the  MountTool  to display the newly mounted partitions.
After you are done, unmount the partitions. When you unplug the USB device,  automount.sh  will again update the
MountTool  to no longer display your device.


Hi Rich,
that i understand

but i need to get the Script to work first.

Quote
After you make changes to udev rules, you need to run:
sudo udevadm control --reload-rules
udevadm trigger
i did reload the rules but still no changes.
Code: [Select]
tc@Box:~$ sudo udevadm control --reload-rules&
tc@Box:~$
[1]+  Done                       sudo udevadm control --reload-rules
tc@Box:~$
tc@Box:~$ udevadm trigger
tc@Box:~$


The Script doesn't create the Log so i can see what is going on.
and doesn't mount the USB Drive when i plug in.

Code: [Select]

drwxr-sr-x    6 root     staff          120 Dec 27 23:15 ./
drwxr-sr-x   17 root     staff          400 Dec 27 23:15 ../
drwxr-sr-x    2 root     staff           40 Dec 27 23:15 sda1/
drwxr-sr-x    2 root     staff           40 Dec 27 23:15 sda2/
drwxr-sr-x    2 root     staff           40 Dec 27 23:15 sda3/
drwxr-xr-x    4 root     root          4096 Dec  8  2020 sdc1/
the above listed Drives are already mounted while booting

When i manualy refresh mnttool:
Code: [Select]

drwxr-sr-x    7 root     staff          140 Dec 27 23:29 ./
drwxr-sr-x   17 root     staff          400 Dec 27 23:15 ../
drwxr-sr-x    2 root     staff           40 Dec 27 23:15 sda1/
drwxr-sr-x    2 root     staff           40 Dec 27 23:15 sda2/
drwxr-sr-x    2 root     staff           40 Dec 27 23:15 sda3/
drwxr-xr-x    4 root     root          4096 Dec  8  2020 sdc1/
drwxr-sr-x    2 root     staff           40 Dec 27 23:29 sdd1/

Edit:
do you know if this Possible
Quote
but i have one problem, how to mount the new attached USB drive not to /mnt/$1 but to other directory
for example to /test/$1 or /mnt/test/$1
Title: Re: Automount USB rules.d Query
Post by: Rich on December 27, 2021, 06:19:20 PM
Hi Rabie
In the script, find this line:
Code: [Select]
# ---- End Functions ---- #and change it to this:
See attached file.

This will write a message to what  $DEBUGLOG  is pointing to. You did uncomment the  DEBUGLOG=  line, right?
After you modified  98-tc.rules, you ran a backup on it, right? Otherwise changes will be lost upon rebooting.
The USB device you plug in must be formatted in order to be mounted.

... i did reload the rules but still no changes.
Code: [Select]
tc@Box:~$ sudo udevadm control --reload-rules&
tc@Box:~$
[1]+  Done                       sudo udevadm control --reload-rules
Why did you background (&) that command?

Quote
... do you know if this Possible ...
/etc/fstab, the MountTool app, and any Tinycore scripts involved in mounting default to /mnt. You can create other
mountpoints and and use them if needed:
Code: [Select]
mkdir -p stuff/i/like
Code: [Select]
sudo mount /dev/sdd1 stuff/i/like
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 28, 2021, 03:30:25 AM
Hi Rich,

Quote
In the script, find this line:
# ---- End Functions ---- #
and change it to this:
See attached file.

i did that (See Attachment)

Quote
You did uncomment the  DEBUGLOG=  line, right?
Yes!
Quote
After you modified  98-tc.rules, you ran a backup on it, right? Otherwise changes will be lost upon rebooting.
i did that also saved in /opt/.filetool.lst
Quote
Why did you background (&) that command?
Code: [Select]
nano /opt/.filetool.lst
/etc/udev/rules.d/98-tc.rules
in bootlocal did put the reload command and copied the line to test, i didn't mean to background it, but it doesn't give any feedback anyway

Code: [Select]
tc@box:~$ sudo udevadm control --reload-rules
tc@box:~$ udevadm trigger
tc@box:~$


Code: [Select]
nano /opt/bootlocal.sh
sudo udevadm control --reload-rules&

Quote
The USB device you plug in must be formatted in order to be mounted.
i don't think so, because with my old script it did work without formatting it,  but i formated it now to test and nothing happens  :-\

Edit:

when i remove the ENV from "/etc/udev/rules.d/98-tc.rules"
Code: [Select]
ENV{ID_FS_TYPE}=="?*" maybe i need to export it as an environment variable ?

the script do create the log:
Code: [Select]
tail -f /tmp/automount.log
12:41:25.%N sdb1 automount.sh started
12:41:25.%N sdb automount.sh started
12:41:53.%N sdb automount.sh started
12:41:53.%N sdb1 automount.sh started
12:43:27.%N sdb1 automount.sh started
12:43:27.%N sdb automount.sh started
12:43:34.%N sdb automount.sh started
12:43:34.%N sdb1 automount.sh started

but sdb doesn't appear in /mnt
Code: [Select]

total 4
drwxr-sr-x    6 root     staff          120 Dec 28 12:37 ./
drwxr-sr-x   17 root     staff          400 Dec 28 12:06 ../
drwxr-sr-x    2 root     staff           40 Dec 28 12:06 sda1/
drwxr-sr-x    2 root     staff           40 Dec 28 12:06 sda2/
drwxr-sr-x    2 root     staff           40 Dec 28 12:06 sda3/
drwxr-xr-x    4 root     root          4096 Dec  8  2020 sdd1/
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 28, 2021, 04:10:04 AM
Code: [Select]
udevadm monitor --env
Title: Re: Automount USB rules.d Query
Post by: Rich on December 28, 2021, 08:11:20 AM
Hi Rabie
...
Code: [Select]
nano /opt/bootlocal.sh
sudo udevadm control --reload-rules&
...
I guess by that you mean you are backgrounding that command in  bootlocal.sh.
If you want to run that command on startup, place it in  bootsync.sh  before it calls  bootlocal.sh  and do not
background it.

Quote
Quote
... The USB device you plug in must be formatted in order to be mounted.
i don't think so, because with my old script it did work without formatting it,  but i formated it now to test and nothing happens  :-\ ...
An unformatted device will still be detected by  udev , but it can not be mounted. Most USB storage devices come
pre-formatted. If the mount command can not recognize the file system type (fat, ntfs, ext3, etc.) it can not mount it.


Quote
... when i remove the ENV from "/etc/udev/rules.d/98-tc.rules"
Code: [Select]
ENV{ID_FS_TYPE}=="?*" maybe i need to export it as an environment variable ? ...
Why would you remove that? udev sets the  ID_FS_TYPE  environment variable. The 98-tc.rules you attached in
reply #2 is correct.

Quote
... the script do create the log: ...
Good, that means udev is detecting a device and finding the script.

Attached is a file that shows what the result of  udevadm monitor --env  should look like.  The sections
containing  ID_FS_TYPE  are the ones  automount.sh  responds to.

It's also possible you need to install  udev-extra.
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 28, 2021, 08:21:34 AM
Quote
Why would you remove that? udev sets the  ID_FS_TYPE  environment variable. The 98-tc.rules you attached in
reply #2 is correct.

i removed it just as a test.

Quote
An unformatted device will still be detected by  udev , but it can not be mounted. Most USB storage devices come
pre-formatted. If the mount command can not recognize the file system type (fat, ntfs, ext3, etc.) it can not mount it.

i formatted the USB Storage on Windows as FAT32
the Script still not creating the log and doesn't mount the USB Drive

Quote
... the script do create the log: ...
Good, that means udev is detecting a device and finding the script.
the Log is been created just when i remove ENV{ID_FS_TYPE}=="?*"
Title: Re: Automount USB rules.d Query
Post by: Rich on December 28, 2021, 08:28:51 AM
Hi Rabie
... the Log is been created just when i remove ENV{ID_FS_TYPE}=="?*"
Yes, that is by design:
Code: [Select]
# If the device is a disk as opposed to a partition (i.e. sda instead of sda1), an
# extended partition, has no partion table, or is unformatted, then FSTYPE is empty
# and we exit.
[ -z "$FSTYPE" ] && exit
If the variable is not set, we don't have enough information to proceed.

See if installing  udev-extra  helps.
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 28, 2021, 08:45:30 AM
Quote
If the variable is not set, we don't have enough information to proceed.
i see

Quote
See if installing  udev-extra  helps.

yes that did it  :) :)

Code: [Select]
tail -f /tmp/automount.log
17:36:07.%N sdd1 automount.sh started
17:36:07.%N sdd1 Start Action=add ID_FS_TYPE=vfat
17:36:07.%N sdd1 Arbitration complete.
17:36:09.%N sdd1 Rebuildfstab
17:36:09.%N sdd1 Mount succeeded.
17:36:09.%N sdd1 Refreshed MountTool
17:36:09.%N sdd1 End.
17:37:17.%N sdd1 automount.sh started
17:37:17.%N sdd1 Start Action=remove ID_FS_TYPE=vfat
17:37:17.%N sdd1 Arbitration complete.
17:37:17.%N sdd1 Forcibly unmounted.
17:37:17.%N sdd1 Removed.
17:37:18.%N sdd1 Rebuildfstab.
17:37:18.%N sdd1 End.

added
Code: [Select]
drwxr-sr-x    7 root     staff          140 Dec 28 17:36 ./
drwxr-sr-x   17 root     staff          400 Dec 28 17:33 ../
drwxr-sr-x    2 root     staff           40 Dec 28 17:32 sda1/
drwxr-sr-x    2 root     staff           40 Dec 28 17:32 sda2/
drwxr-sr-x    2 root     staff           40 Dec 28 17:32 sda3/
drwxr-xr-x    4 root     root          4096 Dec  8  2020 sdc1/
drwxrwxrwx    4 root     root         32768 Jan  1  1970 sdd1/

removed
Code: [Select]
drwxr-sr-x    6 root     staff          120 Dec 28 17:37 ./
drwxr-sr-x   17 root     staff          400 Dec 28 17:33 ../
drwxr-sr-x    2 root     staff           40 Dec 28 17:32 sda1/
drwxr-sr-x    2 root     staff           40 Dec 28 17:32 sda2/
drwxr-sr-x    2 root     staff           40 Dec 28 17:32 sda3/
drwxr-xr-x    4 root     root          4096 Dec  8  2020 sdc1/

thank you very much

now i have just a little question

is there a way to automaticlly rename the new attached usb ? like /mnt/myusbstick ?
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 28, 2021, 09:28:26 AM
also my device has an SD/SDHC/SDXC slot, but it doesn't seem to be recognized by the script.
i tested it with mnttool maualy to be sure that the sd card works:

before:
Code: [Select]
fdisk -l
Disk /dev/sda: 466 GB, 500107862016 bytes, 976773168 sectors
60801 cylinders, 255 heads, 63 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/sda1 *  0,32,33     6,127,57          2048     104447     102400 50.0M  7 HPFS/NTFS
/dev/sda2    6,127,58    1023,254,63     104448  975694715  975590268  465G  7 HPFS/NTFS
/dev/sda3    1023,254,63 1023,254,63  975695872  976769023    1073152  524M 27 Unknown
Disk /dev/sdc: 3727 MB, 3908042752 bytes, 7632896 sectors
9912 cylinders, 55 heads, 14 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/sdc1 *  0,1,1       1017,54,14          62    7632895    7632834 3726M 83 Linux



after:

Code: [Select]
fdisk -l
Disk /dev/sda: 466 GB, 500107862016 bytes, 976773168 sectors
60801 cylinders, 255 heads, 63 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/sda1 *  0,32,33     6,127,57          2048     104447     102400 50.0M  7 HPFS/NTFS
/dev/sda2    6,127,58    1023,254,63     104448  975694715  975590268  465G  7 HPFS/NTFS
/dev/sda3    1023,254,63 1023,254,63  975695872  976769023    1073152  524M 27 Unknown
Disk /dev/sdb: 15 GB, 15980298240 bytes, 31211520 sectors
1942 cylinders, 255 heads, 63 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/sdb1    0,130,3     1023,254,63       8192   31211519   31203328 14.8G  c Win95 FAT32 (LBA)
Disk /dev/sdc: 3727 MB, 3908042752 bytes, 7632896 sectors
9912 cylinders, 55 heads, 14 sectors/track
Units: sectors of 1 * 512 = 512 bytes

Device  Boot StartCHS    EndCHS        StartLBA     EndLBA    Sectors  Size Id Type
/dev/sdc1 *  0,1,1       1017,54,14          62    7632895    7632834 3726M 83 Linux

where sdb is the sd card
is there somthing i can do ?

Title: Re: Automount USB rules.d Query
Post by: Rich on December 28, 2021, 11:21:23 AM
Hi Rabie
also my device has an SD/SDHC/SDXC slot, but it doesn't seem to be recognized by the script. ...
From the comments at the top of the script:
Code: [Select]
# 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.
Title: Re: Automount USB rules.d Query
Post by: Rich on December 28, 2021, 11:39:43 AM
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.
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 28, 2021, 11:49:02 AM
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.

Title: Re: Automount USB rules.d Query
Post by: Rich on December 28, 2021, 12: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.

Title: Re: Automount USB rules.d Query
Post by: Rabie on December 28, 2021, 12: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
Title: Re: Automount USB rules.d Query
Post by: Rich on December 28, 2021, 02: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.
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 28, 2021, 02: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

Title: Re: Automount USB rules.d Query
Post by: Rich on December 28, 2021, 06: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.
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 29, 2021, 02: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.


Title: Re: Automount USB rules.d Query
Post by: Rabie on December 29, 2021, 03: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
Title: Re: Automount USB rules.d Query
Post by: Rich on December 29, 2021, 08: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
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 29, 2021, 09:00:44 AM
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.
Title: Re: Automount USB rules.d Query
Post by: Rich on December 29, 2021, 09:59:07 AM
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.
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 29, 2021, 10:13:48 AM
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
Title: Re: Automount USB rules.d Query
Post by: Rich on December 29, 2021, 10:39:56 AM
Hi Rabie
You are welcome. :)
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 29, 2021, 03: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 ?
Title: Re: Automount USB rules.d Query
Post by: Rich on December 29, 2021, 09:04:14 PM
Hi Rabie
Searching the site your computer is made by might be a good place to search for firmware.
No luck on the firmware yet, but there might be another way.

The vendor ID : product ID for your reader is 0bda:0153.
A search on that returns  Realtek 3-in-1 (SD/SDHC/SDXC) Card Reader.

If you are running TC11 or higher, your reader should be supported by the ums-realtek driver.
To see if the driver supports your card, run:
Code: [Select]
modinfo ums_realtekYou should see a line that matches this:
Quote
alias:          usb:v0BDAp0153d*dc*dsc*dp*ic*isc*ip*in*

If you get a match, we can try altering a driver parameter. Item 3 looks interesting:
Code: [Select]
parm:           ss_delay:seconds to delay before entering selective suspend
parm:           ss_en:enable selective suspend
parm:           auto_delink_en:auto delink mode (0=firmware, 1=software [default])

Unload then reload the driver with altered parameter:
Code: [Select]
sudo modprobe -r ums_realtek
sudo modprobe -v ums_realtek auto_delink_en=0

Test inserting, unmounting, and removing the SD card.
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 30, 2021, 02:25:24 AM
Hi Rich,
Quote
If you are running TC11 or higher, your reader should be supported by the ums-realtek drive

i am running TC10.1 but tried your suggestion anyway and no luck:
Code: [Select]
modinfo ums_realtek
filename:       /lib/modules/4.19.10-tinycore64/kernel/drivers/usb/storage/ums-realtek.ko.gz
author:         wwang <wei_wang@realsil.com.cn>
description:    Driver for Realtek USB Card Reader
license:        GPL
parm:           ss_delay:seconds to delay before entering selective suspend
parm:           ss_en:enable selective suspend
parm:           auto_delink_en:enable auto delink
alias:          usb:v0BDAp0184d*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v0BDAp0177d*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v0BDAp0159d*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v0BDAp0158d*dc*dsc*dp*ic*isc*ip*in*
alias:          usb:v0BDAp0138d*dc*dsc*dp*ic*isc*ip*in*
depends:
intree:         Y
vermagic:       4.19.10-tinycore64 SMP mod_unload

Code: [Select]
tc@box:~$ sudo modprobe -r ums_realtek
tc@box:~$
tc@box:~$ sudo modprobe -v ums_realtek auto_delink_en=0

Quote
Test inserting, unmounting, and removing the SD card.
i just need that UDEV detect it, when someone remove the sd card and the rest will the automount script do
Title: Re: Automount USB rules.d Query
Post by: Rich on December 30, 2021, 06:50:03 AM
Hi Rabie
And in order for UDEV to detect it, the card reader needs to supply it.

The driver under TC10 does not support your reader. I thought you had TC11 or TC12 running.

By the way, you should not be quoting entire posts in your replies. If you are responding to a particular part of a
post, you can quote just that part if you feel it is necessary.
Title: Re: Automount USB rules.d Query
Post by: Rabie on December 30, 2021, 06:55:25 AM
Hi Rich,
Quote
And in order for UDEV to detect it, the card reader needs to supply it.

The driver under TC10 does not support your reader. I thought you had TC11 or TC12 running
ok then like i said before in the other thread, i have to wait until TC13 is released, so i can upgrade my whole system.

Quote
By the way, you should not be quoting entire posts in your replies. If you are responding to a particular part of a
post, you can quote just that part if you feel it is necessary.
that was an accident   ;D
Title: Re: Automount USB rules.d Query
Post by: Rich on December 30, 2021, 06:59:23 AM
Hi Rabie
... that was an accident   ;D
Repairs have been made.  :)