Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to clean-up abandoned mounts #405

Open
enocom opened this issue Nov 8, 2021 · 3 comments
Open

How to clean-up abandoned mounts #405

enocom opened this issue Nov 8, 2021 · 3 comments

Comments

@enocom
Copy link

enocom commented Nov 8, 2021

Let's say a previous run of a program using this library mounted a FUSE instance with fs.Mount but was shutdown with SIGKILL before it could unmount the mount.

Is there a way to unmount abandoned mounts without requiring a user do so manually?

I see that fuse.NewServer attempts to mount and will fail if there is an abandoned mount. Meanwhile, the unmount function is not exported, so a client cannot call it directly.

@hanwen
Copy link
Owner

hanwen commented Nov 8, 2021

I have this script to clean up my connections:

$ cat ~/bin/kill-all-fuse.sh
#!/bin/sh
set -eux

cd /sys/fs/fuse/connections
for f in *; do
  echo $f
  echo hoi > $f/abort
done


for f in $(mount|grep fuse|grep tmp| awk '{print $3;}'); do
  fusermount -u $f
done

I wish I could automate this better, but I don't know how to get connection number from the fuse mount.

@enocom
Copy link
Author

enocom commented Nov 8, 2021

Thanks! That's a handy script. Also, glad I didn't miss anything obvious in the documentation.

How would you feel about exporting unmount (and its Darwin equivalent) in one form or another? Alternatively, perhaps MountOptions could allow a user to request a mount to be cleaned up before attempting to mount again?

@navytux
Copy link
Contributor

navytux commented Jun 14, 2023

but I don't know how to get connection number from the fuse mount

@hanwen, FYI this number is st_dev of corresponding FUSE mountpoint:

https://lab.nexedi.com/nexedi/wendelin.core/blob/63153845/wcfs/__init__.py#L339-343

https://github.com/torvalds/linux/blob/b6dad5178ceaf23f369c3711062ce1f2afc33644/fs/fuse/control.c#L252-L269

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants