xref: /freebsd/sbin/fsck_ffs/fsck_ffs.8 (revision 4f1f4356f3012928b463f9ef1710fb908e48b1e2)
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 January 25, 2009
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 BFprfny
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
48The specified disk partitions and/or file systems are checked.
49In "preen" or "check clean" mode the clean flag of each file system's
50superblock is examined and only those file systems that are not marked clean
51are checked.
52File systems are marked clean when they are unmounted,
53when they have been mounted read-only, or when
54.Nm
55runs on them successfully.
56If the
57.Fl f
58option is specified, the file systems
59will be checked regardless of the state of their clean flag.
60.Pp
61The kernel takes care that only a restricted class of innocuous file system
62inconsistencies can happen unless hardware or software failures intervene.
63These are limited to the following:
64.Pp
65.Bl -item -compact -offset indent
66.It
67Unreferenced inodes
68.It
69Link counts in inodes too large
70.It
71Missing blocks in the free map
72.It
73Blocks in the free map also in files
74.It
75Counts in the super-block wrong
76.El
77.Pp
78These are the only inconsistencies that
79.Nm
80with the
81.Fl p
82option will correct; if it encounters other inconsistencies, it exits
83with an abnormal return status and an automatic reboot will then fail.
84For each corrected inconsistency one or more lines will be printed
85identifying the file system on which the correction will take place,
86and the nature of the correction.
87After successfully correcting a file system,
88.Nm
89will print the number of files on that file system,
90the number of used and free blocks,
91and the percentage of fragmentation.
92.Pp
93If sent a
94.Dv QUIT
95signal,
96.Nm
97will finish the file system checks, then exit with an abnormal
98return status that causes an automatic reboot to fail.
99This is useful when you want to finish the file system checks during an
100automatic reboot,
101but do not want the machine to come up multiuser after the checks complete.
102.Pp
103If
104.Nm
105receives a
106.Dv SIGINFO
107(see the
108.Dq status
109argument for
110.Xr stty 1 )
111signal, a line will be written to the standard output indicating
112the name of the device currently being checked, the current phase
113number and phase-specific progress information.
114.Pp
115Without the
116.Fl p
117option,
118.Nm
119audits and interactively repairs inconsistent conditions for file systems.
120If the file system is inconsistent the operator is prompted for concurrence
121before each correction is attempted.
122It should be noted that some of the corrective actions which are not
123correctable under the
124.Fl p
125option will result in some loss of data.
126The amount and severity of data lost may be determined from the diagnostic
127output.
128The default action for each consistency correction
129is to wait for the operator to respond
130.Li yes
131or
132.Li no .
133If the operator does not have write permission on the file system
134.Nm
135will default to a
136.Fl n
137action.
138.Pp
139The following flags are interpreted by
140.Nm :
141.Bl -tag -width indent
142.It Fl F
143Determine whether the file system needs to be cleaned immediately
144in foreground, or if its cleaning can be deferred to background.
145To be eligible for background cleaning it must have been running
146with soft updates, not have been marked as needing a foreground check,
147and be mounted and writable when the background check is to be done.
148If these conditions are met, then
149.Nm
150exits with a zero exit status.
151Otherwise it exits with a non-zero exit status.
152If the file system is clean,
153it will exit with a non-zero exit status so that the clean status
154of the file system can be verified and reported during the foreground
155checks.
156Note that when invoked with the
157.Fl F
158flag, no cleanups are done.
159The only thing that
160.Nm
161does is to determine whether a foreground or background
162check is needed and exit with an appropriate status code.
163.It Fl B
164A check is done on the specified and possibly active file system.
165The set of corrections that can be done is limited to those done
166when running in preen mode (see the
167.Fl p
168flag).
169If unexpected errors are found,
170the file system is marked as needing a foreground check and
171.Nm
172exits without attempting any further cleaning.
173.It Fl b
174Use the block specified immediately after the flag as
175the super block for the file system.
176An alternate super block is usually located at block 32 for UFS1,
177and block 160 for UFS2.
178.It Fl C
179Check if file system was dismounted cleanly.
180If so, skip file system checks (like "preen").
181However, if the file system was not cleanly dismounted, do full checks,
182as if
183.Nm
184was invoked without
185.Fl C .
186.It Fl c
187Convert the file system to the specified level.
188Note that the level of a file system can only be raised.
189There are currently four levels defined:
190.Bl -tag -width indent
191.It 0
192The file system is in the old (static table) format.
193.It 1
194The file system is in the new (dynamic table) format.
195.It 2
196The file system supports 32-bit uid's and gid's,
197short symbolic links are stored in the inode,
198and directories have an added field showing the file type.
199.It 3
200If maxcontig is greater than one,
201build the free segment maps to aid in finding contiguous sets of blocks.
202If maxcontig is equal to one, delete any existing segment maps.
203.El
204.Pp
205In interactive mode,
206.Nm
207will list the conversion to be made
208and ask whether the conversion should be done.
209If a negative answer is given,
210no further operations are done on the file system.
211In preen mode,
212the conversion is listed and done if
213possible without user interaction.
214Conversion in preen mode is best used when all the file systems
215are being converted at once.
216The format of a file system can be determined from the
217first line of output from
218.Xr dumpfs 8 .
219.Pp
220This option implies the
221.Fl f
222flag.
223.It Fl f
224Force
225.Nm
226to check
227.Sq clean
228file systems when preening.
229.It Fl m
230Use the mode specified in octal immediately after the flag as the
231permission bits to use when creating the
232.Pa lost+found
233directory rather than the default 1777.
234In particular, systems that do not wish to have lost files accessible
235by all users on the system should use a more restrictive
236set of permissions such as 700.
237.It Fl n
238Assume a no response to all questions asked by
239.Nm
240except for
241.Ql CONTINUE? ,
242which is assumed to be affirmative;
243do not open the file system for writing.
244.It Fl p
245Preen file systems (see above).
246.It Fl r
247Free up excess unused inodes.
248Decreasing the number of preallocated inodes reduces the
249running time of future runs of
250.Nm
251and frees up space that can allocated to files.
252The
253.Fl r
254option is ignored when running in preen mode.
255.It Fl y
256Assume a yes response to all questions asked by
257.Nm ;
258this should be used with great caution as this is a free license
259to continue after essentially unlimited trouble has been encountered.
260.El
261.Pp
262Inconsistencies checked are as follows:
263.Pp
264.Bl -enum -compact
265.It
266Blocks claimed by more than one inode or the free map.
267.It
268Blocks claimed by an inode outside the range of the file system.
269.It
270Incorrect link counts.
271.It
272Size checks:
273.Bl -item -offset indent -compact
274.It
275Directory size not a multiple of DIRBLKSIZ.
276.It
277Partially truncated file.
278.El
279.It
280Bad inode format.
281.It
282Blocks not accounted for anywhere.
283.It
284Directory checks:
285.Bl -item -offset indent -compact
286.It
287File pointing to unallocated inode.
288.It
289Inode number out of range.
290.It
291Directories with unallocated blocks (holes).
292.It
293Dot or dot-dot not the first two entries of a directory
294or having the wrong inode number.
295.El
296.It
297Super Block checks:
298.Bl -item -offset indent -compact
299.It
300More blocks for inodes than there are in the file system.
301.It
302Bad free block map format.
303.It
304Total free block and/or free inode count incorrect.
305.El
306.El
307.Pp
308Orphaned files and directories (allocated but unreferenced) are,
309with the operator's concurrence, reconnected by
310placing them in the
311.Pa lost+found
312directory.
313The name assigned is the inode number.
314If the
315.Pa lost+found
316directory does not exist, it is created.
317If there is insufficient space its size is increased.
318.Pp
319The full foreground
320.Nm
321checks for many more problems that may occur after an
322unrecoverable disk write error.
323Thus, it is recommended that you perform foreground
324.Nm
325on your systems periodically and whenever you encounter
326unrecoverable disk write errors or file-system\-related panics.
327.Sh FILES
328.Bl -tag -width /etc/fstab -compact
329.It Pa /etc/fstab
330contains default list of file systems to check.
331.El
332.Sh EXIT STATUS
333.Ex -std
334.Pp
335If the option
336.Fl F
337is used,
338.Nm
339exits 7 if the file system is clean.
340.Sh DIAGNOSTICS
341The diagnostics produced by
342.Nm
343are fully enumerated and explained in Appendix A of
344.Rs
345.%T "Fsck \- The UNIX File System Check Program"
346.Re
347.Sh SEE ALSO
348.Xr fs 5 ,
349.Xr fstab 5 ,
350.Xr fsck 8 ,
351.Xr fsdb 8 ,
352.Xr newfs 8 ,
353.Xr reboot 8
354