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

multilib-10.1
Last change on this file since a1ad522 was a1ad522, checked in by Thomas Trepl <thomas@…>, 4 years ago

Merge changes from trunk to multilib

git-svn-id: http://svn.linuxfromscratch.org/LFS/branches/multilib@12034 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
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.