Created
April 9, 2024 00:54
-
-
Save sant123/6faeac0045e414dc6fdb923052975543 to your computer and use it in GitHub Desktop.
Automount usb devices with systemd and udisks2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mount usb devices with systemd and udisks2 | |
ENV{ID_FS_USAGE}=="filesystem", ENV{UDISKS_FILESYSTEM_SHARED}="1" | |
ACTION=="add", SUBSYSTEMS=="usb", SUBSYSTEM=="block", ENV{ID_FS_USAGE}=="filesystem",\ | |
RUN+="/usr/bin/systemctl --no-block start automount-usb@%k.service" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=Automount USB devices | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/bin/udisksctl mount -b /dev/%i |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Put the contents of 98-automount-usb.rules under /etc/udev/rules.d -> /etc/udev/rules.d/98-automount-usb.rules | |
# Put the contents of automount-usb@.service under /etc/systemd/system -> /etc/systemd/system/automount-usb@.service | |
# In shell execute the following commands | |
sudo udevadm control --reload | |
sudo udevadm trigger | |
sudo systemctl daemon-reload |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sources:
https://wiki.archlinux.org/title/udev#Tips_and_tricks
https://wiki.archlinux.org/title/Udisks#Mount_to_/media