Bug #6340 » fsck_test.diff
| src/etc/rc | ||
|---|---|---|
| 54 | 54 | |
| 55 | 55 |
if [ -e /root/force_fsck ]; then |
| 56 | 56 |
echo "Forcing filesystem(s) check..." |
| 57 |
/sbin/fsck -y -F -t ufs
|
|
| 57 |
/sbin/fsck -y |
|
| 58 | 58 |
fi |
| 59 | 59 | |
| 60 | 60 |
if [ "${PLATFORM}" != "cdrom" ]; then
|
| ... | ... | |
| 77 | 77 | |
| 78 | 78 |
if [ ${FSCK_ACTION_NEEDED} = 1 ]; then
|
| 79 | 79 |
echo "WARNING: Trying to recover filesystem from inconsistency..." |
| 80 |
/sbin/fsck -yF |
|
| 80 |
ntries=0 |
|
| 81 |
fsck_rc=1 |
|
| 82 |
until [ $ntries -ge 3 -o $fsck_rc -eq 0 ]; do |
|
| 83 |
/sbin/fsck -y |
|
| 84 |
fsck_rc=$? |
|
| 85 |
ntries=$((ntries+1)) |
|
| 86 |
echo "DEBUG: Run #${ntries} - rc = ${fsck_rc}"
|
|
| 87 |
sleep 1 |
|
| 88 | ||
| 89 |
# Sometimes first call returns 0 but filesystem is still broken |
|
| 90 |
# Run fsck in preen mode again just to be sure |
|
| 91 |
/sbin/fsck -p -F |
|
| 92 |
fsck_rc=$? |
|
| 93 |
echo "DEBUG: (-p) #${ntries} - rc = ${fsck_rc}"
|
|
| 94 |
sleep 1 |
|
| 95 |
done |
|
| 96 | ||
| 97 |
if [ $fsck_rc -ne 0 ]; then |
|
| 98 |
echo "Automatic filesystem recovery failed. Starting recovery shell!" |
|
| 99 |
tcsh |
|
| 100 |
reboot |
|
| 101 |
fi |
|
| 81 | 102 |
fi |
| 82 | 103 | |
| 83 | 104 |
/sbin/mount -a 2>/dev/null |
| 84 |
mount_rc=$? |
|
| 85 |
attempts=0 |
|
| 86 |
while [ ${mount_rc} -ne 0 -a ${attempts} -lt 3 ]; do
|
|
| 87 |
/sbin/fsck -yF |
|
| 88 |
/sbin/mount -a 2>/dev/null |
|
| 89 |
mount_rc=$? |
|
| 90 |
attempts=$((attempts+1)) |
|
| 91 |
done |
|
| 105 | ||
| 106 |
if [ $? -ne 0 ]; then |
|
| 107 |
echo "Filesystems could not be mounted. Starting recovery shell!" |
|
| 108 |
tcsh |
|
| 109 |
reboot |
|
| 110 |
fi |
|
| 92 | 111 | |
| 93 | 112 |
if [ "${PLATFORM}" = "nanobsd" ]; then
|
| 94 | 113 |
# XXX This script does need all filesystems rw!!!! |