I want to remove my external HDD as safely as possible.
I want to use umount --lazy:
Lazy unmount. Detach the filesystem from the file hierarchy now, and clean up all references to this filesystem as soon as it is not busy anymore. (Requires kernel 2.4.11 or later.)
Then after a short delay I plan to kill any processes with open files on the device where the filesystem is still quasi-mounted.
- I can't use
lsoffor an accurate list of the open files as the filesystem has become invisible to new processes. - If I use
lsofbeforeumount -l, there is a race contition of a new file being opened in between the two invocations.
Is there any way of finding out which processes are accessing a DEVICE rather than a filesystem?
umount --lazyis not safe and can not be made safe. You can achieve something similar withmount --movebut the best method is still the old-fashioned regularumount.mount --moverequiresmount --make-private /parent-mount-pointwhich has implications.