Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On a CentOS 5.3 server the /var folder has changed to a file. Appears to be FS corruption.

Rest of the FS looks OK. Anyone know a quick way to fix this? fsck.ext3 reports the fs as clean even using a force check.

It looks like the machine had the power yanked and when it came back up it was like this.

share|improve this question

You likely have quite a few problems I should think, given it's possible any databases, websites, mail spools and log directories have also died in there.

I would seriously recommend taking a block level backup of the disk before you start mucking around in it if you had any sort of important data on that server. dd if=/dev/XXX of=/somewhere/else/disk.img (from memory!)

While knweiss' answer will rebuild your rpm directory and program specific dirs and may let you continue using the server you will need to get in to the file system internals to try recover anything meaningful.

I'd also be concerned about any other directories that have gone missing that you haven't noticed yet. (...and I'm going to assume it really is a file and not just an empty directory where var is on a separate partition that failed to mount.)

share|improve this answer

Delete the file and restore the /var folder from your backup.

If you don't have a backup you could do rpm -ivh --replacepkgs filesystem...rpm to reinstall the "filesystem" rpm. This will create the empty(!) folder hierarchy of /var. Reboot afterwards. Now, if an application is still not working because something is missing in /var do the same with its rpm.

share|improve this answer
Thank, I will have to use the rpm as there is no backup of /var – Daniel Oct 11 '09 at 9:23
You'll have the small problem that you would have lost your RPM database, which you'll need to reinit, which means you need to create the var directory .... – David Pashley Oct 11 '09 at 11:32
Good point! ;-) – knweiss Oct 11 '09 at 11:42

Your Answer


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