Bug #6340 » fsck_test.diff
| src/etc/rc | ||
|---|---|---|
|
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
|
||
| ... | ... | |
|
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!!!!
|
||