I'm using CentOS 7 and trying to list a directory's contents but can't. When I try to list the contents, I get the following output:
[entpnerd@myhost ~]$ ls -ali /data/sharedlogs/otherhost/
ls: cannot access /data/sharedlogs/otherhost/vcs: Not a directory
total 12
2361284 drwxr-xr-x 4 root root 4096 Sep 26 14:40 .
2359297 drwxr-xr-x 6 root root 4096 Apr 26 17:41 ..
2362573 drwxr-xr-x 2 root root 4096 Mar 22 2017 tkr
? d????????? ? ? ? ? ? vcs
The output states that my directory, vcs
, is "Not a directory", even though it should be, since this is where files have been previously logged. Additionally, the file permission bits are now all question marks, as is the owner, and (inexplicably) the inode ID.
How can I get the file system to recognize my directory as a directory again?
After trying everything that I've outlined below, the only path forward that I see is to ensure that the disk is backed up and run fsck
(as suggested by this forum) or possibly just formatting the entire mount. Hopefully I find a simpler and less drastic solution.
Some things I have tried:
sudo
: I tried runningsudo ls
but no difference in output.rm
: I tried removingvcs
to put it back but no luck. I tried this both withsudo
and without, but no luck either. Oddly enough, when I trysudo rm
it statesIs a directory
. I also triedrm
with both the-r
and the-d
switches, with no luck also. The output I get from therm
command attempts are:[entpnerd@myhost ~]$ rm /data/sharedlogs/otherhost/vcs rm: cannot remove ‘/data/sharedlogs/otherhost/vcs’: Not a directory [entpnerd@myhost ~]$ sudo rm /data/sharedlogs/otherhost/vcs rm: cannot remove ‘/data/sharedlogs/otherhost/vcs’: Is a directory [entpnerd@myhost ~]$ sudo rm -r /data/sharedlogs/otherhost/vcs rm: cannot remove ‘/data/sharedlogs/otherhost/vcs’: Is a directory [entpnerd@myhost ~]$ rm -r /data/sharedlogs/otherhost/vcs rm: cannot remove ‘/data/sharedlogs/otherhost/vcs’: Not a directory [entpnerd@myhost ~]$ rm -rd /data/sharedlogs/otherhost/vcs rm: cannot remove ‘/data/sharedlogs/otherhost/vcs’: Not a directory [entpnerd@myhost ~]$ sudo rm -rd /data/sharedlogs/otherhost/vcs rm: cannot remove ‘/data/sharedlogs/otherhost/vcs’: Is a directory
- inode ID: I tried removing by the inode (as suggested by this answer to a similar question), but I had no luck with that either, because as you can see from the output of the above
ls
command, thevcs
directory has no inode ID. Non-ASCII characters: In the post, "How to Delete the Undeletable Directory", the directory had non-ASCII characters. This also is not the case as I saw from the
xxd
output:[entpnerd@myhost ~]$ ls -l /data/sharedlogs/otherhost/ | xxd ls: cannot access /data/sharedlogs/otherhost/vcs: Not a directory 0000000: 746f 7461 6c20 340a 6472 7778 722d 7872 total 4.drwxr-xr ... 0000040: 3f3f 3f3f 3f20 3f20 3f20 2020 203f 2020 ????? ? ? ? 0000050: 2020 2020 203f 2020 2020 2020 2020 2020 ? 0000060: 2020 3f20 7663 730a ? vcs.
lsattr
: As suggested by the similar question, "Why can't I delete this file as root?", I tried using thelsattr
command, but with no luck either:[entpnerd@myhost ~]$ lsattr /data/sharedlogs/otherhost/ -------------e-- /data/sharedlogs/otherhost/tkr /data/sharedlogs/otherhost/vcs: Not a directory [entpnerd@myhost ~]$ lsattr /data/sharedlogs/otherhost/vcs lsattr: Not a directory while trying to stat /data/sharedlogs/otherhost/vcs [entpnerd@myhost ~]$ sudo lsattr /data/sharedlogs/otherhost/vcs [sudo] password for entpnerd: lsattr: Not a directory while trying to stat /data/sharedlogs/otherhost/vcs
Setting executable bits for the directory: As per the similar question, "Question marks showing in ls of directory. IO errors too", I tried to set the executable bits for the directory, but no luck with that either.
[entpnerd@myhost ~]$ sudo chmod -R g+x /data/sharedlogs/otherhost/vcs [sudo] password for entpnerd: chmod: cannot access ‘/data/sharedlogs/otherhost/vcs’: Not a directory [entpnerd@myhost ~]$ sudo chmod -R u+x /data/sharedlogs/otherhost/vcs chmod: cannot access ‘/data/sharedlogs/otherhost/vcs’: Not a directory [entpnerd@myhost ~]$ sudo chmod -R a+x /data/sharedlogs/otherhost/vcs chmod: cannot access ‘/data/sharedlogs/otherhost/vcs’: Not a directory
Any help would be greatly appreciated.