2 ########################################################################
5 # Description : File System Check
7 # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
8 # A. Luebke - luebke@users.sourceforge.net
9 # DJ Lucas - dj@linuxfromscratch.org
10 # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
14 # Based on checkfs script from LFS-3.1 and earlier.
18 # 1 - File system errors corrected
19 # 2 - System should be rebooted
20 # 4 - File system errors left uncorrected
21 # 8 - Operational error
22 # 16 - Usage or syntax error
23 # 32 - Fsck canceled by user request
24 # 128 - Shared library error
26 #########################################################################
30 # Required-Start: udev swap
36 # Short-Description: Checks local filesystems before mounting.
37 # Description: Checks local filesystmes before mounting.
38 # X-LFS-Provided-By: LFS
41 .
/lib
/lsb
/init-functions
45 if [ -f /fastboot
]; then
46 msg
="/fastboot found, will omit "
47 msg
="${msg} file system checks as requested.\n"
52 log_info_msg
"Mounting root file system in read-only mode... "
53 mount
-n -o remount
,ro
/ >/dev
/null
55 if [ ${?} != 0 ]; then
57 msg
="\n\nCannot check root "
58 msg
="${msg}filesystem because it could not be mounted "
59 msg
="${msg}in read-only mode.\n\n"
60 msg
="${msg}After you press Enter, this system will be "
61 msg
="${msg}halted and powered off.\n\n"
62 log_failure_msg
"${msg}"
64 log_info_msg
"Press Enter to continue..."
66 /etc
/rc.d
/init.d
/halt stop
71 if [ -f /forcefsck
]; then
72 msg
="/forcefsck found, forcing file"
73 msg
="${msg} system checks as requested."
74 log_success_msg
"$msg"
80 log_info_msg
"Checking file systems..."
81 # Note: -a option used to be -p; but this fails e.g. on fsck.minix
82 if is_true
"$VERBOSE_FSCK"; then
83 fsck
${options} -a -A -C -T
85 fsck
${options} -a -A -C -T >/dev
/null
90 if [ "${error_value}" = 0 ]; then
94 if [ "${error_value}" = 1 ]; then
95 msg
="\nWARNING:\n\nFile system errors "
96 msg
="${msg}were found and have been corrected.\n"
97 msg
="${msg} You may want to double-check that "
98 msg
="${msg}everything was fixed properly."
99 log_warning_msg
"$msg"
102 if [ "${error_value}" = 2 -o "${error_value}" = 3 ]; then
103 msg
="\nWARNING:\n\nFile system errors "
104 msg
="${msg}were found and have been been "
105 msg
="${msg}corrected, but the nature of the "
106 msg
="${msg}errors require this system to be rebooted.\n\n"
107 msg
="${msg}After you press enter, "
108 msg
="${msg}this system will be rebooted\n\n"
109 log_failure_msg
"$msg"
111 log_info_msg
"Press Enter to continue..."
116 if [ "${error_value}" -gt 3 -a "${error_value}" -lt 16 ]; then
117 msg
="\nFAILURE:\n\nFile system errors "
118 msg
="${msg}were encountered that could not be "
119 msg
="${msg}fixed automatically.\nThis system "
120 msg
="${msg}cannot continue to boot and will "
121 msg
="${msg}therefore be halted until those "
122 msg
="${msg}errors are fixed manually by a "
123 msg
="${msg}System Administrator.\n\n"
124 msg
="${msg}After you press Enter, this system will be "
125 msg
="${msg}halted and powered off.\n\n"
126 log_failure_msg
"$msg"
128 log_info_msg
"Press Enter to continue..."
130 /etc
/rc.d
/init.d
/halt stop
133 if [ "${error_value}" -ge 16 ]; then
134 msg
="FAILURE:\n\nUnexpected failure "
135 msg
="${msg}running fsck. Exited with error "
136 msg
="${msg} code: ${error_value}.\n"
144 echo "Usage: ${0} {start}"