]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sbin/fsck_ffs/fsck_ffs.8
reboot(8): print syscall error on sysctl failure
[FreeBSD/FreeBSD.git] / sbin / fsck_ffs / fsck_ffs.8
1 .\"
2 .\" Copyright (c) 1980, 1989, 1991, 1993
3 .\"     The Regents of the University of California.  All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\" 3. Neither the name of the University nor the names of its contributors
14 .\"    may be used to endorse or promote products derived from this software
15 .\"    without specific prior written permission.
16 .\"
17 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
18 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
21 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" SUCH DAMAGE.
28 .\"
29 .\"     @(#)fsck.8      8.4 (Berkeley) 5/9/95
30 .\"
31 .Dd May 3, 2019
32 .Dt FSCK_FFS 8
33 .Os
34 .Sh NAME
35 .Nm fsck_ffs ,
36 .Nm fsck_ufs
37 .Nd file system consistency check and interactive repair
38 .Sh SYNOPSIS
39 .Nm
40 .Op Fl BCdEFfnpRrSyZz
41 .Op Fl b Ar block
42 .Op Fl c Ar level
43 .Op Fl m Ar mode
44 .Ar filesystem
45 .Ar ...
46 .Sh DESCRIPTION
47 The specified disk partitions and/or file systems are checked.
48 In "preen" or "check clean" mode the clean flag of each file system's
49 superblock is examined and only those file systems that are not marked clean
50 are checked.
51 File systems are marked clean when they are unmounted,
52 when they have been mounted read-only, or when
53 .Nm
54 runs on them successfully.
55 If the
56 .Fl f
57 option is specified, the file systems
58 will be checked regardless of the state of their clean flag.
59 .Pp
60 The kernel takes care that only a restricted class of innocuous file system
61 inconsistencies can happen unless hardware or software failures intervene.
62 These are limited to the following:
63 .Pp
64 .Bl -item -compact -offset indent
65 .It
66 Unreferenced inodes
67 .It
68 Link counts in inodes too large
69 .It
70 Missing blocks in the free map
71 .It
72 Blocks in the free map also in files
73 .It
74 Counts in the super-block wrong
75 .El
76 .Pp
77 These are the only inconsistencies that
78 .Nm
79 with the
80 .Fl p
81 option will correct; if it encounters other inconsistencies, it exits
82 with an abnormal return status and an automatic reboot will then fail.
83 For each corrected inconsistency one or more lines will be printed
84 identifying the file system on which the correction will take place,
85 and the nature of the correction.
86 After successfully correcting a file system,
87 .Nm
88 will print the number of files on that file system,
89 the number of used and free blocks,
90 and the percentage of fragmentation.
91 .Pp
92 If sent a
93 .Dv QUIT
94 signal,
95 .Nm
96 will finish the file system checks, then exit with an abnormal
97 return status that causes an automatic reboot to fail.
98 This is useful when you want to finish the file system checks during an
99 automatic reboot,
100 but do not want the machine to come up multiuser after the checks complete.
101 .Pp
102 If
103 .Nm
104 receives a
105 .Dv SIGINFO
106 (see the
107 .Dq status
108 argument for
109 .Xr stty 1 )
110 signal, a line will be written to the standard output indicating
111 the name of the device currently being checked, the current phase
112 number and phase-specific progress information.
113 .Pp
114 Without the
115 .Fl p
116 option,
117 .Nm
118 audits and interactively repairs inconsistent conditions for file systems.
119 If the file system is inconsistent the operator is prompted for concurrence
120 before each correction is attempted.
121 It should be noted that some of the corrective actions which are not
122 correctable under the
123 .Fl p
124 option will result in some loss of data.
125 The amount and severity of data lost may be determined from the diagnostic
126 output.
127 The default action for each consistency correction
128 is to wait for the operator to respond
129 .Li yes
130 or
131 .Li no .
132 If the operator does not have write permission on the file system
133 .Nm
134 will default to a
135 .Fl n
136 action.
137 .Pp
138 The following flags are interpreted by
139 .Nm :
140 .Bl -tag -width indent
141 .It Fl B
142 A check is done on the specified and possibly active file system.
143 The set of corrections that can be done is limited to those done
144 when running in preen mode (see the
145 .Fl p
146 flag).
147 If unexpected errors are found,
148 the file system is marked as needing a foreground check and
149 .Nm
150 exits without attempting any further cleaning.
151 .It Fl b
152 Use the block specified immediately after the flag as
153 the super block for the file system.
154 An alternate super block is usually located at block 32 for UFS1,
155 and block 192 for UFS2.
156 .Pp
157 See the
158 .Fl N
159 flag of
160 .Xr newfs 8 .
161 .It Fl C
162 Check if file system was dismounted cleanly.
163 If so, skip file system checks (like "preen").
164 However, if the file system was not cleanly dismounted, do full checks,
165 as if
166 .Nm
167 was invoked without
168 .Fl C .
169 .It Fl c
170 Convert the file system to the specified level.
171 Note that the level of a file system can only be raised.
172 There are currently four levels defined:
173 .Bl -tag -width indent
174 .It 0
175 The file system is in the old (static table) format.
176 .It 1
177 The file system is in the new (dynamic table) format.
178 .It 2
179 The file system supports 32-bit uid's and gid's,
180 short symbolic links are stored in the inode,
181 and directories have an added field showing the file type.
182 .It 3
183 If maxcontig is greater than one,
184 build the free segment maps to aid in finding contiguous sets of blocks.
185 If maxcontig is equal to one, delete any existing segment maps.
186 .El
187 .Pp
188 In interactive mode,
189 .Nm
190 will list the conversion to be made
191 and ask whether the conversion should be done.
192 If a negative answer is given,
193 no further operations are done on the file system.
194 In preen mode,
195 the conversion is listed and done if
196 possible without user interaction.
197 Conversion in preen mode is best used when all the file systems
198 are being converted at once.
199 The format of a file system can be determined from the
200 first line of output from
201 .Xr dumpfs 8 .
202 .Pp
203 This option implies the
204 .Fl f
205 flag.
206 .It Fl d
207 Enable debugging messages.
208 .It Fl E
209 Clear unallocated blocks, notifying the underlying device that they
210 are not used and that their contents may be discarded.
211 This is useful for filesystems which have been mounted on systems
212 without TRIM support, or with TRIM support disabled, as well as
213 filesystems which have been copied from one device to another.
214 .Pp
215 See the
216 .Fl E
217 and
218 .Fl t
219 flags of
220 .Xr newfs 8 ,
221 and
222 the
223 .Fl t
224 flag of
225 .Xr tunefs 8 .
226 .It Fl F
227 Determine whether the file system needs to be cleaned immediately
228 in foreground, or if its cleaning can be deferred to background.
229 To be eligible for background cleaning it must have been running
230 with soft updates, not have been marked as needing a foreground check,
231 and be mounted and writable when the background check is to be done.
232 If these conditions are met, then
233 .Nm
234 exits with a zero exit status.
235 Otherwise it exits with a non-zero exit status.
236 If the file system is clean,
237 it will exit with a non-zero exit status so that the clean status
238 of the file system can be verified and reported during the foreground
239 checks.
240 Note that when invoked with the
241 .Fl F
242 flag, no cleanups are done.
243 The only thing that
244 .Nm
245 does is to determine whether a foreground or background
246 check is needed and exit with an appropriate status code.
247 .It Fl f
248 Force
249 .Nm
250 to check
251 .Sq clean
252 file systems when preening.
253 .It Fl m
254 Use the mode specified in octal immediately after the flag as the
255 permission bits to use when creating the
256 .Pa lost+found
257 directory rather than the default 1777.
258 In particular, systems that do not wish to have lost files accessible
259 by all users on the system should use a more restrictive
260 set of permissions such as 700.
261 .It Fl n
262 Assume a no response to all questions asked by
263 .Nm
264 except for
265 .Ql CONTINUE? ,
266 which is assumed to be affirmative;
267 do not open the file system for writing.
268 .It Fl p
269 Preen file systems (see above).
270 .It Fl R
271 Instruct fsck_ffs to restart itself if it encounters certain errors that
272 warrant another run.
273 It will limit itself to a maximum of 10 restarts in a given run in order
274 to avoid an endless loop with extremely corrupted filesystems.
275 .It Fl r
276 Free up excess unused inodes.
277 Decreasing the number of preallocated inodes reduces the
278 running time of future runs of
279 .Nm
280 and frees up space that can allocated to files.
281 The
282 .Fl r
283 option is ignored when running in preen mode.
284 .It Fl S
285 Surrender on error.
286 With this flag enabled, a hard error returned on disk i/o will cause
287 .Nm
288 to abort instead of continuing on and possibly tripping over more i/o errors.
289 .It Fl y
290 Assume a yes response to all questions asked by
291 .Nm ;
292 this should be used with great caution as this is a free license
293 to continue after essentially unlimited trouble has been encountered.
294 .It Fl Z
295 Similar to
296 .Fl E ,
297 but overwrites unused blocks with zeroes.
298 If both
299 .Fl E
300 and
301 .Fl Z
302 are specified, blocks are first zeroed and then erased.
303 .It Fl z
304 Clear unused directory space.
305 The cleared space includes deleted file names and name padding.
306 .El
307 .Pp
308 Inconsistencies checked are as follows:
309 .Pp
310 .Bl -enum -compact
311 .It
312 Blocks claimed by more than one inode or the free map.
313 .It
314 Blocks claimed by an inode outside the range of the file system.
315 .It
316 Incorrect link counts.
317 .It
318 Size checks:
319 .Bl -item -offset indent -compact
320 .It
321 Directory size not a multiple of DIRBLKSIZ.
322 .It
323 Partially truncated file.
324 .El
325 .It
326 Bad inode format.
327 .It
328 Blocks not accounted for anywhere.
329 .It
330 Directory checks:
331 .Bl -item -offset indent -compact
332 .It
333 File pointing to unallocated inode.
334 .It
335 Inode number out of range.
336 .It
337 Directories with unallocated blocks (holes).
338 .It
339 Dot or dot-dot not the first two entries of a directory
340 or having the wrong inode number.
341 .El
342 .It
343 Super Block checks:
344 .Bl -item -offset indent -compact
345 .It
346 More blocks for inodes than there are in the file system.
347 .It
348 Bad free block map format.
349 .It
350 Total free block and/or free inode count incorrect.
351 .El
352 .El
353 .Pp
354 Orphaned files and directories (allocated but unreferenced) are,
355 with the operator's concurrence, reconnected by
356 placing them in the
357 .Pa lost+found
358 directory.
359 The name assigned is the inode number.
360 If the
361 .Pa lost+found
362 directory does not exist, it is created.
363 If there is insufficient space its size is increased.
364 .Pp
365 The full foreground
366 .Nm
367 checks for many more problems that may occur after an
368 unrecoverable disk write error.
369 Thus, it is recommended that you perform foreground
370 .Nm
371 on your systems periodically and whenever you encounter
372 unrecoverable disk write errors or file-system\-related panics.
373 .Sh FILES
374 .Bl -tag -width /etc/fstab -compact
375 .It Pa /etc/fstab
376 contains default list of file systems to check.
377 .El
378 .Sh EXIT STATUS
379 .Ex -std
380 .Pp
381 Specific non-zero exit status values used are:
382 .Bl -tag -width indent
383 .It 1
384 Usage error (missing or invalid command arguments).
385 .It 2
386 The
387 .Fl p
388 option was used and a
389 .Dv SIGQUIT
390 was received, indicating that the system should be returned to single
391 user mode after the file system check.
392 .It 3
393 The file system superblock cannot be read.
394 This could indicate that the file system device does not exist or is not yet
395 ready.
396 .It 4
397 A mounted file system was modified; the system should be rebooted.
398 .It 5
399 The
400 .Fl B
401 option was used and soft updates are not enabled on the file system.
402 .It 6
403 The
404 .Fl B
405 option was used and the kernel lacks needed support.
406 .It 7
407 The
408 .Fl F
409 option was used and the file system is clean.
410 .It 8
411 General error exit.
412 .It 16
413 The file system could not be completely repaired.
414 The file system may be able to be repaired by running
415 .Nm
416 on the file system again.
417 .El
418 .Sh DIAGNOSTICS
419 The diagnostics produced by
420 .Nm
421 are fully enumerated and explained in Appendix A of
422 .Rs
423 .%T "Fsck \- The UNIX File System Check Program"
424 .Re
425 .Sh SEE ALSO
426 .Xr fs 5 ,
427 .Xr fstab 5 ,
428 .Xr fsck 8 ,
429 .Xr fsdb 8 ,
430 .Xr newfs 8 ,
431 .Xr reboot 8
432 .Sh HISTORY
433 A
434 .Nm fsck
435 utility appeared in
436 .Bx 4.0 .
437 It became
438 .Nm
439 in
440 .Fx 5.0
441 with the introduction of the filesystem independent wrapper as
442 .Nm fsck .