Skip to content

Instantly share code, notes, and snippets.

@eib
eib / 85-external-drive-rule.rules
Last active May 23, 2024 16:51
How to automatically mount/unmount an external USB hard drive
# File: /etc/udev/rules.d/85-external-drive-rule.rules
# Rules for auto-mounting/unmounting USB drives
ACTION=="add", ENV{ID_MODEL}=="USB_to_ATA_ATAPI_bridge", ENV{ID_VENDOR_ID}=="152d", ENV{ID_MODEL_ID}=="2338", RUN+="/usr/local/bin/automount.sh"
ACTION=="remove", ENV{ID_MODEL}=="USB_to_ATA_ATAPI_bridge", ENV{ID_VENDOR_ID}=="152d", ENV{ID_MODEL_ID}=="2338", RUN+="/usr/local/bin/unmount.sh"
# Notes:
# To detect your own drive's ID_MODEL, ID_MODEL_ID, and ID_VENDOR_ID, run "udevadm monitor --environment --udev" before plugging/unplugging the drive
# To force udev to reload these rules (without reboot), run "udevadm control --reload-rules" and "udevadm trigger"
# To change udev's logging level (written to /var/log/syslog), you can run "udevadm control --log-priority=info" (or debug), or configure it via /etc/udev/udev.conf
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.