I need yours help after spending 2 whole days to try configuring usb automount.
I run net install Debian 12 and with only dwm window manager.
What I try to achieve is to automount usb drives just after insertion. I found a lot of resources but nothing worked for me.
I wrote a bash script which works fine when I run it manually - means when I insert usb and run script it is mounted and when I run it with different parameter is unmounted.
I found this : https://www.baeldung.com/linux/automount-usb-device - but it did not work.
and this - https://andreafortuna.org//2019/06/26/a ... d-systemd/ which is faulty.
but I made some changes according the latter example and this looks like this:
/etc/systemd/system/usb-mount@.service
Code: Select all
[Unit]
Description=Mount USB Drive on %i
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/usb_mount.sh %i
ExecStop=/usr/local/bin/usb_mount.sh %i
[Install]
WantedBy=multi-user.target
Code: Select all
KERNEL=="sd[a-z][0-9]", SUBSYSTEMS=="usb", ACTION=="add", RUN+="/bin/systemctl start usb_mount@add.service"
KERNEL=="sd[a-z][0-9]", SUBSYSTEMS=="usb", ACTION=="remove", RUN+="/bin/systemctl stop usb_mount@remove.service"
Code: Select all
sudo systemctl status usb_mount@add.service
Code: Select all
sudo systemctl status usb_mount@remove.service
Is there anyone who knows hot to configure above solution to be correct one - because I did something wron but no Idea how fix this.
Thank you in advance!!!