source: bootscripts/lfs/init.d/checkfs@ d83fd51

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 8.1 8.1-rc1 8.1-rc2 8.2 8.2-rc1 8.3 8.3-rc1 8.3-rc2 8.4 8.4-rc1 9.0 9.0-rc1 9.1 9.1-rc1 cross-chap5 ml-11.0 multilib old-trunk trunk xry111/git-transition xry111/glibc-2.34 xry111/tester-nohack xry111/usr-move
Last change on this file since d83fd51 was d83fd51, checked in by Bruce Dubbs <bdubbs@…>, 5 years ago

Update formats of error messages in checkfs boot script.
Update to man-pages-4.10.
Update to linux-4.10.3.
Update to gdbm-1.13.
Update to coreutils-8.27.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@11209 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

  • Property mode set to 100644
File size: 4.4 KB
Line 
1#!/bin/sh
2########################################################################
3# Begin checkfs
4#
5# Description : File System Check
6#
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
11#
12# Version : LFS 7.0
13#
14# Based on checkfs script from LFS-3.1 and earlier.
15#
16# From man fsck
17# 0 - No errors
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
25#
26#########################################################################
27
28### BEGIN INIT INFO
29# Provides: checkfs
30# Required-Start: udev swap $time
31# Should-Start:
32# Required-Stop:
33# Should-Stop:
34# Default-Start: S
35# Default-Stop:
36# Short-Description: Checks local filesystems before mounting.
37# Description: Checks local filesystmes before mounting.
38# X-LFS-Provided-By: LFS
39### END INIT INFO
40
41. /lib/lsb/init-functions
42
43case "${1}" in
44 start)
45 if [ -f /fastboot ]; then
46 msg="/fastboot found, will omit "
47 msg="${msg} file system checks as requested.\n"
48 log_info_msg "${msg}"
49 exit 0
50 fi
51
52 log_info_msg "Mounting root file system in read-only mode... "
53 mount -n -o remount,ro / >/dev/null
54
55 if [ ${?} != 0 ]; then
56 log_failure_msg2
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}"
63
64 log_info_msg "Press Enter to continue..."
65 wait_for_user
66 /etc/rc.d/init.d/halt stop
67 else
68 log_success_msg2
69 fi
70
71 if [ -f /forcefsck ]; then
72 msg="/forcefsck found, forcing file"
73 msg="${msg} system checks as requested."
74 log_success_msg "$msg"
75 options="-f"
76 else
77 options=""
78 fi
79
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
84 else
85 fsck ${options} -a -A -C -T >/dev/null
86 fi
87
88 error_value=${?}
89
90 if [ "${error_value}" = 0 ]; then
91 log_success_msg2
92 fi
93
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"
100 fi
101
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"
110
111 log_info_msg "Press Enter to continue..."
112 wait_for_user
113 reboot -f
114 fi
115
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"
127
128 log_info_msg "Press Enter to continue..."
129 wait_for_user
130 /etc/rc.d/init.d/halt stop
131 fi
132
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"
137 log_info_msg $msg
138 exit ${error_value}
139 fi
140
141 exit 0
142 ;;
143 *)
144 echo "Usage: ${0} {start}"
145 exit 1
146 ;;
147esac
148
149# End checkfs
Note: See TracBrowser for help on using the repository browser.