xref: /dragonfly/sbin/fsck/fsck.8 (revision 0085a56d)
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: src/sbin/fsck/fsck.8,v 1.14.2.3 2001/01/23 23:11:07 iedowse Exp $
31.\"
32.Dd September 29, 2016
33.Dt FSCK 8
34.Os
35.Sh NAME
36.Nm fsck
37.Nd UFS filesystem consistency check and interactive repair
38.Sh SYNOPSIS
39.Nm
40.Fl p
41.Op Fl f
42.Op Fl m Ar mode
43.Op Ar filesystem
44.Ar ...
45.Nm
46.Op Fl Lny
47.Op Fl b Ar block#
48.Op Fl c Ar level
49.Op Fl l Ar maxparallel
50.Op Fl m Ar mode
51.Op Ar filesystem
52.Ar ...
53.Sh DESCRIPTION
54The first form of
55.Nm
56preens a standard set of filesystems or the specified filesystems.
57It is normally used in the script
58.Pa /etc/rc
59during automatic reboot.
60Here
61.Nm
62reads the table
63.Pa /etc/fstab
64to determine which filesystems to check.
65Only partitions in fstab that are mounted ``rw,'' ``rq'' or ``ro''
66and that have non-zero pass number are checked.
67Filesystems with pass number 1 (normally just the root filesystem)
68are checked one at a time.
69When pass 1 completes, all remaining filesystems are checked,
70running one process per disk drive.
71The disk drive containing each filesystem is inferred from the longest prefix
72of the device name that ends in a digit; the remaining characters are assumed
73to be the partition designator.
74.Pp
75In "preen" mode the clean flag of each filesystem's superblock is examined
76and only those filesystems that
77are not marked clean are checked.
78Filesystems are marked clean when they are unmounted,
79when they have been mounted read-only, or when
80.Nm
81runs on them successfully.
82If the
83.Fl f
84option is specified, the filesystems
85will be checked regardless of the state of their clean flag.
86.Pp
87The kernel takes care that only a restricted class of innocuous filesystem
88inconsistencies can happen unless hardware or software failures intervene.
89These are limited to the following:
90.Pp
91.Bl -item -compact -offset indent
92.It
93Unreferenced inodes
94.It
95Link counts in inodes too large
96.It
97Missing blocks in the free map
98.It
99Blocks in the free map also in files
100.It
101Counts in the super-block wrong
102.El
103.Pp
104These are the only inconsistencies that
105.Nm
106with the
107.Fl p
108option will correct; if it encounters other inconsistencies, it exits
109with an abnormal return status and an automatic reboot will then fail.
110For each corrected inconsistency one or more lines will be printed
111identifying the filesystem on which the correction will take place,
112and the nature of the correction.  After successfully correcting a filesystem,
113.Nm
114will print the number of files on that filesystem,
115the number of used and free blocks,
116and the percentage of fragmentation.
117.Pp
118If sent a
119.Dv QUIT
120signal,
121.Nm
122will finish the filesystem checks, then exit with an abnormal
123return status that causes an automatic reboot to fail.
124This is useful when you want to finish the filesystem checks during an
125automatic reboot,
126but do not want the machine to come up multiuser after the checks complete.
127.Pp
128If
129.Nm
130receives a
131.Dv SIGINFO
132(see the
133.Dq status
134argument for
135.Xr stty 1 )
136signal, a line will be written to the standard output indicating
137the name of the device currently being checked, the current phase
138number and phase-specific progress information.
139.Pp
140Without the
141.Fl p
142option,
143.Nm
144audits and interactively repairs inconsistent conditions for filesystems.
145If the filesystem is inconsistent the operator is prompted for concurrence
146before each correction is attempted.
147It should be noted that some of the corrective actions which are not
148correctable under the
149.Fl p
150option will result in some loss of data.
151The amount and severity of data lost may be determined from the diagnostic
152output.
153The default action for each consistency correction
154is to wait for the operator to respond
155.Li yes
156or
157.Li no .
158If the operator does not have write permission on the filesystem
159.Nm
160will default to a
161.Fl n
162action.
163.Pp
164.Nm Fsck
165has more consistency checks than
166its predecessors
167.Em check , dcheck , fcheck ,
168and
169.Em icheck
170combined.
171.Pp
172The following flags are interpreted by
173.Nm .
174.Bl -tag -width indent
175.It Fl b
176Use the block specified immediately after the flag as
177the super block for the filesystem.  Block 32 is usually
178an alternate super block.
179.It Fl c
180Convert the filesystem to the specified level.
181Note that the level of a filesystem can only be raised.
182.Pp
183There are currently four levels defined:
184.Bl -tag -width indent
185.It 0
186The filesystem is in the old (static table) format.
187.It 1
188The filesystem is in the new (dynamic table) format.
189.It 2
190The filesystem supports 32-bit uid's and gid's,
191short symbolic links are stored in the inode,
192and directories have an added field showing the file type.
193.It 3
194If maxcontig is greater than one,
195build the free segment maps to aid in finding contiguous sets of blocks.
196If maxcontig is equal to one, delete any existing segment maps.
197.El
198.Pp
199In interactive mode,
200.Nm
201will list the conversion to be made
202and ask whether the conversion should be done.
203If a negative answer is given,
204no further operations are done on the filesystem.
205In preen mode,
206the conversion is listed and done if
207possible without user interaction.
208Conversion in preen mode is best used when all the filesystems
209are being converted at once.
210The format of a filesystem can be determined from the
211first line of output from
212.Xr dumpfs 8 .
213.It Fl f
214Force
215.Nm
216to check
217.Sq clean
218filesystems when preening.
219.It Fl l
220Limit the number of parallel checks to the number specified in the following
221argument.
222By default, the limit is the number of disks, running one process per disk.
223If a smaller limit is given, the disks are checked round-robin, one filesystem
224at a time.
225.It Fl L
226Just print the "last mounted on" information and exit, do no other checking.
227.It Fl m
228Use the mode specified in octal immediately after the flag as the
229permission bits to use when creating the
230.Pa lost+found
231directory rather than the default 1777.
232In particular, systems that do not wish to have lost files accessible
233by all users on the system should use a more restrictive
234set of permissions such as 700.
235.It Fl n
236Assume a no response to all questions asked by
237.Nm
238except for
239.Ql CONTINUE? ,
240which is assumed to be affirmative;
241do not open the filesystem for writing.
242.It Fl p
243Preen filesystems (see above).
244.It Fl y
245Assume a yes response to all questions asked by
246.Nm ;
247this should be used with great caution as this is a free license
248to continue after essentially unlimited trouble has been encountered.
249.El
250.Pp
251If no filesystems are given to
252.Nm
253then a default list of filesystems is read from
254the file
255.Pa /etc/fstab .
256.Pp
257Inconsistencies checked are as follows:
258.Bl -enum -compact
259.It
260Blocks claimed by more than one inode or the free map.
261.It
262Blocks claimed by an inode outside the range of the filesystem.
263.It
264Incorrect link counts.
265.It
266Size checks:
267.Bl -item -offset indent -compact
268.It
269Directory size not a multiple of DIRBLKSIZ.
270.It
271Partially truncated file.
272.El
273.It
274Bad inode format.
275.It
276Blocks not accounted for anywhere.
277.It
278Directory checks:
279.Bl -item -offset indent -compact
280.It
281File pointing to unallocated inode.
282.It
283Inode number out of range.
284.It
285Directories with unallocated blocks (holes).
286.It
287Dot or dot-dot not the first two entries of a directory
288or having the wrong inode number.
289.El
290.It
291Super Block checks:
292.Bl -item -offset indent -compact
293.It
294More blocks for inodes than there are in the filesystem.
295.It
296Bad free block map format.
297.It
298Total free block and/or free inode count incorrect.
299.El
300.El
301.Pp
302Orphaned files and directories (allocated but unreferenced) are,
303with the operator's concurrence, reconnected by
304placing them in the
305.Pa lost+found
306directory.
307The name assigned is the inode number.
308If the
309.Pa lost+found
310directory does not exist, it is created.
311If there is insufficient space its size is increased.
312.Pp
313Because of inconsistencies between the block device and the buffer cache,
314the raw device should always be used.
315.Sh FILES
316.Bl -tag -width /etc/fstab -compact
317.It Pa /etc/fstab
318contains default list of filesystems to check.
319.El
320.Sh DIAGNOSTICS
321The diagnostics produced by
322.Nm
323are fully enumerated and explained in Appendix A of
324.Rs
325.%T "Fsck \- The UNIX File System Check Program"
326.Re
327.Sh SEE ALSO
328.Xr fs 5 ,
329.Xr fstab 5 ,
330.Xr UFS 5 ,
331.Xr fsdb 8 ,
332.Xr newfs 8 ,
333.Xr reboot 8
334.Sh HISTORY
335The
336.Nm
337command appeared in
338.Bx 4.0 .
339