kjo*_*kjo 5 filesystems mount fuse rm files
我尝试过的一切(总是具有超级用户权限)都失败了:
# rm -rf /path/to/undeletable
rm: cannot remove ‘/path/to/undeletable’: Is a directory
# rmdir /path/to/undeletable
rmdir: failed to remove ‘/path/to/undeletable’: Device or resource busy
# lsof +D /path/to/undeletable
lsof: WARNING: can't stat(/path/to/undeletable): Permission denied
lsof 4.86
latest revision: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/
latest FAQ: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ
latest man page: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/lsof_man
usage: [-?abhKlnNoOPRtUvVX] [+|-c c] [+|-d s] [+D D] [+|-f[gG]] [+|-e s]
[-F [f]] [-g [s]] [-i [i]] [+|-L [l]] [+m [m]] [+|-M] [-o [o]] [-p s]
[+|-r [t]] [-s [p:s]] [-S [t]] [-T [t]] [-u s] [+|-w] [-x [fl]] [--] [names]
Use the ``-h'' option to get more help information.
Run Code Online (Sandbox Code Playgroud)
当我在没有超级用户权限的情况下尝试上述任何一项时,结果基本相同。唯一的区别是来自lsof命令的初始 WARNING 消息具有Input/output error而不是Permission denied。(这个微小的差异本身已经足够令人费解了,但是,无论如何......)
我怎样才能抹掉这个目录?
Run Code Online (Sandbox Code Playgroud)# rm -rf /path/to/undeletable rm: cannot remove ‘/path/to/undeletable’: Is a directory
rm调用stat(2)以检查/path/to/undeletable是目录(由 删除rmdir(2))还是文件(由 删除unlink(2)。由于stat调用失败(稍后我们将看到原因),rm决定使用unlink,这解释了错误消息。
Run Code Online (Sandbox Code Playgroud)# rmdir /path/to/undeletable rmdir: failed to remove ‘/path/to/undeletable’: Device or resource busy
“设备或资源繁忙”,而不是“目录非空”。所以问题是该目录被某些东西使用,而不是它包含文件。最明显的“被某物使用”是它是一个挂载点。
Run Code Online (Sandbox Code Playgroud)# lsof +D /path/to/undeletable lsof: WARNING: can't stat(/path/to/undeletable): Permission denied
这证实了stat对目录的失败。为什么root会没有权限?这是 FUSE 的一个限制:除非使用allow_other选项挂载,否则FUSE 文件系统只能由与提供 FUSE 驱动程序的进程具有相同用户 ID 的进程访问。甚至 root 也受到了打击。
所以你有一个由非 root 用户挂载的 FUSE 文件系统。你想让我做什么?
很可能您只是对该目录感到恼火并想卸载它。根可以做到这一点。
umount /path/to/undeletable
Run Code Online (Sandbox Code Playgroud)如果您想摆脱挂载点但保留挂载,请使用 移动它mount --move。(仅限 Linux)
mkdir /elsewhere/undeletable
chown bob /elsewhere/undeletable
mount --move /path/to/undeletable /elsewhere/undeletable
mail bob -s 'I moved your mount point'
Run Code Online (Sandbox Code Playgroud)如果要删除该文件系统上的文件,请使用su或任何其他方法切换到该用户,然后删除这些文件。
su bob -c 'rm -rf /path/to/undeletable'
Run Code Online (Sandbox Code Playgroud)如果您想在不中断挂载的情况下删除被挂载点隐藏的文件,请创建另一个没有挂载点的视图并从那里删除文件。(仅限 Linux)
mount --bind /path/to /mnt
rm -rf /mnt/undeletable/* /mnt/undeletable/.[!.]* /mnt/undeletable/..?*
umount /mnt
Run Code Online (Sandbox Code Playgroud)| 归档时间: |
|
| 查看次数: |
1277 次 |
| 最近记录: |