# Unable to delete empty folder



## alie (Nov 30, 2011)

```
[/var/tmp/test]# ls -la
total 8K
drwx------ 2 root wheel 1024 Nov 22 19:50 .
drwxrwxrwt 6 root wheel  512 Nov 30 18:31 ..
```


```
[/var/tmp]# rm -rf test/     
rm: test/: Directory not empty
```

Any idea how to solve this weird issue?


----------



## gkontos (Nov 30, 2011)

Have you tried:

[CMD=""]# chflags -R noschg test/[/CMD]
[CMD=""]# rm -rf test/[/CMD]


----------



## alie (Nov 30, 2011)

gkontos said:
			
		

> Have you tried:
> 
> [CMD=""]# chflags -R noschg test/[/CMD]
> [CMD=""]# rm -rf test/[/CMD]




```
[/var/tmp]# chflags -R noschg test/
[/var/tmp]# rm -rf test/
rm: test/: Directory not empty
```

No success. I can rename it but i can't remove it


```
[/var/tmp]# ls -la
total 24K
drwxrwxrwt  6 root    wheel  512 Nov 30 18:31 .
drwxr-xr-x 25 root    wheel  512 Nov 30 18:27 ..
srwxrwxrwx  1 ezyclie wheel    0 Nov 30 18:27 dbus-HyZGHnKjcg
drwx------  7 ezyclie wheel  512 Nov 30 18:28 kdecache-ezyclie
drwx------  2 kdm     wheel  512 Nov 30 18:27 kdecache-kdm
drwx------  2 ezyclie wheel  512 Nov 30 18:28 orbit-ezyclie
drwx------  2 root    wheel 1024 Nov 22 19:50 test
```


----------



## pbd (Nov 30, 2011)

What was in that directory? Can some process, that opened file in it, be still running?


----------



## fluca1978 (Nov 30, 2011)

I suggest doing a 

```
lsfo | grep test
```
and inspect it with

```
ls -lod test
```
to see if there is any flag.


----------



## alie (Nov 30, 2011)

pbd said:
			
		

> What was in that directory? Can some process, that opened file in it, be still running?



Its empty dir...


```
[/var/tmp]# ls -lod test
drwx------ 2 root 1024 Nov 22 19:50 test
```


----------



## SirDice (Nov 30, 2011)

alie said:
			
		

> Its empty dir...


If a process has a file open in that directory and that file is deleted, the file isn't completely removed. You won't see it but it's still there.

Another possibility is a corrupt filesystem. I'd reboot the machine and do an fsck(8) on it. The reboot will also take care of the application that might still have an open filehandle.


----------



## alie (Nov 30, 2011)

SirDice said:
			
		

> If a process has a file open in that directory and that file is deleted, the file isn't completely removed. You won't see it but it's still there.
> 
> Another possibility is a corrupt filesystem. I'd reboot the machine and do an fsck(8) on it. The reboot will also take care of the application that might still have an open filehandle.



I am able to rename it and i've tried fsck(8) too with single user mod... still no success


----------



## alie (Nov 30, 2011)

Ok solved... I have to run single user mode without mount then fsck


----------



## SirDice (Nov 30, 2011)

alie said:
			
		

> I have to run single user mode without mount then fsck


Certain filesystem errors can't be fixed if the filesystem is mounted.


----------

