Sample Header Ad - 728x90

Using rm --one-file-system to only delete files on the local filesystem

1 vote
1 answer
2086 views
I have a FUSE mount located in /media/writable, however, sometimes this FUSE mount disconnects, but some programs will still attempt to write to /media/writable. When I restart the FUSE mount service, it will fail to mount because the directory is non-empty. How can I use rm's --one-file-system argument to ensure that when I rm /media/writable, it will only delete files located on the **local** filesystem, as opposed to the **fuse mounted** filesystem? There are other folders located in /media/ so I am unable to run rm in the parent folder. Am I better off moving the folder one layer down (eg. /media/writable/mount) so I can rm the parent folder, or is there a way of selecting which filesystem I wish to delete from? I'm running Ubuntu 18.04.1 LTS with coreutils 8.28. Edit: My current method is this, but I'd like to see if there's a better way to do it: ExecStartPre=-/bin/mountpoint /media/writable/ || /usr/bin/stat /media/writable/MOUNTED || /bin/rm/ --one-file-system -rf /media/writable/*
Asked by Connor Bell (23 rep)
Mar 9, 2019, 01:27 PM
Last activity: Jun 16, 2025, 06:02 PM