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