2

I was wondering if there was a way to register a callback with the system so that when a user attached an external drive my callback is called and I can then proceed to manually mount the disk.

What I'm doing currently is putting a default entry into /etc/fstab with nofail on, this way if the drive is inserted before boot it will be automatically mounted. What'd I'd rather do though is allow the drive to be inserted at anytime, and have it automounted by the system.

Is there a way to do this without polling lsblk in a loop?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232
John Allard
  • 1,368
  • 4
    You're probably looking for udev rules, several are described in the following question: http://unix.stackexchange.com/questions/44454/how-to-mount-removable-media-in-media-label-automatically-when-inserted-with – grochmal Jul 27 '16 at 00:58
  • That seems like exactly what I was looking for, thanks! – John Allard Jul 27 '16 at 01:03

1 Answers1

0

Monitor using udevadm for subsystem block and id_type as cd .With the actions we can check the change / add / remove

Udaya
  • 171