Thoughts that are my own.

Fixing Journal Abort Filesystem Problems

I routinely deal with Read Only file systems and always have to remember the commands to remove the journal and run a file system check. Since some days I am better at remembering than others, I thought I’d just write it down in this post so I can find it later.

First, remove the journal:

sh# tune2fs -O ^has_journal /dev/hda5

If you run into errors due to ‘needs_recovery’, do this to remove the recovery flag and then remove the journal as shown above:

sh# debugfs -w /dev/hda5 debugfs: features ^needs_recovery debugfs: quit

Run the file system check. See how bad things are first.

sh# fsck -n /dev/hda5

If it’s not too bad, do the real fsck.

sh# fsck -y /dev/hda5

Once the rebuild is successful and complete, rebuild the journal.

sh# tune2fs -j /dev/hda5

Mount the filesystem and make sure it’s happy and ready for action.

sh# mkdir /mnt/fixed && mount -t ext3 /dev/hda5 /mnt/fixed

Reboot the server and put it back in the fray.