Problem :
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?
Solution :
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.
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.