San风夕 发表于 2014-03-04 15:57

Solaris10下无法删除目录

环境信息:Solaris 10u10
内核版本:Generic_150400-03
问题现象:
无法用rm命令删除abc目录,ls -al查看发现是空目录,但是硬链接数不对,正常的空目录是2,abc目录显示是3.
请问下有什么办法来纠正硬链接数不对这个问题呢,从而可以正常删除该目录?
# ls -al abc/
total 32
drwxr-x---   3 root   root         117 Mar4 10:33 .
drwxrwxrwt   5 root   sys          559 Mar4 11:44 ..
# rm -rf abc/
rm: Unable to remove directory abc/: File exists

q1208c 发表于 2014-03-04 16:42

ls -ald abc

San风夕 发表于 2014-03-04 19:57

本帖最后由 San风夕 于 2014-03-04 19:58 编辑

# ls -ald abc
drwxr-x---   3 root   root         117 Mar4 10:33 abc
回复 2# q1208c


   

东方蜘蛛 发表于 2014-03-04 22:02

rmdir?????

q1208c 发表于 2014-03-05 07:49

回复 3# San风夕

这就不知道了. ls显示, 这是一个标准的目录, 也没有 acl 设置.


   

San风夕 发表于 2014-03-05 11:26

本帖最后由 San风夕 于 2014-03-05 11:27 编辑

# rmdir abc/
rmdir: directory "abc/": Directory not empty
# ls -al abc/
total 32
drwxr-x---   3 root   root         117 Mar4 10:33 .
drwxrwxrwt   5 root   sys          559 Mar5 03:30 ..
# rm -rf abc/
rm: Unable to remove directory abc/: File exists
这个目录下肯定是丢失了目录什么的吧,现在的表现就是:1.硬链接数不对(我标红的那里,本来空目录应该是2的.) 2.无法删除.
回复 4# 东方蜘蛛


   

watchsat 发表于 2014-03-06 05:13

Kernel 150400 有嚴重Bugs, 請更新到150400-09再試試.

calcm 发表于 2014-03-18 18:20

给你看看网上查到的
https://blogs.oracle.com/paulie/entry/cannot_remove_directory_file_exists

Cannot remove directory: File exists
By paulie on May 20, 2009
If you try to delete a directory over NFS and get an error such as...

rm: cannot remove directory `asdf/': File exists

... you will notice that conventional methods won't be good enough to remove it.

$ chmod -R 777 asdf/
$ rm -rf asdf/
$ rm: cannot remove directory `asdf/': File exists

Usually there is a file like .nfs234B inside the directory than can be displayed with ls -la

$ ls -la
total 146
drwxr-xr-x 2 user group    512 2009-05-20 08:51 .
drwxr-xr-x 3 user group    512 2009-05-19 08:59 ..
-rwxr-xr-x 1 user group 134888 2009-05-18 12:45 .nfs234B

Removing this file only replaces it with another. There are two solutions: manually delete the file on the NFS server, or (if you don't have that type of access) kill its process.

$fuser -u asdf/.\*
asdf/.:   9070c(user)
asdf/..:    28690c(user)   24845c(user)
asdf/.nfs934B:   9070tm(user)

9070 is the offending process. Kill it with fire.

$ kill -9 9070

Should be able to remove that directory now.

San风夕 发表于 2014-03-20 12:50

先谢谢了,
我这里的情况跟你找到的还不一样,最终确认可能的原因是在目录下使用了unlink命令删了一个文件,导致该目录的硬链接数不对,无法删除.
回复 8# calcm


   
页: [1]
查看完整版本: Solaris10下无法删除目录