From 286cd231245f8b57d4386594ed4fefa7fcdad953 Mon Sep 17 00:00:00 2001 From: Luiz Souza Date: Fri, 13 Oct 2017 19:31:33 -0500 Subject: [PATCH] Mount the disk (the root slice) as read-only before running the fsck in the preen mode. This force the flush of all pending writes to disk and thus put the disk in a consistent state. The second effect of this change is that the file system can actually be recovered now, because otherwise with the root slice mounted as read-write, the fsck cannot write any changes. --- src/etc/pfSense-rc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/etc/pfSense-rc b/src/etc/pfSense-rc index 88651ffef1..39200046b6 100755 --- a/src/etc/pfSense-rc +++ b/src/etc/pfSense-rc @@ -69,6 +69,7 @@ fsck_forced_iterations=`/bin/kenv -q pfsense.fsck.force` if [ ! -z "${fsck_forced_iterations}" ]; then echo "Forcing filesystem check (${fsck_forced_iterations} times)..." while [ ${fsck_forced_iterations} -gt 0 ]; do + /sbin/mount -ur / /sbin/fsck -y -t ufs fsck_forced_iterations=$((fsck_forced_iterations - 1)) done @@ -78,6 +79,12 @@ if [ -e /root/force_growfs ]; then /etc/rc.d/growfs onestart fi +# +# The file system needs to be unmounted to guarantee a clean operation of fsck. +# Pending changes can keep the file system dirty until all the cached data is +# flushed to the disk. +# +/sbin/mount -ur / FSCK_ACTION_NEEDED=0 /sbin/fsck -p case $? in