Avoid to run `fsck` twice (and save some time during boot)

93 views
Skip to first unread message

Antonio Kless

unread,
Dec 13, 2013, 9:20:01 AM12/13/13
to freebsd-...@freebsd.org
I am running 8.4-RELEASE-p4 (amd64) box with this lines in /etc/rc.conf:

fsck_y_enable="YES"
background_fsck="NO"

- to be sure that if it will be rebooted with power loss, filesystem
would be checked and repaired.

But I discovered (/etc/rc.d/fsck) that `fsck` run twice:

fsck_start()
{
if [ "$autoboot" = no ]; then
echo "Fast boot: skipping disk checks."
elif [ ! -r /etc/fstab ]; then
echo "Warning! No /etc/fstab: skipping disk checks."
elif [ "$autoboot" = yes ]; then
# During fsck ignore SIGQUIT
trap : 3

check_startmsgs && echo "Starting file system checks:"
if checkyesno background_fsck; then
fsck -F -p
else
fsck -p
fi

case $? in

.....

8)
if checkyesno fsck_y_enable; then
echo "File system preen failed, trying fsck -y ${fsck_y_flags}"
fsck -y ${fsck_y_flags}
case $? in
0)
;;
*)
echo "Automatic file system check failed; help!"
stop_boot
;;
esac
else
echo "Automatic file system check failed; help!"
stop_boot
fi
;;

.....


So time is wasting. Why not just run `fsck -y ${fsck_y_flags}`?

Of course I could hack the script, but I wonder if there is the way to
avoid runnig fsck twice not hacking system scripts? Or is there any
reasons to run it twice?

--
Best regards,
Antonio Kless


signature.asc

Anton Sayetsky

unread,
Dec 13, 2013, 9:25:52 AM12/13/13
to Antonio Kless, FreeBSD Questions
2013/12/13 Antonio Kless <antoni...@gmail.com>:
man fsck
/-p
...
profit
_______________________________________________
freebsd-...@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "freebsd-questi...@freebsd.org"

Antonio Kless

unread,
Dec 13, 2013, 9:51:40 AM12/13/13
to Anton Sayetsky, FreeBSD Questions
13.12.2013 18:25, Anton Sayetsky:
> man fsck
> /-p
> ...
> profit

What do you mind?

Well, first check with "-p" is exactly what I want to avoid before doing
second check without it.
signature.asc

Anton Sayetsky

unread,
Dec 13, 2013, 9:56:23 AM12/13/13
to Antonio Kless, FreeBSD Questions
2013/12/13 Antonio Kless <antoni...@gmail.com>:
> What do you mind?
>
> Well, first check with "-p" is exactly what I want to avoid before doing
> second check without it.
fsck checks limited range of errors in preen mode. This works really FAST.
Logic is following:
1. Run very fast (preen) check on FS if dirty flag set.
2. If above fails, run full and slow check.

Of course, you can disable preen pass. But be ready to multi-houred
filesystem checks on every unclean reboot even if FS isn't damaged.
Reply all
Reply to author
Forward
0 new messages