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