]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sbin/fsck_ffs/fsck_ffs.8
MFC r368207,368607:
[FreeBSD/stable/10.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 .\" 4. 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 October 5, 2016
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 BEFfnpRryZ
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 E
153 Clear unallocated blocks, notifying the underlying device that they
154 are not used and that their contents may be discarded.
155 This is useful for filesystems which have been mounted on systems
156 without TRIM support, or with TRIM support disabled, as well as
157 filesystems which have been copied from one device to another.
158 .Pp
159 See the
160 .Fl E
161 and
162 .Fl t
163 flags of
164 .Xr newfs 8 ,
165 and
166 the
167 .Fl t
168 flag of
169 .Xr tunefs 8 .
170 .It Fl F
171 Determine whether the file system needs to be cleaned immediately
172 in foreground, or if its cleaning can be deferred to background.
173 To be eligible for background cleaning it must have been running
174 with soft updates, not have been marked as needing a foreground check,
175 and be mounted and writable when the background check is to be done.
176 If these conditions are met, then
177 .Nm
178 exits with a zero exit status.
179 Otherwise it exits with a non-zero exit status.
180 If the file system is clean,
181 it will exit with a non-zero exit status so that the clean status
182 of the file system can be verified and reported during the foreground
183 checks.
184 Note that when invoked with the
185 .Fl F
186 flag, no cleanups are done.
187 The only thing that
188 .Nm
189 does is to determine whether a foreground or background
190 check is needed and exit with an appropriate status code.
191 .It Fl b
192 Use the block specified immediately after the flag as
193 the super block for the file system.
194 An alternate super block is usually located at block 32 for UFS1,
195 and block 160 for UFS2.
196 .Pp
197 See the
198 .Fl N
199 flag of
200 .Xr newfs 8 .
201 .It Fl C
202 Check if file system was dismounted cleanly.
203 If so, skip file system checks (like "preen").
204 However, if the file system was not cleanly dismounted, do full checks,
205 as if
206 .Nm
207 was invoked without
208 .Fl C .
209 .It Fl c
210 Convert the file system to the specified level.
211 Note that the level of a file system can only be raised.
212 There are currently four levels defined:
213 .Bl -tag -width indent
214 .It 0
215 The file system is in the old (static table) format.
216 .It 1
217 The file system is in the new (dynamic table) format.
218 .It 2
219 The file system supports 32-bit uid's and gid's,
220 short symbolic links are stored in the inode,
221 and directories have an added field showing the file type.
222 .It 3
223 If maxcontig is greater than one,
224 build the free segment maps to aid in finding contiguous sets of blocks.
225 If maxcontig is equal to one, delete any existing segment maps.
226 .El
227 .Pp
228 In interactive mode,
229 .Nm
230 will list the conversion to be made
231 and ask whether the conversion should be done.
232 If a negative answer is given,
233 no further operations are done on the file system.
234 In preen mode,
235 the conversion is listed and done if
236 possible without user interaction.
237 Conversion in preen mode is best used when all the file systems
238 are being converted at once.
239 The format of a file system can be determined from the
240 first line of output from
241 .Xr dumpfs 8 .
242 .Pp
243 This option implies the
244 .Fl f
245 flag.
246 .It Fl f
247 Force
248 .Nm
249 to check
250 .Sq clean
251 file systems when preening.
252 .It Fl m
253 Use the mode specified in octal immediately after the flag as the
254 permission bits to use when creating the
255 .Pa lost+found
256 directory rather than the default 1777.
257 In particular, systems that do not wish to have lost files accessible
258 by all users on the system should use a more restrictive
259 set of permissions such as 700.
260 .It Fl n
261 Assume a no response to all questions asked by
262 .Nm
263 except for
264 .Ql CONTINUE? ,
265 which is assumed to be affirmative;
266 do not open the file system for writing.
267 .It Fl p
268 Preen file systems (see above).
269 .It Fl R
270 Instruct fsck_ffs to restart itself if it encounters certain errors that
271 warrant another run.
272 It will limit itself to a maximum of 10 restarts in a given run in order
273 to avoid an endless loop with extremely corrupted filesystems.
274 .It Fl r
275 Free up excess unused inodes.
276 Decreasing the number of preallocated inodes reduces the
277 running time of future runs of
278 .Nm
279 and frees up space that can allocated to files.
280 The
281 .Fl r
282 option is ignored when running in preen mode.
283 .It Fl S
284 Surrender on error.
285 With this flag enabled, a hard error returned on disk i/o will cause
286 .Nm
287 to abort instead of continuing on and possibly tripping over more i/o errors.
288 .It Fl y
289 Assume a yes response to all questions asked by
290 .Nm ;
291 this should be used with great caution as this is a free license
292 to continue after essentially unlimited trouble has been encountered.
293 .It Fl Z
294 Similar to
295 .Fl E ,
296 but overwrites unused blocks with zeroes.
297 If both
298 .Fl E
299 and
300 .Fl Z
301 are specified, blocks are first zeroed and then erased.
302 .El
303 .Pp
304 Inconsistencies checked are as follows:
305 .Pp
306 .Bl -enum -compact
307 .It
308 Blocks claimed by more than one inode or the free map.
309 .It
310 Blocks claimed by an inode outside the range of the file system.
311 .It
312 Incorrect link counts.
313 .It
314 Size checks:
315 .Bl -item -offset indent -compact
316 .It
317 Directory size not a multiple of DIRBLKSIZ.
318 .It
319 Partially truncated file.
320 .El
321 .It
322 Bad inode format.
323 .It
324 Blocks not accounted for anywhere.
325 .It
326 Directory checks:
327 .Bl -item -offset indent -compact
328 .It
329 File pointing to unallocated inode.
330 .It
331 Inode number out of range.
332 .It
333 Directories with unallocated blocks (holes).
334 .It
335 Dot or dot-dot not the first two entries of a directory
336 or having the wrong inode number.
337 .El
338 .It
339 Super Block checks:
340 .Bl -item -offset indent -compact
341 .It
342 More blocks for inodes than there are in the file system.
343 .It
344 Bad free block map format.
345 .It
346 Total free block and/or free inode count incorrect.
347 .El
348 .El
349 .Pp
350 Orphaned files and directories (allocated but unreferenced) are,
351 with the operator's concurrence, reconnected by
352 placing them in the
353 .Pa lost+found
354 directory.
355 The name assigned is the inode number.
356 If the
357 .Pa lost+found
358 directory does not exist, it is created.
359 If there is insufficient space its size is increased.
360 .Pp
361 The full foreground
362 .Nm
363 checks for many more problems that may occur after an
364 unrecoverable disk write error.
365 Thus, it is recommended that you perform foreground
366 .Nm
367 on your systems periodically and whenever you encounter
368 unrecoverable disk write errors or file-system\-related panics.
369 .Sh FILES
370 .Bl -tag -width /etc/fstab -compact
371 .It Pa /etc/fstab
372 contains default list of file systems to check.
373 .El
374 .Sh EXIT STATUS
375 .Ex -std
376 .Pp
377 If the option
378 .Fl F
379 is used,
380 .Nm
381 exits 7 if the file system is clean.
382 .Sh DIAGNOSTICS
383 The diagnostics produced by
384 .Nm
385 are fully enumerated and explained in Appendix A of
386 .Rs
387 .%T "Fsck \- The UNIX File System Check Program"
388 .Re
389 .Sh SEE ALSO
390 .Xr fs 5 ,
391 .Xr fstab 5 ,
392 .Xr fsck 8 ,
393 .Xr fsdb 8 ,
394 .Xr newfs 8 ,
395 .Xr reboot 8
396 .Sh HISTORY
397 A
398 .Nm fsck
399 utility appeared in
400 .Bx 4.0 .
401 It became
402 .Nm
403 in
404 .Fx 5.0
405 with the introduction of the filesystem independent wrapper as
406 .Nm fsck .