4
# Required-Start: checkroot
6
# Should-Start: mtab cryptdisks
10
# Short-Description: Check all filesystems.
13
# Include /usr/bin in path to find on_ac_power if /usr/ is on the root
15
PATH=/sbin:/bin:/usr/bin
16
FSCK_LOGFILE=/var/log/fsck/checkfs
17
[ "$FSCKFIX" ] || FSCKFIX=no
20
. /lib/lsb/init-functions
21
. /lib/init/splash-functions-base
22
. /lib/init/usplash-fsck-functions.sh
25
# See if we're on AC Power. If not, we're not gonna run our
26
# check. If on_ac_power (in /usr/) is unavailable, behave as
27
# before and check all file systems needing it.
29
# Disabled AC power check until fsck can be told to only check the
30
# file system if it is corrupt when running on battery. (bug #526398)
31
# if which on_ac_power >/dev/null 2>&1
33
# on_ac_power >/dev/null 2>&1
36
# [ "$VERBOSE" = no ] || log_success_msg "Running on battery power, so skipping file system check."
43
if [ -f /fastboot ] || grep -s -w -i "fastboot" /proc/cmdline
45
[ "$fscheck" = yes ] && log_warning_msg "Fast boot enabled, so skipping file system check."
50
# Check the rest of the file systems.
52
if [ "$fscheck" = yes ] && [ ! "$BAT" ] && [ "$FSCKTYPES" != "none" ]
54
if [ -f /forcefsck ] || grep -s -w -i "forcefsck" /proc/cmdline
60
if [ "$FSCKFIX" = yes ]
68
dumb|network|unknown|"")
72
[ "$(uname -m)" = s390 ] && spinner="" # This should go away
74
[ "$FSCKTYPES" ] && FSCKTYPES_OPT="-t $FSCKTYPES"
75
handle_failed_fsck() {
76
log_failure_msg "File system check failed.
77
A log is being saved in ${FSCK_LOGFILE} if that location is writable.
78
Please repair the file system manually."
79
log_warning_msg "A maintenance shell will now be started.
80
CONTROL-D will terminate this shell and resume system boot."
81
# Start a single user shell on the console
84
log_failure_msg "Attempt to start maintenance shell failed.
85
Continuing with system boot in 5 seconds."
89
if [ "$VERBOSE" = no ]
91
log_action_begin_msg "Checking file systems"
92
if usplash_running; then
93
PROGRESS_FILE=`mktemp` || exit 1
95
logsave -s $FSCK_LOGFILE fsck -C3 -R -A $fix $force $FSCKTYPES_OPT >/dev/console 2>&1 3>$PROGRESS_FILE &
97
usplash_progress "$PROGRESS_FILE"
100
splash_start_indefinite
101
logsave -s $FSCK_LOGFILE fsck $spinner -R -A $fix $force $FSCKTYPES_OPT
103
splash_stop_indefinite
106
if [ "$FSCKCODE" -gt 1 ]
108
log_action_end_msg 1 "code $FSCKCODE"
116
log_action_msg "Will now check all file systems of types $FSCKTYPES"
118
log_action_msg "Will now check all file systems"
120
splash_start_indefinite
121
logsave -s $FSCK_LOGFILE fsck $spinner -V -R -A $fix $force $FSCKTYPES_OPT
123
splash_stop_indefinite
124
if [ "$FSCKCODE" -gt 1 ]
128
log_success_msg "Done checking file systems.
129
A log is being saved in ${FSCK_LOGFILE} if that location is writable."
133
rm -f /fastboot /forcefsck 2>/dev/null
140
restart|reload|force-reload)
141
echo "Error: argument '$1' not supported" >&2
148
echo "Usage: checkfs.sh [start|stop]" >&2