Fixing ext3 read-only file system
Submitted by robot_terror on Fri, 07/04/2008 - 09:22.
When an ext3 file system reports being "read-only" quick action needs to be taken.
- Power off the server ('init 0') to avoid data loss.
- Boot into a rescue environment
- Do not allow the rescue to mount the drives. For Red Hat, choose the 'Skip' option when prompted to find your RHEL installation.
- Once in the rescue shell, locate the / file system (ex: /dev/sda5)
- Remove the existing journal:
sh# tune2fs -O ^has_journal /dev/hda5If this fails because of the needs_recovery flag preform the following
sh# debugfs -w /dev/sda5 debugfs: features ^needs_recovery debugfs: quit
- Now, perform a fsck operation. Note, use the -y option with caution. You might want to just see how bad the corruption is first before you say "YES" to anything.
sh# fsck.ext2 -f /dev/sda5
- Now, if your fsck looks good, rebuild the journal
sh# tune2fs -j /dev/sda5
- Mount the filesystem and make sure its clean
sh# mkdir /mnt/fixed && mount -t ext3 /dev/sda5 /mnt/fixed
- If done, then unmount the file system, and bring it back up.
sh# cd / ; umount /mnt/fixed && reboot && exit
NB: Stolen from an old how-to at work in case the Wiki it's on goes way abruptly; I didn't write this -- Robot Terror
