OSDN Git Service

b2519b928e14e8b210788ace951a25f56f0c6502
[linuxjf/JF.git] / docs / LFS-BOOK / scripts / apds09.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4   <head>
5     <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
6     <title>
7       D.9. /etc/rc.d/init.d/checkfs
8     </title>
9     <link rel="stylesheet" href="../stylesheets/lfs.css" type="text/css" />
10     <meta name="generator" content="DocBook XSL Stylesheets V1.73.2" />
11     <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
12     "text/css" media="print" />
13   </head>
14   <body class="lfs" id="lfs-6.8">
15     <div class="navheader">
16       <h4>
17         Linux From Scratch - Version 6.8
18       </h4>
19       <h3>
20         付録 D. ブートスクリプトと sysconfig スクリプト version-20100627
21       </h3>
22       <ul>
23         <li class="prev">
24           <a accesskey="p" href="apds08.html" title=
25           "/etc/rc.d/init.d/setclock">前のページ</a>
26           <p>
27             /etc/rc.d/init.d/setclock
28           </p>
29         </li>
30         <li class="next">
31           <a accesskey="n" href="apds10.html" title=
32           "/etc/rc.d/init.d/mountfs">次のページ</a>
33           <p>
34             /etc/rc.d/init.d/mountfs
35           </p>
36         </li>
37         <li class="up">
38           <a accesskey="u" href="scripts.html" title=
39           "付録 D. ブートスクリプトと sysconfig スクリプト version-20100627">上に戻る</a>
40         </li>
41         <li class="home">
42           <a accesskey="h" href="../index.html" title=
43           "Linux From Scratch - Version 6.8">ホーム</a>
44         </li>
45       </ul>
46     </div>
47     <div class="wrap" lang="ja" xml:lang="ja">
48       <h1 class="sect1">
49         <a id="checkfs" name="checkfs"></a>D.9. /etc/rc.d/init.d/checkfs
50       </h1>
51       <pre class="screen">
52 #!/bin/sh
53 ########################################################################
54 # Begin $rc_base/init.d/checkfs
55 #
56 # Description : File System Check
57 #
58 # Authors     : Gerard Beekmans - gerard@linuxfromscratch.org
59 #               A. Luebke - luebke@users.sourceforge.net
60 #
61 # Version     : 00.00
62 #
63 # Notes       :
64 #
65 # Based on checkfs script from LFS-3.1 and earlier.
66 #
67 # From man fsck
68 # 0    - No errors
69 # 1    - File system errors corrected
70 # 2    - System should be rebooted
71 # 4    - File system errors left uncorrected
72 # 8    - Operational error
73 # 16   - Usage or syntax error
74 # 32   - Fsck canceled by user request
75 # 128  - Shared library error
76 #
77 #########################################################################
78
79 . /etc/sysconfig/rc
80 . ${rc_functions}
81
82 case "${1}" in
83     start)
84         if [ -f /fastboot ]; then
85             boot_mesg -n "/fastboot found, will not perform" ${INFO}
86             boot_mesg " file system checks as requested."
87             echo_ok
88             exit 0
89         fi
90
91         boot_mesg "Mounting root file system in read-only mode..."
92         mount -n -o remount,ro / &gt;/dev/null
93         evaluate_retval
94
95         if [ ${?} != 0 ]; then
96             echo_failure
97             boot_mesg -n "FAILURE:\n\nCannot check root" ${FAILURE}
98             boot_mesg -n " filesystem because it could not be mounted"
99             boot_mesg -n " in read-only mode.\n\nAfter you"
100             boot_mesg -n " press Enter, this system will be"
101             boot_mesg -n " halted and powered off."
102             boot_mesg -n "\n\nPress enter to continue..." ${INFO}
103             boot_mesg "" ${NORMAL}
104             read ENTER
105             ${rc_base}/init.d/halt stop
106         fi
107
108         if [ -f /forcefsck ]; then
109             boot_mesg -n "/forcefsck found, forcing file" ${INFO}
110             boot_mesg " system checks as requested."
111             echo_ok
112             options="-f"
113         else
114             options=""
115         fi
116
117         boot_mesg "Checking file systems..."
118         # Note: -a option used to be -p; but this fails e.g.
119         # on fsck.minix
120         fsck ${options} -a -A -C -T
121         error_value=${?}
122
123         if [ "${error_value}" = 0 ]; then
124             echo_ok
125         fi
126
127         if [ "${error_value}" = 1 ]; then
128             echo_warning
129             boot_mesg -n "WARNING:\n\nFile system errors" ${WARNING}
130             boot_mesg -n " were found and have been corrected."
131             boot_mesg -n "  You may want to double-check that"
132             boot_mesg -n " everything was fixed properly."
133             boot_mesg "" ${NORMAL}
134         fi
135
136         if [ "${error_value}" = 2 -o "${error_value}" = 3 ]; then
137             echo_warning
138             boot_mesg -n "WARNING:\n\nFile system errors" ${WARNING}
139             boot_mesg -n " were found and have been been"
140             boot_mesg -n " corrected, but the nature of the"
141             boot_mesg -n " errors require this system to be"
142             boot_mesg -n " rebooted.\n\nAfter you press enter,"
143             boot_mesg -n " this system will be rebooted"
144             boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
145             boot_mesg "" ${NORMAL}
146             read ENTER
147             reboot -f
148         fi
149
150         if [ "${error_value}" -gt 3 -a "${error_value}" -lt 16 ]; then
151             echo_failure
152             boot_mesg -n "FAILURE:\n\nFile system errors" ${FAILURE}
153             boot_mesg -n " were encountered that could not be"
154             boot_mesg -n " fixed automatically.  This system"
155             boot_mesg -n " cannot continue to boot and will"
156             boot_mesg -n " therefore be halted until those"
157             boot_mesg -n " errors are fixed manually by a"
158             boot_mesg -n " System Administrator.\n\nAfter you"
159             boot_mesg -n " press Enter, this system will be"
160             boot_mesg -n " halted and powered off."
161             boot_mesg -n "\n\nPress Enter to continue..." ${INFO}
162             boot_mesg "" ${NORMAL}
163             read ENTER
164           ${rc_base}/init.d/halt stop
165         fi
166
167         if [ "${error_value}" -ge 16 ]; then
168             echo_failure
169             boot_mesg -n "FAILURE:\n\nUnexpected Failure" ${FAILURE}
170             boot_mesg -n " running fsck.  Exited with error"
171             boot_mesg -n " code: ${error_value}."
172             boot_mesg "" ${NORMAL}
173             exit ${error_value}
174         fi
175         ;;
176     *)
177         echo "Usage: ${0} {start}"
178         exit 1
179         ;;
180 esac
181
182 # End $rc_base/init.d/checkfs
183 </pre>
184     </div>
185     <div class="navfooter">
186       <ul>
187         <li class="prev">
188           <a accesskey="p" href="apds08.html" title=
189           "/etc/rc.d/init.d/setclock">前のページ</a>
190           <p>
191             /etc/rc.d/init.d/setclock
192           </p>
193         </li>
194         <li class="next">
195           <a accesskey="n" href="apds10.html" title=
196           "/etc/rc.d/init.d/mountfs">次のページ</a>
197           <p>
198             /etc/rc.d/init.d/mountfs
199           </p>
200         </li>
201         <li class="up">
202           <a accesskey="u" href="scripts.html" title=
203           "付録 D. ブートスクリプトと sysconfig スクリプト version-20100627">上に戻る</a>
204         </li>
205         <li class="home">
206           <a accesskey="h" href="../index.html" title=
207           "Linux From Scratch - Version 6.8">ホーム</a>
208         </li>
209       </ul>
210     </div>
211   </body>
212 </html>