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