LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Directory shows as "unknown type" - any way to recover it? (https://www.linuxquestions.org/questions/linux-general-1/directory-shows-as-unknown-type-any-way-to-recover-it-487569/)

V@no 09-27-2006 09:07 PM

Directory shows as "unknown type" - any way to recover it?
 
Hello!
For unknown reason some files/directories on hard drive are not accessible anymore. If I do ls -l /full/path/ the corrupted directory shows like:
Code:

drwxr-xr-x 12 user user 16384 2006-04-17 22:56 name_of_good_directory
?---------  ? ?    ?        ?                ? /full/path/name_of_bad_directory

Is there a way to restore/recover these corrupted directories/files?

I've already checked the hard drive on possible sector loss or such - nothing wrong with it...

System info:
OS: Ubuntu 6.06
Kernel: 2.6.15-27-386
Filesystem: ext3
Hard drive connected via PCI Promise ATA100 controller

Thank you!

stress_junkie 09-27-2006 10:02 PM

If this is on your boot partition then you should force an fsck during the next reboot as follows:
Code:

root> shutdown -fr now
If it is on a partition other than the boot partition then unmount the partition and run fsck on the device mapping in the /dev directory as in /dev/hda3.

haertig 09-27-2006 11:50 PM

This may just be a permissions problem on the directory, not corruption. A directory that is readable, but not executable, gives you strange results when you try to list it's contents.

Here's an example I just tried on my own system. The "corruption" shows up when I give the directory a weird 444 mode. The "corruption" dissappears when I change it back to a more reasonable 555 permission.
Code:

$ mkdir dir1
$ ls -l dir1
total 0
$ > dir1/file1
$ ls -l dir1
total 0
-rw-r--r-- 1 david david 0 2006-09-27 22:46 file1
$ chmod 444 dir1
$ ls -l dir1
total 0
?--------- ? ? ? ?                ? dir1/file1
$ chmod 555 dir1
$ ls -l dir1
total 0
-rw-r--r-- 1 david david 0 2006-09-27 22:46 file1
$


V@no 09-27-2006 11:57 PM

Thanks for the replies.

Unfortunately its not permission issue...I just ran fsck and it indeed found some problems with these folders/files...Though I did answer "no" when it asked me to repair them, because I'm afraid by doing that I might lose the files completely...
Should I continue repair it with fsck or there is a better way to recover the files?

Thank you.

stress_junkie 09-28-2006 08:01 AM

If fsck finds files with problems it will put those files in the lost+found directory at the top of the partition's file system. Chances are that these files will not have their original name. Also, they may only be fragments of the original files.

I would try haertig's idea.
Code:

root> chmod 777 bad-directory
If that doesn't fix it then you can try to see how the directory is stored on the disk using the stat utility.
Code:

root> mkdir tmp
root> stat tmp
  File: `tmp'
  Size: 48              Blocks: 0          IO Block: 4096  directory
Device: 301h/769d      Inode: 275987      Links: 2
Access: (0700/drwx------)  Uid: (    0/    root)  Gid: (    0/    root)
Access: 2006-09-28 09:11:41.000000000 -0400
Modify: 2006-09-28 09:11:41.000000000 -0400
Change: 2006-09-28 09:11:41.000000000 -0400
root>

That might be useful if I knew of a tool that would fix a file based on that information, but I don't.

Otherwise I don't know of any other method of getting into that bad directory prior to using fsck.

brainiac 09-28-2006 09:23 AM

Have a look at testdisk. I had a partition that came up unknown, large storage partition, and test disk fixed it for me. I never did figure out why Debian or XP Pro could not "see" it, it was there, just unrecognizable.

stress_junkie 09-28-2006 09:46 AM

Quote:

Originally Posted by brainiac
Have a look at testdisk. I had a partition that came up unknown, large storage partition, and test disk fixed it for me. I never did figure out why Debian or XP Pro could not "see" it, it was there, just unrecognizable.

I'm a big fan of test disk myself. I don't think it applies here, though. This is a problem of an unreadable directory inside a good file system. Test disk fixes partition tables.
http://www.cgsecurity.org/wiki/TestDisk_Download


All times are GMT -5. The time now is 06:00 AM.