Ticket #4523 Run fsck with -C flag and alway in foreground during bootup to prevent any issues that might schedule background mode.

This commit is contained in:
Ermal LUÇI 2015-05-27 10:20:52 +02:00
parent 9eb84e6321
commit fc123231da

109
etc/rc
View File

@ -37,66 +37,24 @@ if [ ! -z "`sysctl -Nq debug.ddb.scripting.scripts`" ]; then
fi
if [ -e /root/force_fsck ]; then
echo "Forcing filesystem check..."
/sbin/fsck -y -t ufs /
if [ "$PLATFORM" = "nanobsd" ]; then
/sbin/fsck -y -t ufs /cf
fi
echo "Forcing filesystem(s) check..."
/sbin/fsck -y -F -t ufs
fi
if [ "${PLATFORM}" = "nanobsd" ]; then
kldstat -qm zfs
if [ $? -eq 0 ]; then
kldunload zfs
fi
fi
if [ ! "${PLATFORM}" = "cdrom" ]; then
/sbin/fsck -y -C -F
# Mount memory file system if it exists
echo "Mounting filesystems..."
# Mount memory file system if it exists
echo "Mounting filesystems..."
# Handle ZFS read-only case
if [ "$PLATFORM" = "pfSense" ]; then
kldstat -qm zfs
if [ $? -eq 0 ]; then
ZFSFSAVAILABLE=$(/sbin/zfs mount 2>/dev/null | wc -l)
if [ $ZFSFSAVAILABLE -eq 0 ]; then
kldunload zfs
elif [ -f /usr/bin/grep ]; then
ZFSROOT=`/sbin/zfs mount | /usr/bin/grep ' /$' | /usr/bin/cut -d ' ' -f 1`
if [ "$ZFSROOT" != "" ]; then
/sbin/zfs set readonly=off $ZFSROOT
fi
fi
fi
fi
if [ "${PLATFORM}" = "cdrom" ]; then
/etc/rc.cdrom
else
# Mount /. If it fails run a fsck.
if [ "$PLATFORM" = "nanobsd" ]; then
export PKG_TMPDIR=/root/
/sbin/mount -uw / 2>/dev/null
mount_rc=$?
attempts=0
while [ ${mount_rc} -ne 0 -a ${attempts} -lt 3 ]; do
/sbin/fsck -y /
/sbin/fsck -y /cf
/sbin/mount -uw / 2>/dev/null
mount_rc=$?
attempts=$((attempts+1))
done
else
/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=0
while [ ${mount_rc} -ne 0 -a ${attempts} -lt 3 ]; do
/sbin/fsck -y /
/sbin/mount -a 2>/dev/null
mount_rc=$?
attempts=$((attempts+1))
done
fi
attempts=$((attempts+1))
done
# If /conf is a directory, convert it to a symlink to /cf/conf
if [ -d "/conf" ]; then
@ -108,24 +66,6 @@ else
fi
fi
if [ ! "$PLATFORM" = "jail" ]; then
# Check to see if a compact flash mountpoint exists
# If it fails to mount then run a fsck -y
if grep -q cf /etc/fstab; then
/sbin/mount -w /cf 2>/dev/null
/sbin/mount -uw /cf 2>/dev/null
mount_rc=$?
attempts=0
while [ ${mount_rc} -ne 0 -a ${attempts} -lt 3 ]; do
/sbin/umount /cf
/sbin/fsck -y /cf
/sbin/mount -w /cf 2>/dev/null
mount_rc=$?
attempts=$((attempts+1))
done
fi
fi
USE_MFS_TMPVAR=`/usr/bin/grep -c use_mfs_tmpvar /cf/conf/config.xml`
if [ "${PLATFORM}" = "nanobsd" ] || [ ${USE_MFS_TMPVAR} -gt 0 ]; then
/etc/rc.embedded
@ -136,6 +76,29 @@ fi
/bin/rm -f /root/TRIM_set
/bin/rm -f /root/TRIM_unset
if [ "${PLATFORM}" = "nanobsd" ]; then
/sbin/kldstat -qm zfs
if [ $? -eq 0 ]; then
/sbin/kldunload zfs
fi
elif [ "$PLATFORM" = "pfSense" ]; then
# Handle ZFS read-only case
/sbin/kldstat -qm zfs
if [ $? -eq 0 ]; then
ZFSFSAVAILABLE=$(/sbin/zfs mount 2>/dev/null | wc -l)
if [ $ZFSFSAVAILABLE -eq 0 ]; then
/sbin/kldunload zfs
elif [ -f /usr/bin/grep ]; then
ZFSROOT=`/sbin/zfs mount | /usr/bin/grep ' /$' | /usr/bin/cut -d ' ' -f 1`
if [ "$ZFSROOT" != "" ]; then
/sbin/zfs set readonly=off $ZFSROOT
fi
fi
fi
elif [ "${PLATFORM}" = "cdrom" ]; then
/etc/rc.cdrom
fi
# Disable APM on ATA drives. Leaving this on will kill drives long-term, especially laptop drives, by generating excessive Load Cycles.
if [ -f /etc/rc.disable_hdd_apm ]; then
/etc/rc.disable_hdd_apm