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