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