Hello,
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
{
[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
}
/etc/udev/rules.d/99-local.rules
{
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"
}
and the problem is that
{
sudo systemctl status usb_mount@add.service
}
is always active and to mount usb I need to stop this and when I insert usb is going active and mounting the drive but
{
sudo systemctl status usb_mount@remove.service
}
is always dead - and to unmount the usb I need to start it. And whenever I want to insert next/second usb is not going to mount.
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!!!
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
{
[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
}
/etc/udev/rules.d/99-local.rules
{
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"
}
and the problem is that
{
sudo systemctl status usb_mount@add.service
}
is always active and to mount usb I need to stop this and when I insert usb is going active and mounting the drive but
{
sudo systemctl status usb_mount@remove.service
}
is always dead - and to unmount the usb I need to start it. And whenever I want to insert next/second usb is not going to mount.
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!!!
Statistics: Posted by jager — 2024-09-15 20:34 — Replies 3 — Views 77