After removing a bay mounted SATA connected drive the kernel will most of the time remove the mount. However, sometimes the mount remains even though the disk has been removed. Is there a way to avoid this?


As I ended replied to the original OP, you can always force an unmount with a lazy unmount

umount -l <filesystem|partition>

Nevertheless the thing about lazy umount is that it ignores the pending buffers to be written to that drive.

I would recommend a script a sudo for the user or a group of users that run the app, that only allows to run a script to umount the drive, and that can be invoked by the app. Or even a key on the console programmed to to call a script. (if a physical server)

  • The question then becomes how can I detect whether a mount is a zombie or not so that I know which mount I need to force unmount on. – ronag Nov 20 '15 at 9:54
  • I understand where you are coming from the user taking out the rive, not having admin intervention. Transfer the work of the umount to the user, that is why I am talking about an option in the app. – Rui F Ribeiro Nov 20 '15 at 9:57
  • The application is a business critical application. I still can't have the it failing/being confused due to end-user mistakes. I can of course add an unmount button, however the end-user could still just jank the drive (some users are idiots). I would need a drive bay with some form of software controlled physical lock that the unmount option controls. However, I have not found any such product on the market. – ronag Nov 20 '15 at 10:22
  • Alternatively maybe we should switch to a usb based drive solution. Though we haven't found any USB based drive bays as of yet. – ronag Nov 20 '15 at 10:24

I would not remove the actual drive without unmounting manually the mount point previously.

There are not guarantees the cache will be flushed or even data corruption can ensue otherwise.

One thing is hot mounting something, like a USB disk or a drive, a whole different story is unmounting it.

  • The cache is always flushed prior to removing the disk so there are no problems with data corruption. However, due to end user behaviour it's not possible to guarantee proper unmounting. Everything works fine except that we get zombie mounts every now and then which confuses the application. – ronag Nov 19 '15 at 21:26
  • Who guarantees you that after running sync there are no more writes? – Rui F Ribeiro Nov 19 '15 at 21:27
  • The application makes sure to call sync before the end-user removes the drive. – ronag Nov 19 '15 at 21:35
  • And then you trust the gods there are no more writes afterwards and wonder why often the mount remains there. I am being ironic. – Rui F Ribeiro Nov 19 '15 at 21:36
  • Not sure if you are trying to be insulting or not... The application is the only one writing to the mount and once it's performed sync it does not write anything else. – ronag Nov 19 '15 at 21:38

I'm a person that just registered here for asking exactly the same question and ran in to this while looking for the appropriate categories...:)

It could be so that, since you're writing to a fuse filesystem, and fuse is "filesystem in userespace", there's actually a separate user process running as long as the mount exists. This is just a theory, but I suspect that if this process dies or perhaps hangs, the state of the mount might not be updated properly, even if the disk has been detached.

In any case, it would be easy to test if this behaviour is reproducible by sending SIGKILL to one of these processes.

  • Fuse was never mentioned, although it is possible. Fuse is slow compared to native methods and it is not the best of the ideas to use it in some production system. In fuse, the situation about the pending syncs are worse than I am saying. Most of the hw that you can do hot inserts (namely CPU and disks), are not intended to be taken at random without some housekeeping tasks. If you want normal users/app users to be somewhat independent, better create a sudo authorisation for a script that unmounts the drive, and create a special menu on the app for some users. – Rui F Ribeiro Nov 20 '15 at 8:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.