Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

When I ls -ls on my folder I get this now:

27216 -rw-r--r--   1 qat users 27865731 2012-03-16 09:13 deploy

But it was a directory, is there a quick way to convert it back?

share|improve this question
3  
No, there sure is no quick way to "convert it back". I can't imagine how this happened in the first place, probably you deleted the directory and placed a file there. –  Niklas B. Mar 16 '12 at 14:25
2  
Using the same tiny magnet that was used to bypass all the filesystem safety check, you can flip the bit back. –  Simon Richter Mar 16 '12 at 14:33
add comment

migrated from stackoverflow.com Mar 16 '12 at 14:27

This question came from our site for professional and enthusiast programmers.

3 Answers

No, there's no quick way to convert it back.

I share the opinion of one of the commenters that you probably inadvertently removed the directory and replaced it with a file. Assuming the file size didn't change, 27MB would be a gigantic directory, containing hundreds of thousands of files. In many years of doing Unix admin work, I've only seen one directory with over 100,000 files in it, so I'm doubtful that you had a directory that large. Take a look at the files contents and see if it looks familiar; odds are good that the file contains logging output from some process or the other.

Assuming you're not mistaken and a directory was silently converted to a regular file, this is very bad news for your system. A number of things could be wrong, and I would not trust this system again until I figured out what component (disk, disk controller, RAM, filesystem code) is failing.

share|improve this answer
    
Good explanation. My advise would be to use file deploy to check the file type. –  Niklas B. Mar 16 '12 at 23:34
add comment

This was happening to me running arch-linux because my /home directory was mounted on a usb hard drive and it was autosuspending. So I had urxvt and tmux open in the /home/user directory and was logged into X.

I went away from my screen for an hour and came back and typed vim into the urxvt bash shell. Since the drives were suspended they first had to wake up so it took about 5-10 seconds for vim to load. It doesn't have to be vim for this to happen but when I went back to bash some of my directories like /home/user/tmp and /home/user/.vim had been converted from directories to files.

The fix for me was to reboot into level 3 as root and unmount /home, then running an fsck -f on the hard drive, then I rebooted and the files had been converted back into directories and none of my files were lost or corrupted.

Then I disabled usb autosuspend to keep it from happening again.

share|improve this answer
add comment

They suggest on http://stackoverflow.com/questions/4855373/how-to-change-a-file-that-used-to-be-a-directory-back-to-directory-on-linux to remove the file and create the directory:

rm filename
mkdir filename

But on my corrupted? NTFS 3G external drive, I just got:

rm: filename: No such file or directory
mkdir: filename: File exists

So am not sure what the solution if any would be.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.