source: bootscripts/lfs/init.d/checkfs@ 5bc19fc

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.0 7.1 7.2 7.3 7.4 7.5 7.5-systemd 7.6 7.6-systemd 7.7 7.7-systemd 7.8 7.8-systemd 7.9 7.9-systemd 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 5bc19fc was 0cda898, checked in by Bruce Dubbs <bdubbs@…>, 13 years ago

Rewrite bootscripts and Chaper 7

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

  • Property mode set to 100644
File size: 4.5 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# Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
10#
11# Version : LFS 7.0
12#
13# Based on checkfs script from LFS-3.1 and earlier.
14#
15# From man fsck
16# 0 - No errors
17# 1 - File system errors corrected
18# 2 - System should be rebooted
19# 4 - File system errors left uncorrected
20# 8 - Operational error
21# 16 - Usage or syntax error
22# 32 - Fsck canceled by user request
23# 128 - Shared library error
24#
25#########################################################################
26
27### BEGIN INIT INFO
28# Provides: checkfs
29# Required-Start: udev swap $time
30# Should-Start:
31# Required-Stop:
32# Should-Stop:
33# Default-Start: S
34# Default-Stop:
35# Short-Description: Checks local filesystems before mounting.
36# Description: Checks local filesystmes before mounting.
37# X-LFS-Provided-By: LFS
38### END INIT INFO
39
40. /lib/boot/functions
41
42case "${1}" in
43 start)
44 if [ -f /fastboot ]; then
45 boot_mesg -n "/fastboot found, will not perform" ${INFO}
46 boot_mesg " file system checks as requested."
47 echo_ok
48 exit 0
49 fi
50
51 boot_mesg "Mounting root file system in read-only mode..."
52 mount -n -o remount,ro / >/dev/null
53 evaluate_retval
54
55 if [ ${?} != 0 ]; then
56 echo_failure
57 boot_mesg -n "FAILURE:\n\nCannot check root" ${FAILURE}
58 boot_mesg -n " filesystem because it could not be mounted"
59 boot_mesg -n " in read-only mode.\n\nAfter you"
60 boot_mesg -n " press Enter, this system will be"
61 boot_mesg -n " halted and powered off."
62 boot_mesg -n "\n\nPress enter to continue..." ${INFO}
63 boot_mesg "" ${NORMAL}
64 wait_for_user
65 /etc/rc.d/init.d/halt stop
66 fi
67
68 if [ -f /forcefsck ]; then
69 boot_mesg -n "/forcefsck found, forcing file" ${INFO}
70 boot_mesg " system checks as requested."
71 echo_ok
72 options="-f"
73 else
74 options=""
75 fi
76
77 boot_mesg "Checking file systems..."
78 # Note: -a option used to be -p; but this fails e.g.
79 # on fsck.minix
80 fsck ${options} -a -A -C -T
81 error_value=${?}
82
83 if [ "${error_value}" = 0 ]; then
84 echo_ok
85 fi
86
87 if [ "${error_value}" = 1 ]; then
88 echo_warning
89 boot_mesg -n "WARNING:\n\nFile system errors" ${WARNING}
90 boot_mesg -n " were found and have been corrected. "
91 boot_mesg -n " You may want to double-check that"
92 boot_mesg -n " everything was fixed properly."
93 boot_mesg "" ${NORMAL}
94 fi
95
96 if [ "${error_value}" = 2 -o "${error_value}" = 3 ]; then
97 echo_warning
98 boot_mesg -n "WARNING:\n\nFile system errors" ${WARNING}
99 boot_mesg -n " were found and have been been"
100 boot_mesg -n " corrected, but the nature of the"
101 boot_mesg -n " errors require this system to be"
102 boot_mesg -n " rebooted.\n\nAfter you press enter,"
103 boot_mesg -n " this system will be rebooted"
104 boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
105 boot_mesg "" ${NORMAL}
106 wait_for_user
107 reboot -f
108 fi
109
110 if [ "${error_value}" -gt 3 -a "${error_value}" -lt 16 ]; then
111 echo_failure
112 boot_mesg -n "FAILURE:\n\nFile system errors" ${FAILURE}
113 boot_mesg -n " were encountered that could not be"
114 boot_mesg -n " fixed automatically. This system"
115 boot_mesg -n " cannot continue to boot and will"
116 boot_mesg -n " therefore be halted until those"
117 boot_mesg -n " errors are fixed manually by a"
118 boot_mesg -n " System Administrator.\n\nAfter you"
119 boot_mesg -n " press Enter, this system will be"
120 boot_mesg -n " halted and powered off."
121 boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
122 boot_mesg "" ${NORMAL}
123 wait_for_user
124 /etc/rc.d/init.d/halt stop
125 fi
126
127 if [ "${error_value}" -ge 16 ]; then
128 echo_failure
129 boot_mesg -n "FAILURE:\n\nUnexpected Failure" ${FAILURE}
130 boot_mesg -n " running fsck. Exited with error"
131 boot_mesg -n " code: ${error_value}."
132 boot_mesg "" ${NORMAL}
133 exit ${error_value}
134 fi
135 ;;
136 *)
137 echo "Usage: ${0} {start}"
138 exit 1
139 ;;
140esac
141
142# End checkfs
Note: See TracBrowser for help on using the repository browser.