#! /bin/sh ### BEGIN INIT INFO # Provides: checkfs # Required-Start: checkroot # Required-Stop: # Should-Start: # Default-Start: S # Default-Stop: # X-Interactive: true # Short-Description: Check all filesystems. ### END INIT INFO # Include /usr/bin in path to find on_ac_power if /usr/ is on the root # partition. setglobal PATH = '/sbin:/bin:/usr/bin' setglobal FSCK_LOGFILE = '/var/log/fsck/checkfs' test $FSCKFIX || setglobal FSCKFIX = 'no' source /lib/init/vars.sh source /lib/lsb/init-functions source /lib/init/mount-functions.sh source /lib/init/swap-functions.sh proc do_start { # Trap SIGINT so that we can handle user interupt of fsck. trap "" INT # See if we're on AC Power. If not, we're not gonna run our # check. If on_ac_power (in /usr/) is unavailable, behave as # before and check all file systems needing it. # Disabled AC power check until fsck can be told to only check the # file system if it is corrupt when running on battery. (bug #526398) # if which on_ac_power >/dev/null 2>&1 # then # on_ac_power >/dev/null 2>&1 # if [ $? -eq 1 ] # then # [ "$VERBOSE" = no ] || log_success_msg "Running on battery power, so skipping file system check." # BAT=yes # fi # fi setglobal BAT = ''"" setglobal fscheck = '"yes'" if is_fastboot_active { test $fscheck = yes && log_warning_msg "Fast boot enabled, so skipping file system check." setglobal fscheck = 'no' } # # Check the rest of the file systems. # if test $fscheck = yes && test ! $BAT && test $FSCKTYPES != "none" { # Execute swapon command again, in case there are lvm # or md swap partitions. fsck can suck RAM. swaponagain 'lvm and md' if test -f /forcefsck || grep -q -s -w -i "forcefsck" /proc/cmdline { setglobal force = '"-f'" } else { setglobal force = ''"" } if test $FSCKFIX = yes { setglobal fix = '"-y'" } else { setglobal fix = '"-a'" } setglobal spinner = '"-C'" match $TERM { with dumb|network|unknown|"" setglobal spinner = ''"" } test $[uname -m] = s390x && setglobal spinner = ''"" # This should go away setglobal FSCKTYPES_OPT = ''"" test $FSCKTYPES && setglobal FSCKTYPES_OPT = ""-t $FSCKTYPES"" proc handle_failed_fsck { log_failure_msg "File system check failed. A log is being saved in $(FSCK_LOGFILE) if that location is writable. Please repair the file system manually." log_warning_msg "A maintenance shell will now be started. CONTROL-D will terminate this shell and resume system boot." # Start a single user shell on the console if ! sulogin $CONSOLE { log_failure_msg "Attempt to start maintenance shell failed. Continuing with system boot in 5 seconds." sleep 5 } } if test $VERBOSE = no { log_action_begin_msg "Checking file systems" logsave -s $FSCK_LOGFILE fsck $spinner -M -A $fix $force $FSCKTYPES_OPT setglobal FSCKCODE = $Status if test $FSCKCODE -eq 32 { log_action_end_msg 1 "code $FSCKCODE" log_warning_msg "File system check was interrupted by user" } elif test $FSCKCODE -gt 1 { log_action_end_msg 1 "code $FSCKCODE" handle_failed_fsck } else { log_action_end_msg 0 } } else { if test $FSCKTYPES { log_action_msg "Will now check all file systems of types $FSCKTYPES" } else { log_action_msg "Will now check all file systems" } logsave -s $FSCK_LOGFILE fsck $spinner -V -M -A $fix $force $FSCKTYPES_OPT setglobal FSCKCODE = $Status if test $FSCKCODE -eq 32 { log_warning_msg "File system check was interrupted by user" } elif test $FSCKCODE -gt 1 { handle_failed_fsck } else { log_success_msg "Done checking file systems. A log is being saved in $(FSCK_LOGFILE) if that location is writable." } } } rm -f /fastboot /forcefsck !2 >/dev/null } match $1 { with start|"" do_start with restart|reload|force-reload echo "Error: argument '$1' not supported" > !2 exit 3 with stop|status # No-op with * echo "Usage: checkfs.sh [start|stop]" > !2 exit 3 } :