Yes, reinstall is the only way to fix UFS.
I've filed multitude of bugs about UFS and fsck. fsck is so broken that it needs multiple successive manual runs to even try to repair the filesystem, and then it gets all sort of things wrong, and segfaults, or spits out various confused nonsense, and eventually screws the filesystem to the point where you cannot boot any more.
I got the below patch from one of the pfSense devs for debugging, and while it tries to run fsck much aggressively, as noted above, the only result in the end was complete FS destruction. Also, it would need updating for 2.3.2 or newer, apparently.
diff --git a/src/etc/rc b/src/etc/rc
index e82a5ba..970fa9c 100755
--- a/src/etc/rc
+++ b/src/etc/rc
@@ -54,7 +54,7 @@ fi
if [ -e /root/force_fsck ]; then
echo "Forcing filesystem(s) check..."
- /sbin/fsck -y -F -t ufs
+ /sbin/fsck -y
fi
if [ "${PLATFORM}" != "cdrom" ]; then
@@ -77,18 +77,37 @@ if [ "${PLATFORM}" != "cdrom" ]; then
if [ ${FSCK_ACTION_NEEDED} = 1 ]; then
echo "WARNING: Trying to recover filesystem from inconsistency..."
- /sbin/fsck -yF
+ ntries=0
+ fsck_rc=1
+ until [ $ntries -ge 3 -o $fsck_rc -eq 0 ]; do
+ /sbin/fsck -y
+ fsck_rc=$?
+ ntries=$((ntries+1))
+ echo "DEBUG: Run #${ntries} - rc = ${fsck_rc}"
+ sleep 1
+
+ # Sometimes first call returns 0 but filesystem is still broken
+ # Run fsck in preen mode again just to be sure
+ /sbin/fsck -p -F
+ fsck_rc=$?
+ echo "DEBUG: (-p) #${ntries} - rc = ${fsck_rc}"
+ sleep 1
+ done
+
+ if [ $fsck_rc -ne 0 ]; then
+ echo "Automatic filesystem recovery failed. Starting recovery shell!"
+ tcsh
+ reboot
+ fi
fi
/sbin/mount -a 2>/dev/null
- mount_rc=$?
- attempts=0
- while [ ${mount_rc} -ne 0 -a ${attempts} -lt 3 ]; do
- /sbin/fsck -yF
- /sbin/mount -a 2>/dev/null
- mount_rc=$?
- attempts=$((attempts+1))
- done
+
+ if [ $? -ne 0 ]; then
+ echo "Filesystems could not be mounted. Starting recovery shell!"
+ tcsh
+ reboot
+ fi
if [ "${PLATFORM}" = "nanobsd" ]; then
# XXX This script does need all filesystems rw!!!!