Unmounting and remounting an external disk on reconnect
by poisonborz from LinuxQuestions.org on (#5974A)
I have a server, from which I host a few directories on an external hdd. I'd like to just yank out the disk any time I want (it's why it is external) without any prior preparation.
- on dismount: force unmount and remove the mount point, whatever process uses it
- on mount: mount it again
Is dismount like this possible without crashing my server?
I tried to write udev usb mount rules plus shell scripts (on add and remove), but:
- for remove/dismount, a umount -l does not work and the syslog just log disk errors whenever I try to to access the drive
- for add, mounting doesn't seem to work from the shell script. Yet after typing the command manually the mount occurs properly.
Is there a better strategy for this?


- on dismount: force unmount and remove the mount point, whatever process uses it
- on mount: mount it again
Is dismount like this possible without crashing my server?
I tried to write udev usb mount rules plus shell scripts (on add and remove), but:
- for remove/dismount, a umount -l does not work and the syslog just log disk errors whenever I try to to access the drive
- for add, mounting doesn't seem to work from the shell script. Yet after typing the command manually the mount occurs properly.
Is there a better strategy for this?