I'm on Linux Mint, which is debian based, but this should also work with debian bookworm.<br>
This is a job for <b>udev service</b>, the extented device manager from systemd.<br>It gets notified by the kernel, if some hardware is plugged in and you can load some extra modules or start some running actions.<br>
But you cant call the low level mount command of the bin folder in udev running action, that would not work and lead to problems.<br>
you need <b>systemd-mount</b> https://manpages.debian.org/bookworm/systemd/systemd-mount.1.en.html, which does the job outside of udev, when udev finsihed executing.

1) check if udev daemon is running ```systemctl list-units *udevd.service```<br>
and check, if you have systemd-mount ```ls /usr/bin/systemd-mount```<br>
2) get the device node/path - manually mount your usb-drive with your file manager, i do it with an USB Stick <br>
open terminal and run command df on a file or directory of the usb drive<br>
```df "filename|directory on your USB drive"```<br>
output:<br>
```
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdf1 3997696 2821980 1175716 71% ...
``` 
now you have the device node/path of your usb drive: <b>/dev/sdf1</b><br>

3) get the Attributes and Environment variables for your device from udev database, needed for a udev rule.<br>
We must exactly identify the device, to which the udev rule shall be applied, because the dev path can change every time you disconnect and connect your USB Drive<br>
```udevadm info /dev/sdf1 ```or<br>
```udevadm info --attribute-walk /dev/sdf1``` detailed<br>
<br>output of first one:
```
P: /devices/pci0000:00/0000:00:09.0/0000:02:00.0/usb8/8-1/8-1:1.0/host6/target6:0:0/6:0:0:0/block/sdf/sdf1
N: sdf1
L: 0
S: disk/by-id/usb-SanDisk_U3_Cruzer_Micro_0000186F6A60343E-0:0-part1
S: disk/by-uuid/3CF6-EEA5
S: disk/by-path/pci-0000:02:00.0-usb-0:1:1.0-scsi-0:0:0:0-part1
S: disk/by-partuuid/e41c7c97-01
E: DEVPATH=/devices/pci0000:00/0000:00:09.0/0000:02:00.0/usb8/8-1/8-1:1.0/host6/target6:0:0/6:0:0:0/block/sdf/sdf1
E: DEVNAME=/dev/sdf1
E: DEVTYPE=partition
E: DISKSEQ=21
E: PARTN=1
E: MAJOR=8
E: MINOR=81
E: SUBSYSTEM=block
E: USEC_INITIALIZED=2220353618
E: ID_VENDOR=SanDisk
E: ID_VENDOR_ENC=SanDisk\x20
E: ID_VENDOR_ID=0781
E: ID_MODEL=U3_Cruzer_Micro
E: ID_MODEL_ENC=U3\x20Cruzer\x20Micro\x20
E: ID_MODEL_ID=5406
E: ID_REVISION=3.21
E: ID_SERIAL=SanDisk_U3_Cruzer_Micro_0000186F6A60343E-0:0
E: ID_SERIAL_SHORT=0000186F6A60343E
E: ID_TYPE=disk
E: ID_INSTANCE=0:0
E: ID_BUS=usb
E: ID_USB_INTERFACES=:080650:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=usb-storage
E: ID_PATH=pci-0000:02:00.0-usb-0:1:1.0-scsi-0:0:0:0
E: ID_PATH_TAG=pci-0000_02_00_0-usb-0_1_1_0-scsi-0_0_0_0
E: ID_PART_TABLE_UUID=e41c7c97
E: ID_PART_TABLE_TYPE=dos
E: ID_DRIVE_THUMB=1
E: ID_FS_UUID=3CF6-EEA5
E: ID_FS_UUID_ENC=3CF6-EEA5
E: ID_FS_VERSION=FAT32
E: ID_FS_TYPE=vfat
E: ID_FS_USAGE=filesystem
E: ID_PART_ENTRY_SCHEME=dos
E: ID_PART_ENTRY_UUID=e41c7c97-01
E: ID_PART_ENTRY_TYPE=0xc
E: ID_PART_ENTRY_NUMBER=1
E: ID_PART_ENTRY_OFFSET=2048
E: ID_PART_ENTRY_SIZE=8011776
E: ID_PART_ENTRY_DISK=8:80
E: DEVLINKS=/dev/disk/by-id/usb-SanDisk_U3_Cruzer_Micro_0000186F6A60343E-0:0-part1 /dev/disk/by-uuid/3CF6-EEA5 /dev/disk/by-path/pci-0000:02:00.0-usb-0:1:1.0-scsi-0:0:0:0-part1 /dev/disk/by-partuuid/e41c7c97-01
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:
```
E: means, this is an environment variable<br>
for my udev rule i use variable <b>ID_FS_UUID=3CF6-EEA5</b> to identify my device<br>
This is the uuid number of the filesystem on my usbstick.<br>

4) write an udev rule and save it to <b>/etc/udev/rules.d</b> directory<br>
rules must be saved with the extension <b>.rules</b><br>udev rules are worked through in a lexicographical order and can overwrite each other, so i use numbers in the beginning of the name.<br>
get root rights -> open file <b>99_myrule.rules</b>

udev rule:<br>
```
ENV{ID_FS_UUID}=="3CF6-EEA5", RUN{program}+="/usr/bin/systemd-mount --no-block --collect $devnode /my/mount/directory/"
```
save it! <br>
ENV{ID_FS_UUID}=="3CF6-EEA5" means<br>
check if the environment variable ID_FS_UUID of the device is equal to 3CF6-EEA5,<br>if so, device identified -> RUN systemd-mount<br>
$devnode ... expands to the device path, udev sets for the device (/dev/...)<br>

The device will be mounted to <b>/my/mount/directory/</b>, be sure, that it exists!<br>
Here is the complete syntax for udev rules: https://www.linux.org/docs/man7/udev.html<br>

5) reload udev rules<br>
```sudo udevadm control --reload-rules```

6) You are ready to disconnect and connect the usb drive and see, if it works!

you can also additionally identify your device by vendor id and product id, but than you need a detailed look at the udev database.<br>
```udevadm info --attribute-walk /dev/sdf1```<br>
i found in SUBSYSTEMS=="usb":
```
ATTRS{idProduct}=="5406"
ATTRS{idVendor}=="0781"
```

udev rule:<br>
```
ATTRS{idVendor}=="0781", ATTRS{idProduct}=="5406", ENV{ID_FS_UUID}=="3CF6-EEA5", RUN{program}+="/usr/bin/systemd-mount --no-block --collect $devnode /my/mount/directory/"
```