Posts

Rebuild the journal in a ext3 journaled filesystem

The symptom of a broken ext3 journal is that the system will boot normaly but after a while the filesystem will be remounted read only and according to the log there are problems reading a block in the journal.

Boot on a rescue cd or boot but make sure the filesystem is in read only mode.

In this example i use /dev/md0 (the software raid device), becuase when I had this problem it was an ext3 journaled filesystem residing on a software raid that was causing trouble.

Issue the following commands

# fsck /dev/md0
# tune2fs -O ^have_journaled /dev/md0
# mount -n -o remount,rw /dev/md0
# tune2fs -j /dev/md0
# mount -n -o remount,ro /dev/md0
# fsck /dev/md0
# reboot

The first tune2fs removes the current journal on the filesystem (-O ^have_journaled). The second tune2fs (-j) recreates it. In between the filesystem must be mounted read only in order for the new journal to be written.