sudo rm -rf在root拥有的空目录上返回“无法删除目录”


8

我的Debian系统上有一个目录。目录是:

root@debian:/3/20150626# stat 00
File: `00'
Size: 6             Blocks: 0          IO Block: 4096   directory
Device: fe00h/65024d    Inode: 4392587948  Links: 3
Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2015-06-25 20:00:00.086150791 -0400
Modify: 2015-07-07 12:39:04.174903234 -0400
Change: 2015-07-07 12:39:04.174903234 -0400
Birth: -

目录为空:

root@debian:/3/20150626# ls -al 00
total 0
drwxr-xr-x 3 root root  6 Jul  7 12:39 .
drwxr-xr-x 3 root root 23 Jul  7 12:56 ..

但是我的系统却不这样认为:

root@debian:/3/20150626# rm -rf 00
rm: cannot remove `00': Directory not empty

我不知道为什么会发生这种情况,也无法找到前进的方法。谁能提供帮助?

我可以找到的先前问题都没有解决此特定问题。但是,为了解决我在类似帖子中看到的一些问题:

a。)该文件夹是由一个正在运行的进程创建的,该进程之前已创建了许多文件夹,并且这些文件夹已被多次删除。这个特定的人陷入了困境。

b。)现在该目录中不应写入任何内容。我已经检查了很多次,ls -al输出始终不返回任何内容。

c。)我已经检查了lsof,并且此目录没有打开:

root@debian:/3/20150626# lsof 00
root@debian:/3/20150626# 

d。) rm没有别名。它非常接近Debian的存货...对任何核心Bash程序(如rm等等)都没有做任何特别的事情。

e。)允许重命名,但仍然无法删除:

root@debian:/3/20150626# mv 00 delete_me
root@debian:/3/20150626# ls -al
total 0
drwxr-xr-x 3 root root  30 Jul  7 13:45 .
drwxr-xr-x 7 root root 105 Jul  7 12:57 ..
drwxr-xr-x 3 root root   6 Jul  7 12:39 delete_me
root@debian:/3/20150626# rm -rf delete_me
rm: cannot remove `delete_me': Directory not empty
root@debian:/3/20150626# ls -al delete_me/
total 0
drwxr-xr-x 3 root root  6 Jul  7 12:39 .
drwxr-xr-x 3 root root 30 Jul  7 13:45 ..

**注意,此后称为“ delete_me”,因为我对其进行了重命名,因此我将顺其自然。

f。)这是我find在其上运行时返回的唯一目录。

root@debian:/3/20150626# find / -type d -name delete_me
/3/20150626/delete_me
root@debian:/3/20150626# find delete_me
delete_me

g。)lsattr什么也没显示:

root@debian:/3/20150626# lsattr
---------------- ./delete_me

1
是否可以重命名目录?
珍妮D

2
“链接:3”部分跳给我;好像您可能有一个子目录。“查找00”返回什么?
杰夫·谢勒

更新了我的问题,并为您提供了答案,@ JennyD
harperville

1
您是否检查lsattr过是否分配了任何特殊属性?
2015年

2
在我看来,从项目(a)开始的运行过程正以某种方式保留在“ delete_me”子目录中的可能性越来越大。您可以停止此运行过程,然后重新检查stat输出(和/或重试rmdir)吗?
杰夫·谢勒

Answers:


1

找到了答案。正如@JeffSchaller所建议的那样,该链接有问题。解决方案是运行xfs_check以查看链接不正确,然后运行xfs_repair修复它们。

  1. 运行mount以查看设备名称。我的是/dev/mapper/vg3-lv3
  2. umount /3
  3. xfs_check /dev/mapper/vg3-lv3 返回了以下内容:

    link count mismatch for inode 4392587948 (name ?), nlink 3, counted 2

    link count mismatch for inode 12983188890 (name ?), nlink 1, counted 2

  4. xfs_repair /dev/mapper/vg3-lv3 表明链接已更正:

    resetting inode 4392587948 nlinks from 3 to 2

    resetting inode 12983188890 nlinks from 1 to 2

原来我还有另一个错误地链接的索引节点。

感谢您提供的所有帮助,但使用xfs_repair的黑魔法,我的问题已解决。


-1

您试图验证文件夹/目录的属性是否具有属性“ i ”-imutable已激活!如果使用“ *”将其关闭,请使用 lsattr 命令检查该文件夹/目录是否具有属性“ i ”被激活

chattr -i' 文件夹 '

*“这样您就可以执行所需的任务。


1
-i文件/文件夹上的属性不会阻止它显示,但是您在哪里看到该-i设置?OP的输出正相反
kos 2015年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.